Skip to content

Commit 96734a2

Browse files
Merge pull request #2861 from devitocodes/JDBetteridge/unique_ci_docker_tag
ci: Add UID to the dockertag
2 parents 04373ef + 5e1ab47 commit 96734a2

5 files changed

Lines changed: 153 additions & 23 deletions

File tree

.github/workflows/pytest-core-mpi.yaml

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
test-mpi-docker:
6666
name: pytest-mpi
6767
runs-on: ${{ matrix.os }}
68+
outputs:
69+
unique : ${{ steps.uniquetag.outputs.unique }}
6870
strategy:
6971
matrix:
7072
name: [gcc, gcc-arm, icx]
@@ -89,15 +91,58 @@ jobs:
8991
- name: Checkout devito
9092
uses: actions/checkout@v6
9193

94+
- name: Generate unique CI tag
95+
id: uniquetag
96+
run: |
97+
UNIQUE=$(echo "${GITHUB_RUN_ID}_${GITHUB_RUN_ATTEMPT}" | cksum | cut -f 1 -d " ")
98+
echo "Unique ID: ${UNIQUE}"
99+
echo "unique=${UNIQUE}" >> "$GITHUB_OUTPUT"
100+
92101
- name: Build docker image
102+
env:
103+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
93104
run: |
94-
docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }}
105+
docker build \
106+
--file docker/Dockerfile.devito \
107+
--tag "devito_img${UNIQUE}" \
108+
--build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} \
109+
.
95110
96111
- name: Test with pytest
112+
env:
113+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
97114
run: |
98-
docker run --init -t --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e OMP_NUM_THREADS=1 --name testrun devito_img pytest tests/test_mpi.py
115+
docker run \
116+
--init -t --rm \
117+
--env CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} \
118+
--env OMP_NUM_THREADS=1 \
119+
--name testrun \
120+
"devito_img${UNIQUE}" \
121+
pytest tests/test_mpi.py
99122
100123
- name: Test examples with MPI
124+
env:
125+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
126+
run: |
127+
docker run \
128+
--init -t --rm \
129+
${{ matrix.mpiflag }} \
130+
--env DEVITO_MPI=1 \
131+
--env OMP_NUM_THREADS=1 \
132+
--name examplerun \
133+
"devito_img${UNIQUE}" \
134+
mpiexec -n 2 pytest examples/seismic/acoustic
135+
#
136+
docker run \
137+
--init -t --rm \
138+
--env DEVITO_MPI=1 \
139+
--env OMP_NUM_THREADS=1 \
140+
--name examplerun \
141+
"devito_img${UNIQUE}" \
142+
mpiexec -n 2 pytest examples/seismic/tti
143+
144+
- name: Cleanup
145+
env:
146+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
101147
run: |
102-
docker run --init -t --rm ${{ matrix.mpiflag }} -e DEVITO_MPI=1 -e OMP_NUM_THREADS=1 --name examplerun devito_img mpiexec -n 2 pytest examples/seismic/acoustic
103-
docker run --init -t --rm -e DEVITO_MPI=1 -e OMP_NUM_THREADS=1 --name examplerun devito_img mpiexec -n 2 pytest examples/seismic/tti
148+
docker image rm -f "devito_img${UNIQUE}"

.github/workflows/pytest-core-nompi.yaml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
DEVITO_LANGUAGE: ${{ matrix.language }}
2828
OMP_NUM_THREADS: 2
2929

30+
outputs:
31+
unique : ${{ steps.uniquetag.outputs.unique }}
32+
3033
strategy:
3134
# Prevent all build to stop if a single one fails
3235
fail-fast: false
@@ -146,15 +149,34 @@ jobs:
146149
python-version: ${{ matrix.python-version }}
147150
allow-prereleases: true
148151

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+
149159
- name: Build docker image
150160
if: contains(matrix.name, 'docker')
161+
env:
162+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
151163
run: |
152-
docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }}
164+
docker build \
165+
--file docker/Dockerfile.devito \
166+
--tag "devito_img${UNIQUE}" \
167+
--build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} \
168+
.
153169
154170
- name: Set run prefix
171+
env:
172+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
155173
run: |
156174
if [[ "${{ matrix.name }}" =~ "docker" ]]; then
157-
echo "RUN_CMD=docker run --init -t --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun devito_img" >> "$GITHUB_ENV"
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"
158180
else
159181
echo "RUN_CMD=" >> "$GITHUB_ENV"
160182
fi
@@ -207,15 +229,30 @@ jobs:
207229
208230
- name: Check configuration
209231
run: |
210-
${{ env.RUN_CMD }} python3 -c "from devito import configuration; print(''.join(['%s: %s \n' % (k, v) for (k, v) in configuration.items()]))"
232+
${{ env.RUN_CMD }} python3 \
233+
-c "from devito import configuration; \
234+
print(''.join(['%s: %s \n' % (k, v) for (k, v) in configuration.items()]))"
211235
212236
- name: Test with pytest
213237
run: |
214-
${{ env.RUN_CMD }} pytest -k "${{ matrix.test-set }}" -m "not parallel" --cov --cov-config=.coveragerc --cov-report=xml tests/
238+
${{ env.RUN_CMD }} pytest \
239+
-k "${{ matrix.test-set }}" \
240+
-m "not parallel" \
241+
--cov \
242+
--cov-config=.coveragerc \
243+
--cov-report=xml \
244+
tests/
215245
216246
- name: Upload coverage to Codecov
217247
if: "!contains(matrix.name, 'docker')"
218248
uses: codecov/codecov-action@v5
219249
with:
220250
token: ${{ secrets.CODECOV_TOKEN }}
221251
name: ${{ matrix.name }}
252+
253+
- name: Cleanup Docker
254+
if: "contains(matrix.name, 'docker')"
255+
env:
256+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
257+
run: |
258+
docker image rm -f "devito_img${UNIQUE}"

