Skip to content

CI

CI #119

Workflow file for this run

name: CI
on:
push:
branches:
- "**"
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * MON"
workflow_dispatch:
jobs:
test_library:
runs-on: ubuntu-latest
container: debian:testing
steps:
- name: Install git
run: |
apt update -y -q
apt install -y -qq git
- name: Mark workspace as safe
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- uses: actions/checkout@v4
with:
set-safe-directory: false
- name: Install non-pip dependencies of the image cache tester library
run: |
export DEBIAN_FRONTEND="noninteractive"
apt install -y -qq python3-mpi4py python3-pip xvfb
rm /usr/lib/python3.*/EXTERNALLY-MANAGED
- name: Install the image cache tester library
run: |
python3 -m pip install .[docs,lint,tests]
- name: Clean build files
run: |
git clean -xdf
- name: Run ruff on python files
run: |
python3 -m ruff check .
- name: Run isort on python files
run: |
python3 -m isort --check --diff .
- name: Run mypy on python files
run: |
python3 -m mypy --exclude=conftest.py .
python3 -m mypy tests/notebooks/basic/conftest.py
python3 -m mypy tests/unit/conftest.py
- name: Run yamllint on workflows
run: |
python3 -m yamllint -d "{extends: default, rules: {document-start: {present: false}, line-length: disable, truthy: {check-keys: false}}}" .
- name: Run documentation generation
run: |
cd docs && python3 -m sphinx -W -b html . build/html
- name: Run unit tests
run: |
export DISPLAY=":99"
Xvfb $DISPLAY -screen 0 1024x768x24 > /dev/null 2>&1 &
COVERAGE_FILE=.coverage_unit python3 -m coverage run --source=image_cache_tester -m pytest tests/unit
- name: Run ruff on notebooks test files
run: |
python3 -m nbqa ruff .
- name: Run isort on notebooks test files
run: |
python3 -m nbqa isort --check --diff .
- name: Run mypy on notebooks test files
run: |
python3 -m nbqa mypy .
- name: Check for stray outputs, counts and metadata in ipynb files
uses: RBniCS/check-jupyter-metadata-action@main
with:
pattern: "**/*.ipynb"
- name: Run basic notebooks tests
run: |
export DISPLAY=":99"
Xvfb $DISPLAY -screen 0 1024x768x24 > /dev/null 2>&1 &
COVERAGE_FILE=.coverage_notebooks_basic python3 -m coverage run --source=image_cache_tester -m pytest --coverage-run-allow tests/notebooks/basic
- name: Upload notebooks logs as an artifact in case of failure
if: failure() || cancelled()
uses: actions/upload-artifact@v4
with:
name: "notebooks-logs"
path: |
tests/notebooks/**/.ipynb_pytest/**/*.log*
include-hidden-files: true
- name: Generate viskex notebooks tests
run: |
NO_TESTS_COLLECTED=5
COVERAGE_FILE=.coverage_notebooks_viskex_generation_serial python3 -m coverage run --source=image_cache_tester -m pytest --coverage-run-allow --verify-images --refresh-image-cache --ipynb-action=create-notebooks tests/notebooks/viskex || (($?==$NO_TESTS_COLLECTED))
COVERAGE_FILE=.coverage_notebooks_viskex_generation_parallel python3 -m coverage run --source=image_cache_tester -m pytest --coverage-run-allow --verify-images --refresh-image-cache --ipynb-action=create-notebooks --np=2 tests/notebooks/viskex || (($?==$NO_TESTS_COLLECTED))
shell: bash
- name: Run viskex notebooks tests to check that they are skipped because of missing backends
run: |
COVERAGE_FILE=.coverage_notebooks_viskex_run_serial python3 -m coverage run --source=image_cache_tester -m pytest --coverage-run-allow --verify-images --refresh-image-cache tests/notebooks/viskex
COVERAGE_FILE=.coverage_notebooks_viskex_run_parallel python3 -m coverage run --source=image_cache_tester -m pytest --coverage-run-allow --verify-images --refresh-image-cache --np=2 tests/notebooks/viskex
- name: Combine coverage reports
run: |
python3 -m coverage combine .coverage*
python3 -m coverage report --fail-under=100 --show-missing --skip-covered
test_workflow_call:
needs: [test_library]
uses: viskex/image_cache_tester/.github/workflows/workflow_call.yml@main
with:
notebook_repository: viskex/image_cache_tester
notebook_branch: ${{ github.ref }}
image_cache_branch: image-cache-viskex-tests
notebook_preparation: |
git clone https://github.com/viskex/viskex.git
cd viskex
TMP_DIR=$(mktemp -d)
rsync -arvz --include='*firedrake*' --include='*/' --exclude='*' ./ ${TMP_DIR}/
${DOCKER_SCRIPTS}/scripts/replace_ufl.sh ${TMP_DIR}
rsync -arvz ${TMP_DIR}/ ./
python3 -m pip install .[tests]
notebook_directory: tests/notebooks/viskex
warn:
runs-on: ubuntu-latest
if: github.repository == 'viskex/image_cache_tester' && github.ref == 'refs/heads/main' && github.event_name == 'schedule'
steps:
- name: Warn if scheduled workflow is about to be disabled
uses: fem-on-colab/warn-workflow-about-to-be-disabled-action@main
with:
workflow-filename: ci.yml
days-elapsed: 50