2727 DEVITO_LANGUAGE : ${{ matrix.language }}
2828 OMP_NUM_THREADS : 2
2929
30- outputs :
31- unique : ${{ steps.uniquetag.outputs.unique }}
32-
3330 strategy :
3431 # Prevent all build to stop if a single one fails
3532 fail-fast : false
@@ -139,55 +136,25 @@ jobs:
139136 set : adjoint
140137
141138 steps :
139+ # TODO: This workflow should really be split into 2 (Docker and non-Docker)
142140 - name : Checkout devito
143141 uses : actions/checkout@v6
144142
143+ # Bare metal (not Docker)
145144 - name : Set up Python ${{ matrix.python-version }}
146145 if : " !contains(matrix.name, 'docker')"
147146 uses : actions/setup-python@v6
148147 with :
149148 python-version : ${{ matrix.python-version }}
150149 allow-prereleases : true
151150
152- - name : Generate unique CI tag
153- id : uniquetag
154- run : |
155- UNIQUE=$(echo "${GITHUB_RUN_ID}_${GITHUB_RUN_ATTEMPT}" | cksum | cut -f 1 -d " ")
156- echo "Unique ID: ${UNIQUE}"
157- echo "unique=${UNIQUE}" >> "$GITHUB_OUTPUT"
158-
159- - name : Build docker image
160- if : contains(matrix.name, 'docker')
161- env :
162- UNIQUE : ${{ steps.uniquetag.outputs.unique }}
163- run : |
164- docker build \
165- --file docker/Dockerfile.devito \
166- --tag "devito_img${UNIQUE}" \
167- --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} \
168- .
169-
170- - name : Set run prefix
171- env :
172- UNIQUE : ${{ steps.uniquetag.outputs.unique }}
173- run : |
174- if [[ "${{ matrix.name }}" =~ "docker" ]]; then
175- echo "RUN_CMD=docker run \
176- --init -t --rm \
177- --env CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} \
178- --name testrun \
179- devito_img${UNIQUE}" >> "$GITHUB_ENV"
180- else
181- echo "RUN_CMD=" >> "$GITHUB_ENV"
182- fi
183- id : set-run
184-
185151 - name : Install ${{ matrix.arch }} compiler
186152 if : " runner.os == 'linux' && !contains(matrix.name, 'docker') && matrix.arch !='custom' "
187153 run : |
188154 sudo apt-get install -y ${{ matrix.arch }}
189155
190156 - name : Set tests (reduced number for OSX)
157+ if : " !contains(matrix.name, 'docker')"
191158 run : |
192159 if [ "${{ runner.os }}" == 'macOS' ]; then
193160 brew install llvm libomp
@@ -196,6 +163,7 @@ jobs:
196163 id : set-tests
197164
198165 - name : Set pip flags for latest python (3.12)
166+ if : " !contains(matrix.name, 'docker')"
199167 run : |
200168 ver="${{ matrix.python-version }}"
201169 major=${ver%%.*}
@@ -215,27 +183,17 @@ jobs:
215183 if : matrix.name == 'pytest-ubuntu-py310-gcc14-omp'
216184 run : python3 -m pip install ${{ env.PIPFLAGS }} numpy==1.26
217185
218- - name : Check Docker image Python version
219- if : " contains(matrix.name, 'docker')"
220- run : |
221- declared_pyver="${{ matrix.python-version }}"
222- actual_pyver=$(${{ env.RUN_CMD }} python3 --version | grep "Python " | cut -d' ' -f2 | cut -d'.' -f1,2)
223- echo "Declared Python version: $declared_pyver"
224- echo "Actual Python version: $actual_pyver"
225- if [ "$declared_pyver" != "$actual_pyver" ]; then
226- echo "Python version mismatch: declared $declared_pyver, image has $actual_pyver"
227- exit 1
228- fi
229-
230186 - name : Check configuration
187+ if : " !contains(matrix.name, 'docker')"
231188 run : |
232- ${{ env.RUN_CMD }} python3 \
189+ python3 \
233190 -c "from devito import configuration; \
234191 print(''.join(['%s: %s \n' % (k, v) for (k, v) in configuration.items()]))"
235192
236193 - name : Test with pytest
194+ if : " !contains(matrix.name, 'docker')"
237195 run : |
238- ${{ env.RUN_CMD }} pytest \
196+ pytest \
239197 -k "${{ matrix.test-set }}" \
240198 -m "not parallel" \
241199 --cov \
@@ -250,9 +208,57 @@ jobs:
250208 token : ${{ secrets.CODECOV_TOKEN }}
251209 name : ${{ matrix.name }}
252210
253- - name : Cleanup Docker
211+ # Docker
212+ - id : build
213+ name : Build docker image
214+ if : contains(matrix.name, 'docker')
215+ uses : ./.github/actions/docker-build
216+ with :
217+ file : docker/Dockerfile.devito
218+ tag : devito_img
219+ base : devitocodes/bases:cpu-${{ matrix.arch }}
220+
221+ - name : Get the Docker image Python version
222+ if : " contains(matrix.name, 'docker')"
223+ uses : ./.github/actions/docker-run
224+ with :
225+ uid : ${{ steps.build.outputs.unique }}
226+ tag : devito_img
227+ command : >
228+ python3 --version | grep "Python " | cut -d' ' -f2 | cut -d'.' -f1,2 > dockerpythonversion.txt
229+
230+ - name : Check Docker image Python version
254231 if : " contains(matrix.name, 'docker')"
255- env :
256- UNIQUE : ${{ steps.uniquetag.outputs.unique }}
257232 run : |
258- docker image rm -f "devito_img${UNIQUE}"
233+ declared_pyver="${{ matrix.python-version }}"
234+ actual_pyver=$(cat dockerpythonversion.txt)
235+ echo "Declared Python version: $declared_pyver"
236+ echo "Actual Python version: $actual_pyver"
237+ if [ "$declared_pyver" != "$actual_pyver" ]; then
238+ echo "Python version mismatch: declared $declared_pyver, image has $actual_pyver"
239+ exit 1
240+ fi
241+
242+ - name : Test with pytest
243+ if : " contains(matrix.name, 'docker')"
244+ uses : ./.github/actions/docker-run
245+ with :
246+ uid : ${{ steps.build.outputs.unique }}
247+ env : |
248+ CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }}
249+ tag : devito_img
250+ command : |
251+ pytest \
252+ -k "${{ matrix.test-set }}" \
253+ -m "not parallel" \
254+ --cov \
255+ --cov-config=.coveragerc \
256+ --cov-report=xml \
257+ tests/
258+
259+ - name : Cleanup docker image
260+ if : always()
261+ uses : ./.github/actions/docker-clean
262+ with :
263+ uid : ${{ steps.build.outputs.unique }}
264+ tag : devito_img
0 commit comments