Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning and externalising functions in ci.yml #2868

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .ci/collect_mapdl_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
if [[ $MAPDL_VERSION == *"ubuntu"* ]] ; then
echo "It is an ubuntu based image"
export FILE=/jobs/file
export WDIR='/jobs/'

else
echo "It is a CentOS based image"
export FILE=file
export WDIR=""

fi;


mkdir "$LOG_NAMES" && echo "Successfully generated directory $LOG_NAMES"

####
echo "Collecting MAPDL logs..."

docker exec "$MAPDL_INSTANCE" /bin/bash -c "mkdir -p /mapdl_logs && echo 'Successfully created directory inside docker container'" || echo "Failed to create a directory inside docker container for logs."
docker exec "$MAPDL_INSTANCE" /bin/bash -c "if compgen -G '$FILE*.out' > /dev/null ;then cp -f /file*.out /mapdl_logs && echo 'Successfully copied out files.'; fi" || echo "Failed to copy the 'out' files into a local file"
docker exec "$MAPDL_INSTANCE" /bin/bash -c "if compgen -G '$FILE*.err' > /dev/null ;then cp -f /file*.err /mapdl_logs && echo 'Successfully copied err files.'; fi" || echo "Failed to copy the 'err' files into a local file"
docker exec "$MAPDL_INSTANCE" /bin/bash -c "if compgen -G '$FILE*.log' > /dev/null ;then cp -f /file*.log /mapdl_logs && echo 'Successfully copied log files.'; fi" || echo "Failed to copy the 'log' files into a local file"
docker exec "$MAPDL_INSTANCE" /bin/bash -c "if compgen -G '$WDIR*.crash' > /dev/null ;then cp -f /*.crash /mapdl_logs && echo 'Successfully copied crash files.'; fi" || echo "Failed to copy the 'crash' files into a local file"

docker cp "$MAPDL_INSTANCE":/mapdl_logs/. ./"$LOG_NAMES"/. || echo "Failed to copy the 'log-build-docs' files into a local directory"

####
echo "Collecting local build logs..."

echo "Collecting docker run log..."
cp log.txt ./"$LOG_NAMES"/log.txt || echo "MAPDL run docker log not found."

echo "Copying docker launch log..."
cp mapdl_launch.log ./"$LOG_NAMES"/mapdl_launch.log || echo "MAPDL launch docker log not found."

echo "Collecting file structure..."
ls -R > ./"$LOG_NAMES"/files_structure.txt || echo "Failed to copy file structure to a file"

echo "Collecting docker file structure..."
docker exec "$MAPDL_INSTANCE" /bin/bash -c "ls -R" > ./"$LOG_NAMES"/docker_files_structure.txt || echo "Failed to copy the docker structure into a local file"

echo "Tar files..."
tar cvzf ./"$LOG_NAMES".tgz ./"$LOG_NAMES" || echo "Failed to compress"
20 changes: 20 additions & 0 deletions .ci/display_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

echo "::group:: Display files structure" && ls -R && echo "::endgroup::"


echo "::group:: Display files structure" && docker exec "$MAPDL_INSTANCE" /bin/bash -c "ls -R" && echo "::endgroup::" || echo "Failed to display the docker structure."


echo "::group:: Display docker run log" && cat log.txt && echo "::endgroup::"

