-
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (172 loc) · 8.3 KB
/
Copy pathworkflow_call.yml
File metadata and controls
174 lines (172 loc) · 8.3 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Run image cache tests
on:
workflow_call:
inputs:
notebook_repository:
description: "Repository with the notebooks to be processed"
type: string
notebook_branch:
description: "Branch of the repository with the notebooks to be processed"
type: string
image_cache_branch:
description: "Branch of the repository with the image cache"
type: string
notebook_preparation:
description: "Script to be run before processing notebooks"
type: string
notebook_directory:
description: "Directory with the notebooks to be processed"
type: string
secrets:
REPO_ACCESS_TOKEN:
description: "Token that enables writing to the notebook repository"
jobs:
run:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- backend: dolfinx-nightly-real
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
petsc_arch: real
- backend: dolfinx-nightly-complex
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
petsc_arch: complex
- backend: firedrake-dev-main-real
container: firedrakeproject/firedrake-vanilla-default:dev-main
petsc_arch: real
- backend: firedrake-dev-main-complex
container: firedrakeproject/firedrake-vanilla-complex:dev-main
petsc_arch: complex
fail-fast: false
container:
image: ${{ matrix.container }}
options: --shm-size=1g
steps:
- name: Install git
run: |
export DEBIAN_FRONTEND="noninteractive"
apt update -y -q
apt install -y -qq ca-certificates git
- name: Determine which branch to use while cloning the image cache tester library
id: image_cache_tester_library_branch
run: |
if [[ "${{ github.repository }}" == "viskex/image_cache_tester" ]]; then
BRANCH=${GITHUB_REF#refs/heads/}
else
BRANCH="main"
fi
echo "branch=${BRANCH}" >> ${GITHUB_OUTPUT}
shell: bash
- name: Clone image cache tester library
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: viskex/image_cache_tester
ref: ${{ steps.image_cache_tester_library_branch.outputs.branch }}
path: _image_cache_tester_library
- name: Setup container
run: |
export DEBIAN_FRONTEND="noninteractive"
apt update -y -q
apt install -y -qq libegl1 libgl1-mesa-dri
if [[ "${{ matrix.backend }}" == "dolfinx"* ]]; then
. /usr/local/bin/dolfinx-${{ matrix.petsc_arch }}-mode
echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
elif [[ "${{ matrix.backend }}" == "firedrake"* ]]; then
rm /usr/lib/python3.*/EXTERNALLY-MANAGED
else
echo "Invalid backend"
exit 1
fi
shell: bash
- name: Install the image cache tester library
run: |
pushd _image_cache_tester_library
python3 -m pip install .[tests]
popd
rm -rf _image_cache_tester_library
shell: bash
- name: Clone notebook repository on notebook branch
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: "${{ inputs.notebook_repository }}"
ref: "${{ inputs.notebook_branch }}"
path: "_notebook_repository"
- name: Mark clone of the notebook repository on image cache branch as safe
run: |
git config --global --add safe.directory _notebook_repository/${{ inputs.notebook_directory }}/.image_cache
- name: Clone notebook repository on image cache branch
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: "${{ inputs.notebook_repository }}"
token: "${{ secrets.REPO_ACCESS_TOKEN || github.token }}"
ref: "${{ inputs.image_cache_branch }}"
fetch-depth: 0
path: "_notebook_repository/${{ inputs.notebook_directory }}/.image_cache"
set-safe-directory: false
- name: Run notebook preparation
run: |
${{ inputs.notebook_preparation }}
working-directory: _notebook_repository
- name: Replace nbvalx in notebooks conftest.py
run: |
sed -i 's|nbvalx.pytest_hooks_notebooks|image_cache_tester.pytest_hooks_notebooks|g' ${{ inputs.notebook_directory }}/conftest.py
working-directory: _notebook_repository
- name: Create symbolic links to image cache in subdirectories
run: |
find . -mindepth 1 -mindepth 1 -type d -not -path '*/\.*' -exec bash -c "mkdir -p .image_cache/{} && ln -s ../.image_cache/{} {}/.image_cache" \;
working-directory: _notebook_repository/${{ inputs.notebook_directory }}
- name: Verify images in notebooks (serial, static pyvista backend)
id: verify_images_serial_static
run: |
VISKEX_PYVISTA_BACKEND="static" python3 -m pytest --nbval-cell-timeout=60 --verify-images --refresh-image-cache ${{ inputs.notebook_directory }}
working-directory: _notebook_repository
- name: Verify images in notebooks (serial, html pyvista backend)
id: verify_images_serial_html
if: success() || (failure() && steps.verify_images_serial_static.outcome == 'failure')
run: |
VISKEX_PYVISTA_BACKEND="html" python3 -m pytest --nbval-cell-timeout=60 --verify-images --refresh-image-cache ${{ inputs.notebook_directory }}
working-directory: _notebook_repository
- name: Verify images in notebooks (parallel, static pyvista backend)
id: verify_images_parallel_static
if: success() || (failure() && (steps.verify_images_serial_static.outcome == 'failure' || steps.verify_images_serial_html.outcome == 'failure'))
run: |
VISKEX_PYVISTA_BACKEND="static" python3 -m pytest --nbval-cell-timeout=60 --verify-images --refresh-image-cache --np=2 ${{ inputs.notebook_directory }}
working-directory: _notebook_repository
- name: Verify images in notebooks (parallel, html pyvista backend)
id: verify_images_parallel_html
if: success() || (failure() && (steps.verify_images_serial_static.outcome == 'failure' || steps.verify_images_serial_html.outcome == 'failure' || steps.verify_images_parallel_static.outcome == 'failure'))
run: |
VISKEX_PYVISTA_BACKEND="html" python3 -m pytest --nbval-cell-timeout=60 --verify-images --refresh-image-cache --np=2 ${{ inputs.notebook_directory }}
working-directory: _notebook_repository
- name: Upload notebooks logs as an artifact in case of failure
if: failure() || cancelled()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: "image-cache-test-logs-${{ matrix.backend }}"
path: |
_notebook_repository/**/.ipynb_pytest/**/*.log*
include-hidden-files: true
- name: Refresh image cache
if: failure() && (steps.verify_images_serial_static.outcome == 'failure' || steps.verify_images_serial_html.outcome == 'failure' || steps.verify_images_parallel_static.outcome == 'failure' || steps.verify_images_parallel_html.outcome == 'failure')
run: |
DATETIME=$(date '+%Y%m%d-%H%M%S')
pushd _notebook_repository
SHA_SHORT=$(git rev-parse --short HEAD)
popd
pushd _notebook_repository/${{ inputs.notebook_directory }}/.image_cache
BRANCH="${{ inputs.image_cache_branch }}-update-${SHA_SHORT}-${{ matrix.backend }}-${DATETIME}"
git checkout -b ${BRANCH}
git add .
if [[ "$(git diff --name-only --cached | wc -l)" -gt 0 ]]; then
git config user.name "GitHub Actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "Refresh image cache at ${SHA_SHORT} for ${{ matrix.backend }}"
git push origin ${BRANCH}
fi
popd
shell: bash