.github/workflows/pytest-gpu.yaml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- self-hosted
3838
- ${{ matrix.runner_label }}
3939

40+
outputs:
41+
unique : ${{ steps.uniquetag.outputs.unique }}
42+
4043
strategy:
4144
fail-fast: false
4245
matrix:
@@ -52,7 +55,7 @@ jobs:
5255
test_drive_cmd: "nvidia-smi"
5356
# Respect CUDA_VISIBLE_DEVICES and also hard-limit Docker to that device.
5457
# NOTE: CUDA_VISIBLE_DEVICES must be set by the runner (systemd drop-in etc.).
55-
flags: >-
58+
dockerflags: >-
5659
--init --rm -t
5760
--name ${CONTAINER_BASENAME}
5861
--gpus "device=${CUDA_VISIBLE_DEVICES:-all}"
@@ -64,7 +67,7 @@ jobs:
6467
base: "devitocodes/bases:amd"
6568
test_drive_cmd: "rocm-smi"
6669
# Unchanged, still passes through required /dev nodes etc.
67-
flags: >-
70+
dockerflags: >-
6871
--init --network=host
6972
--device=/dev/kfd --device=/dev/dri
7073
--ipc=host
@@ -77,9 +80,18 @@ jobs:
7780
- name: Checkout devito
7881
uses: actions/checkout@v6
7982

