From 2f3d57f4eca1fbd1038e72ee66474918d989d3f6 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:07:29 +0100 Subject: [PATCH] Running docker pull in the background (#2864) * Using only one script to launch MAPDL * Fixing doc build * Running docker pull in the background * Fixing env var generation * Waiting for port to be open * test * test * test 3 * Fix path * Fixing waiting * Applying changes to DPF too --- .github/workflows/ci.yml | 142 ++++++++++++++++++++++++++------------- 1 file changed, 96 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7478239ac5..5fe0ba21ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,6 +118,28 @@ jobs: - name: "Install Git and checkout project" uses: actions/checkout@v4 + - name: "Login in Github container registry" + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: "Pull, launch, and validate MAPDL service" + id: start_mapdl + env: + LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} + MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} + DISTRIBUTED_MODE: "dmp" + run: | + .ci/start_mapdl.sh &> mapdl_launch.log & export DOCKER_PID=$! + echo "Launching MAPDL service at PID: $DOCKER_PID" + echo "DOCKER_PID=$(echo $DOCKER_PID)" >> $GITHUB_OUTPUT + + - name: "DPF server activation" + run: | + $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & + - name: "Getting files change filters" uses: dorny/paths-filter@v3 id: changes @@ -158,20 +180,6 @@ jobs: pip install . xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - name: "Login in Github container registry" - uses: docker/login-action@v3.0.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: "Pull, launch, and validate MAPDL service" - run: .ci/start_mapdl.sh - env: - LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} - MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} - DISTRIBUTED_MODE: "dmp" - - name: "Retrieve PyMAPDL version" id: version run: | @@ -209,10 +217,26 @@ jobs: run: | pip install .[doc] - - name: "DPF server activation" + - name: "Waiting for the services to be up" run: | - docker pull ghcr.io/ansys/dpf-core:22.2dev - docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}." + echo "Waiting for the MAPDL service to be up..." + nc -v -z localhost $PYMAPDL_PORT + echo "::group:: ps aux Output" && ps aux && echo "::endgroup::" + + echo "Waiting for MAPDL port is open..." + echo "::group:: Waiting for the MAPDL port to be open..." + while ! nc -z localhost $PYMAPDL_PORT; do + sleep 0.1 + done + echo "::endgroup::" + echo "MAPDL service is up!" + + echo "::group:: Waiting for the DPF port to be open..." + while ! nc -z localhost $DPF_PORT; do + sleep 0.1 + done + echo "::endgroup::" + echo "DPF service is up!" - name: "Build documentation" run: | @@ -336,6 +360,39 @@ jobs: - name: "Install Git and checkout project" uses: actions/checkout@v4 + - name: "Login in Github container registry" + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: "Getting SMP/DMP mode" + id: distributed_mode + run: | + image=${{ matrix.mapdl-version }} + export distributed_mode="smp" + if [[ $image == *".1."* ]]; then + export distributed_mode="dmp"; + fi + echo "Distributed mode: $distributed_mode" + echo "distributed_mode=$(echo $distributed_mode)" >> $GITHUB_OUTPUT + + - name: "Pull, launch, and validate MAPDL service" + id: start_mapdl + env: + LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} + MAPDL_VERSION: ${{ matrix.mapdl-version }} + DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} + run: | + .ci/start_mapdl.sh &> mapdl_launch.log & export DOCKER_PID=$! + echo "Launching MAPDL service at PID: $DOCKER_PID" + echo "DOCKER_PID=$(echo $DOCKER_PID)" >> $GITHUB_OUTPUT + + - name: "DPF server activation" + run: | + $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & + - name: "Getting files change filters" uses: dorny/paths-filter@v3 id: changes @@ -374,45 +431,37 @@ jobs: python -m pip install dist/*.whl xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - name: "Login in Github container registry" - uses: docker/login-action@v3.0.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: "Getting SMP/DMP mode" - id: distributed_mode - run: | - image=${{ matrix.mapdl-version }} - export distributed_mode="smp" - if [[ $image == *".1."* ]]; then - export distributed_mode="dmp"; - fi - echo "Distributed mode: $distributed_mode" - echo "distributed_mode=$(echo $distributed_mode)" >> $GITHUB_OUTPUT - - - name: "Pull, launch, and validate MAPDL service" - env: - LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} - MAPDL_VERSION: ${{ matrix.mapdl-version }} - DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} - run: .ci/start_mapdl.sh - - name: "Unit testing requirements installation" run: | python -m pip install .[tests] - - name: "DPF server activation" + - name: "Waiting for the services to be up" run: | - docker pull ghcr.io/ansys/dpf-core:22.2dev - docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}." + echo "Waiting for the MAPDL service to be up..." + nc -v -z localhost $PYMAPDL_PORT + echo "::group:: ps aux Output" && ps aux && echo "::endgroup::" + + echo "Waiting for MAPDL port is open..." + echo "::group:: Waiting for the MAPDL port to be open..." + while ! nc -z localhost $PYMAPDL_PORT; do + sleep 0.1 + done + echo "::endgroup::" + echo "MAPDL service is up!" + + echo "::group:: Waiting for the DPF port to be open..." + while ! nc -z localhost $DPF_PORT; do + sleep 0.1 + done + echo "::endgroup::" + echo "DPF service is up!" - name: "Unit testing" env: DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} run: | - if [[ "${{ matrix.mapdl-version }}" == *"ubuntu"* ]]; then export ON_UBUNTU=true;fi + if [[ "${{ matrix.mapdl-version }}" == *"ubuntu"* ]]; then export ON_UBUNTU=true; else export ON_UBUNTU=false; fi + echo "ON_UBUNTU: $ON_UBUNTU" xvfb-run pytest \ ${{ env.PYTEST_ARGUMENTS }} \ --ignore_image_cache \ @@ -479,6 +528,7 @@ jobs: if: always() run: | cp log.txt ./logs-${{ matrix.mapdl-version }}/log.txt || echo "MAPDL log not found." + cp mapdl_launch.log ./logs-${{ matrix.mapdl-version }}/mapdl_launch.log || echo "MAPDL log not found." tar cvzf ./logs-${{ matrix.mapdl-version }}.tgz ./logs-${{ matrix.mapdl-version }} || echo "Failed to compress" - name: "Upload logs to GitHub"