CI #1599
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
workflow_dispatch: | |
schedule: # UTC at 0300 | |
- cron: "0 3 * * *" | |
pull_request: | |
push: | |
tags: | |
- "*" | |
branches: | |
- main | |
env: | |
DPF_PORT: 21002 | |
DPF_START_SERVER: False | |
MAIN_PYTHON_VERSION: '3.10' | |
MAPDL_PACKAGE: ghcr.io/ansys/mapdl | |
MAPDL_IMAGE_VERSION_DOCS_BUILD: v24.1-ubuntu-student | |
ON_CI: True | |
PYANSYS_OFF_SCREEN: True | |
RESET_EXAMPLES_CACHE: 1 | |
RESET_DOC_BUILD_CACHE: 1 | |
USE_CACHE: False | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
pull-requests: write | |
packages: read | |
jobs: | |
style: | |
name: Code style | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip tox | |
- name: Test with tox | |
run: tox -e style | |
doc-style: | |
name: Documentation Style Check | |
runs-on: ubuntu-latest | |
steps: | |
# TODO - Fix codestyle issues | |
# - name: PyAnsys documentation style checks | |
# uses: ansys/actions/doc-style@v4 | |
# with: | |
# token: ${{ secrets.GITHUB_TOKEN }} | |
# vale-version: "2.29.6" | |
- name : TODO - Reactivate code style | |
run : sleep 1 | |
doc-build: | |
name: "Documentation building" | |
needs: [style, doc-style] | |
timeout-minutes: 60 | |
outputs: | |
PYMAPDL_VERSION: ${{ steps.version.outputs.PYMAPDL_VERSION }} | |
runs-on: ubuntu-latest | |
env: | |
PYMAPDL_PORT: 21000 # default won't work on GitHub runners | |
PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners | |
PYMAPDL_START_INSTANCE: FALSE | |
ON_DOCUMENTATION: TRUE | |
steps: | |
- 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: | | |
export INSTANCE_NAME=MAPDL_0 | |
.ci/start_mapdl.sh & 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: "Install OS packages" | |
run: | | |
sudo apt-get update | |
sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex libgomp1 | |
- name: "Set up Python using cache" | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
cache: 'pip' | |
cache-dependency-path: 'requirements/requirements_doc.txt' | |
- name: "Install Python requirements" | |
run: | | |
pip uninstall ansys-mapdl-core | |
pip install -r requirements/requirements_doc.txt | |
- name: "Test virtual framebuffer" | |
run: | | |
xvfb-run python .ci/display_test.py | |
- name: "Retrieve PyMAPDL version" | |
id: version | |
run: | | |
echo "PYMAPDL_VERSION=$(python -c 'from ansys.mapdl.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT | |
echo "PyMAPDL version is: $(python -c "from ansys.mapdl.core import __version__; print(__version__)")" | |
- name: "Cache Verification Manual examples" | |
uses: actions/cache@v4 | |
if: env.USE_CACHE == true | |
with: | |
path: doc/source/verif-manual | |
key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} | |
restore-keys: | | |
Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} | |
- name: "Cache docs build directory" | |
uses: actions/cache@v4 | |
if: env.USE_CACHE == true | |
with: | |
path: doc/_build | |
key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.PYMAPDL_VERSION }}-${{ github.sha }} | |
restore-keys: | | |
doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.PYMAPDL_VERSION }} | |
- name: "Waiting for the services to be up" | |
timeout-minutes: 15 | |
run: | | |
.ci/waiting_services.sh | |
- name: "Run Ansys documentation building action" | |
uses: ansys/actions/doc-build@v6 | |
with: | |
requires-xvfb: true | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
checkout: false | |
skip-install: true | |
sphinxopts: -j auto -W --keep-going | |
use-python-cache: False | |
check-links: False | |
- name: "Deploy" | |
if: contains(github.ref, 'refs/heads/main') | |
uses: JamesIves/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: gh-pages | |
folder: doc/_build/html | |
clean: true | |
single-commit: true | |
- name: "Display Docker files structures" | |
if: always() | |
env: | |
MAPDL_INSTANCE: MAPDL_0 | |
LOG_NAMES: logs-build-docs | |
run: | | |
.ci/display_logs.sh | |
- name: "Collect MAPDL logs on failure" | |
if: always() | |
env: | |
MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} | |
MAPDL_INSTANCE: MAPDL_0 | |
LOG_NAMES: logs-build-docs | |
run: | | |
.ci/collect_mapdl_logs.sh | |
- name: "Tar logs" | |
if: always() | |
run: | | |
cp -f doc/_build/latex/*.log ./logs-build-docs/ | |
cp log.txt ./logs-build-docs/ | |
tar cvzf ./logs-build-docs.tgz ./logs-build-docs | |
- name: "Upload logs to GitHub" | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logs-build-docs.tgz | |
path: ./logs-build-docs.tgz | |
- name: "Display MAPDL Logs" | |
if: always() | |
run: cat log.txt | |
- name: "List main files" | |
if: always() | |
run: | | |
if compgen -G 'doc/_build/latex/*.log' > /dev/null ;then for f in doc/_build/latex/*.log; do echo "::group:: Output latex log file $f" && cat $f && echo "::endgroup::" ; done; fi | |
if compgen -G './logs-build-docs/*.err' > /dev/null ;then for f in ./logs-build-docs/*.err; do echo "::group:: Error file $f" && cat $f && echo "::endgroup::" ; done; fi | |
if compgen -G './logs-build-docs/*.log' > /dev/null ;then for f in ./logs-build-docs/*.log; do echo "::group:: Log file $f" && cat $f && echo "::endgroup::" ; done; fi | |
if compgen -G './logs-build-docs/*.out' > /dev/null ;then for f in ./logs-build-docs/*.out; do echo "::group:: Output file $f" && cat $f && echo "::endgroup::" ; done; fi | |
release: | |
if: github.event_name == 'refs/heads/main' && !contains(github.ref, 'refs/tags') | |
needs: [style, doc-build] #docs-style | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Zip HTML documentation | |
uses: vimtor/[email protected] | |
with: | |
files: documentation-html | |
dest: documentation-html.zip | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
generate_release_notes: true | |
files: | | |
./documentation-html.zip | |
./documentation-pdf/*.pdf |