# Displaying MAPDL files
FILE_PAT=./"$LOG_NAMES"/*.err
if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: Error file $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to display the 'out' files."

FILE_PAT=./"$LOG_NAMES"/*.log
if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: Log file $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to display the 'err' files."

FILE_PAT=./"$LOG_NAMES"/*.out
if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: Output file $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to display the 'log' files."

5 changes: 5 additions & 0 deletions .ci/substitute_defective_gif.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
cd doc/_build/html/examples/gallery_examples/00-mapdl-examples
cp ../../../../../source/images/dcb.gif ../../../_images/
sed -i 's+../../../_images/sphx_glr_composite_dcb_004.gif+../../../_images/dcb.gif+g' composite_dcb.html
cd ../../../../../../
19 changes: 19 additions & 0 deletions .ci/waiting_services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
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!"
157 changes: 26 additions & 131 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
uses: ansys/actions/doc-style@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: 2.29.6

smoke-tests:
name: Build and smoke test (${{ matrix.os }} | Python ${{ matrix.python-version }}) (Release=${{ matrix.should-release }})
Expand Down Expand Up @@ -219,35 +218,15 @@ jobs:

- name: "Waiting for the services to be up"
run: |
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!"
.ci/waiting_services.sh

- name: "Build documentation"
run: |
xvfb-run make -C doc html SPHINXOPTS="-j auto -W --keep-going"

- name: "Substitute defective GIF"
run: |
cd doc/_build/html/examples/gallery_examples/00-mapdl-examples
cp ../../../../../source/images/dcb.gif ../../../_images/
sed -i 's+../../../_images/sphx_glr_composite_dcb_004.gif+../../../_images/dcb.gif+g' composite_dcb.html
cd ../../../../../../
.ci/substitute_defective_gif.sh

- name: "Upload HTML Documentation"
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -278,36 +257,14 @@ jobs:
name: minimum_requirements.txt
path: ./minimum_requirements.txt

- name: "Display files structure"
if: always()
run: |
mkdir logs-build-docs
echo "::group:: Display files structure" && ls -R && echo "::endgroup::"
ls -R > ./logs-build-docs/files_structure.txt

- name: "Display Docker files structures"
if: always()
run: |
echo "::group:: Display files structure" && docker exec mapdl /bin/bash -c "ls -R" && echo "::endgroup::" || echo "Failed to display the docker structure."
docker exec mapdl /bin/bash -c "ls -R" > ./logs-build-docs/docker_files_structure.txt || echo "Failed to copy the docker structure into a local file"

- name: "Collect MAPDL logs on failure"
if: always()
run: |
docker exec mapdl /bin/bash -c "mkdir -p /mapdl_logs && echo 'Successfully created directory inside docker container'" || echo "Failed to create a directory inside docker container for logs."
docker exec mapdl /bin/bash -c "if compgen -G 'file*.out' > /dev/null ;then cp -f /file*.out /mapdl_logs && echo 'Successfully copied out files.'; fi" || echo "Failed to copy the 'out' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G 'file*.err' > /dev/null ;then cp -f /file*.err /mapdl_logs && echo 'Successfully copied err files.'; fi" || echo "Failed to copy the 'err' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G 'file*.log' > /dev/null ;then cp -f /file*.log /mapdl_logs && echo 'Successfully copied log files.'; fi" || echo "Failed to copy the 'log' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G '*.crash' > /dev/null ;then cp -f /*.crash /mapdl_logs && echo 'Successfully copied crash files.'; fi" || echo "Failed to copy the 'crash' files into a local file"
docker cp mapdl:/mapdl_logs/. ./logs-build-docs/. || echo "Failed to copy the 'log-build-docs' files into a local directory"

- name: "Tar logs"
- name: "Collect logs on failure"
if: always()
env:
MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }}
MAPDL_INSTANCE: mapdl
LOG_NAMES: logs-build-docs
run: |
cp -f doc/_build/latex/*.log ./logs-build-docs/ || echo "Latex logs could not be found."

cp log.txt ./logs-build-docs/ || echo "MAPDL log could not be found."
tar cvzf ./logs-build-docs.tgz ./logs-build-docs
.ci/collect_mapdl_logs.sh

- name: "Upload logs to GitHub"
if: always()
Expand All @@ -316,10 +273,13 @@ jobs:
name: logs-build-docs.tgz
path: ./logs-build-docs.tgz

- name: "Display MAPDL Logs"
- name: "Display files structure"
if: always()
run: cat log.txt || echo "MAPDL log could not be found."

env:
MAPDL_INSTANCE: mapdl
LOG_NAMES: logs-build-docs
run: |
.ci/display_logs.sh


build-test:
Expand Down Expand Up @@ -437,24 +397,7 @@ jobs:

- name: "Waiting for the services to be up"
run: |
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!"
.ci/waiting_services.sh

- name: "Unit testing"
env:
Expand Down Expand Up @@ -491,45 +434,14 @@ jobs:
path: dist/
retention-days: 7

- name: "Display files structure"
if: always()
run: |
mkdir logs-${{ matrix.mapdl-version }} && echo "Successfully generated directory ${{ matrix.mapdl-version }}"
echo "::group:: Display files structure" && ls -R && echo "::endgroup::"
ls -R > ./logs-${{ matrix.mapdl-version }}/files_structure.txt

- name: "Display docker files structures"
if: always()
run: |
echo "::group:: Display files structure" && docker exec mapdl /bin/bash -c "ls -R" && echo "::endgroup::"
docker exec mapdl /bin/bash -c "ls -R" > ./logs-${{ matrix.mapdl-version }}/docker_files_structure.txt || echo "Failed to copy the docker structure into a local file"

- name: "Collect MAPDL logs on failure"
if: ${{ always() && !contains( matrix.mapdl-version, 'ubuntu') }}
run: |
docker exec mapdl /bin/bash -c "mkdir -p /mapdl_logs && echo 'Successfully created directory inside docker container'" || echo "Failed to create a directory inside docker container for logs."
docker exec mapdl /bin/bash -c "if compgen -G 'file*.out' > /dev/null ;then cp -f /file*.out /mapdl_logs && echo 'Successfully copied out files.'; fi" || echo "Failed to copy the 'out' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G 'file*.err' > /dev/null ;then cp -f /file*.err /mapdl_logs && echo 'Successfully copied err files.'; fi" || echo "Failed to copy the 'err' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G 'file*.log' > /dev/null ;then cp -f /file*.log /mapdl_logs && echo 'Successfully copied log files.'; fi" || echo "Failed to copy the 'log' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G '*.crash' > /dev/null ;then cp -f /*.crash /mapdl_logs && echo 'Successfully copied crash files.'; fi" || echo "Failed to copy the 'crash' files into a local file"
docker cp mapdl:/mapdl_logs/. ./logs-${{ matrix.mapdl-version }}/.

- name: "Collect MAPDL logs on failure for ubuntu image"
if: ${{ always() && contains( matrix.mapdl-version,'ubuntu') }}
run: |
docker exec mapdl /bin/bash -c "mkdir -p /mapdl_logs && echo 'Successfully created directory inside docker container'" || echo "Failed to create a directory inside docker container for logs."
docker exec mapdl /bin/bash -c "if compgen -G '/jobs/file*.out' > /dev/null ;then cp -f /jobs/file*.out /mapdl_logs && echo 'Successfully copied out files.'; fi" || echo "Failed to copy the 'out' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G '/jobs/file*.err' > /dev/null ;then cp -f /jobs/file*.err /mapdl_logs && echo 'Successfully copied err files.'; fi" || echo "Failed to copy the 'err' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G '/jobs/file*.log' > /dev/null ;then cp -f /jobs/file*.log /mapdl_logs && echo 'Successfully copied log files.'; fi" || echo "Failed to copy the 'log' files into a local file"
docker exec mapdl /bin/bash -c "if compgen -G '/jobs/*.crash' > /dev/null ;then cp -f /jobs/*.crash /mapdl_logs && echo 'Successfully copied crash files.'; fi" || echo "Failed to copy the 'crash' files into a local file"
docker cp mapdl:/mapdl_logs/. ./logs-${{ matrix.mapdl-version }}/.

- name: "Tar logs"
- name: "Collect logs on failure"
if: always()
env:
MAPDL_VERSION: ${{ matrix.mapdl-version }}
MAPDL_INSTANCE: mapdl
LOG_NAMES: logs-${{ matrix.mapdl-version }}
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"
.ci/collect_mapdl_logs.sh

- name: "Upload logs to GitHub"
if: always()
Expand All @@ -538,17 +450,13 @@ jobs:
name: logs-${{ matrix.mapdl-version }}.tgz
path: ./logs-${{ matrix.mapdl-version }}.tgz

- name: "Display MAPDL Logs"
if: always()
run: cat log.txt

- name: "List main files"
- name: "Display files structure"
if: always()
env:
MAPDL_INSTANCE: mapdl
LOG_NAMES: logs-${{ matrix.mapdl-version }}
run: |
if compgen -G './logs-${{ matrix.mapdl-version }}/*.err' > /dev/null ;then for f in ./logs-${{ matrix.mapdl-version }}/*.err; do echo "::group:: Error file $f" && cat $f && echo "::endgroup::" ; done; fi || echo "Failed to display the 'out' files."
if compgen -G './logs-${{ matrix.mapdl-version }}/*.log' > /dev/null ;then for f in ./logs-${{ matrix.mapdl-version }}/*.log; do echo "::group:: Log file $f" && cat $f && echo "::endgroup::" ; done; fi || echo "Failed to display the 'err' files."
if compgen -G './logs-${{ matrix.mapdl-version }}/*.out' > /dev/null ;then for f in ./logs-${{ matrix.mapdl-version }}/*.out; do echo "::group:: Output file $f" && cat $f && echo "::endgroup::" ; done; fi || echo "Failed to display the 'log' files."

.ci/display_logs.sh

build-test-ubuntu:
name: "Local: Build & test on Ubuntu MAPDL ${{ matrix.mapdl-image }} (Extended testing ${{ matrix.extended_testing }})"
Expand Down Expand Up @@ -882,18 +790,6 @@ jobs:
twine upload --skip-existing ./**/*.whl
twine upload --skip-existing ./**/*.tar.gz

- name: "Notify if fail"
uses: skitionek/notify-microsoft-teams@master
if: ${{ failure() }}
with:
webhook_url: ${{ secrets.TEAM_HOOK }}
needs: ${{ toJson(needs) }}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
overwrite: "{
title: `Release FAILED!`,
}"


upload-docs-release:
name: "Upload release documentation"
Expand All @@ -906,7 +802,6 @@ jobs:
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
render-last: '5'


Expand Down
Loading