83+
- name: Generate unique CI tag
84+
id: uniquetag
85+
run: |
86+
UNIQUE=$(echo "${GITHUB_RUN_ID}_${GITHUB_RUN_ATTEMPT}" | cksum | cut -f 1 -d " ")
87+
echo "Unique ID: ${UNIQUE}"
88+
echo "unique=${UNIQUE}" >> "$GITHUB_OUTPUT"
89+
8090
- name: Set per-runner tags
91+
env:
92+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
8193
run: |
82-
echo "DOCKER_IMAGE=${{ matrix.name }}-${RUNNER_NAME// /_}" >> "$GITHUB_ENV"
94+
echo "DOCKER_IMAGE=${{ matrix.name }}-${RUNNER_NAME// /_}-${UNIQUE}" >> "$GITHUB_ENV"
8395
echo "CONTAINER_BASENAME=testrun-${{ matrix.name }}-${RUNNER_NAME// /_}-${{ github.sha }}" >> "$GITHUB_ENV"
8496
8597
- name: Ensure buildx builder
@@ -112,7 +124,7 @@ jobs:
112124
113125
# Run a simple driver-probe command (nvidia-smi / rocm-smi)
114126
docker rm -f "${CONTAINER_BASENAME}" 2>/dev/null || true
115-
docker run ${{ matrix.flags }} "${DOCKER_IMAGE}" ${{ matrix.test_drive_cmd }}
127+
docker run ${{ matrix.dockerflags }} "${DOCKER_IMAGE}" ${{ matrix.test_drive_cmd }}
116128
117129
- name: Test with pytest
118130
env:
@@ -123,12 +135,13 @@ jobs:
123135
ci_env=$(bash <(curl -s https://codecov.io/env))
124136
125137
# Run the test suite using the matrix-defined flags
126-
docker run ${{ matrix.flags }} \
138+
docker run \
139+
${{ matrix.dockerflags }} \
127140
"${ci_env}" \
128-
-e CI=true \
129-
-e PYTHONFAULTHANDLER=1 \
130-
-e DEVITO_LOGGING=DEBUG \
131-
-e CODECOV_TOKEN \
141+
--env CI=true \
142+
--env PYTHONFAULTHANDLER=1 \
143+
--env DEVITO_LOGGING=DEBUG \
144+
--env CODECOV_TOKEN \
132145
"${DOCKER_IMAGE}" \
133146
pytest -vvv --capture=no --showlocals \
134147
--log-cli-level=DEBUG -o log_cli=true \
@@ -138,11 +151,17 @@ jobs:
138151
139152
- name: Test examples
140153
run: |
141-
docker run ${{ matrix.flags }} "${DOCKER_IMAGE}" pytest ${{ matrix.test_examples }}
154+
docker run \
155+
${{ matrix.dockerflags }} \
156+
"${DOCKER_IMAGE}" \
157+
pytest ${{ matrix.test_examples }}
142158
143159
- name: Test examples with MPI
144160
run: |
145-
docker run ${{ matrix.flags }} --env DEVITO_MPI=1 "${DOCKER_IMAGE}" \
161+
docker run \
162+
${{ matrix.dockerflags }} \
163+
--env DEVITO_MPI=1 \
164+
"${DOCKER_IMAGE}" \
146165
mpiexec -n 2 pytest ${{ matrix.test_examples }}
147166
148167
- name: Builder & image cleanup (keep 3 days of cache)

.github/workflows/tutorials.yaml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
DEVITO_ARCH: "${{ matrix.compiler }}"
2727
DEVITO_LANGUAGE: ${{ matrix.language }}
2828

29+
outputs:
30+
unique : ${{ steps.uniquetag.outputs.unique }}
31+
2932
strategy:
3033
# Prevent all build to stop if a single one fails
3134
fail-fast: false
@@ -59,6 +62,13 @@ jobs:
5962
- name: Checkout devito
6063
uses: actions/checkout@v6
6164

65+
- name: Generate unique CI tag
66+
id: uniquetag
67+
run: |
68+
UNIQUE=$(echo "${GITHUB_RUN_ID}_${GITHUB_RUN_ATTEMPT}" | cksum | cut -f 1 -d " ")
69+
echo "Unique ID: ${UNIQUE}"
70+
echo "unique=${UNIQUE}" >> "$GITHUB_OUTPUT"
71+
6272
- name: Set up Python ${{ matrix.pyver }}
6373
if: "!contains(matrix.name, 'docker')"
6474
uses: actions/setup-python@v6
@@ -72,15 +82,26 @@ jobs:
7282

7383
- name: Build docker image
7484
if: "contains(matrix.name, 'docker')"
85+
env:
86+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
7587
run: |
76-
docker build . --pull --file docker/Dockerfile.devito --tag devito_img
88+
docker build \
89+
--pull \
90+
--file docker/Dockerfile.devito \
91+
--tag "devito_img${UNIQUE}" \
92+
.
7793
7894
- name: Set run prefix
95+
env:
96+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
7997
run: |
8098
if [ "${{ matrix.name }}" == 'tutos-docker-gcc-py310' ]; then
81-
echo "RUN_CMD=docker run --init -t --rm --name testrun devito_img" >> "$GITHUB_ENV"
99+
echo "RUN_CMD=docker run \
100+
--init -t --rm \
101+
--name testrun \
102+
devito_img${UNIQUE}" >> "$GITHUB_ENV"
82103
else
83-
echo "RUN_CMD=" >> "$GITHUB_ENV"
104+
echo "RUN_CMD=" >> "$GITHUB_ENV"
84105
fi
85106
id: set-run
86107

@@ -116,7 +137,7 @@ jobs:
116137
- name: Dask notebooks
117138
if: runner.os != 'macOS'
118139
run: |
119-
${{ env.RUN_CMD }} py.test --nbval examples/seismic/tutorials/*dask*.ipynb
140+
${{ env.RUN_CMD }} py.test --nbval examples/seismic/tutorials/*dask*.ipynb
120141
121142
- name: Self-adjoint notebooks
122143
run: |
@@ -149,3 +170,10 @@ jobs:
149170
- name: Timestepping Notebooks
150171
run: |
151172
${{ env.RUN_CMD }} py.test --nbval examples/timestepping
173+
174+
- name: Cleanup Docker
175+
if: "contains(matrix.name, 'docker')"
176+
env:
177+
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
178+
run: |
179+
docker image rm -f "devito_img${UNIQUE}"

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ repos:
3939
rev: v1.7.8
4040
hooks:
4141
- id: actionlint-docker
42+
args: [-oneline]
4243
- repo: https://github.com/hadolint/hadolint
4344
rev: v2.12.0
4445
hooks:

0 commit comments

Comments
 (0)