Skip to content

Commit

Permalink
Running docker pull in the background (#2864)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
germa89 authored Mar 8, 2024
1 parent 872112a commit 2f3d57f
Showing 1 changed file with 96 additions and 46 deletions.
142 changes: 96 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,28 @@ jobs:
- name: "Install Git and checkout project"
uses: actions/checkout@v4

- name: "Login in Github container registry"
uses: docker/[email protected]
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
Expand Down Expand Up @@ -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/[email protected]
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: |
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -336,6 +360,39 @@ jobs:
- name: "Install Git and checkout project"
uses: actions/checkout@v4

- name: "Login in Github container registry"
uses: docker/[email protected]
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
Expand Down Expand Up @@ -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/[email protected]
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 \
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 2f3d57f

Please sign in to comment.