-
-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (123 loc) · 5.37 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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*
- 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