Skip to content

Commit 7f7456c

Browse files
committed
More debugging belt and braces
1 parent 1ca43b5 commit 7f7456c

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

.github/workflows/pytest-gpu.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ jobs:
8787
8888
- name: Build docker image
8989
run: |
90+
docker buildx create --use --name $RUNNER_NAME || true
9091
docker build . \
92+
--builder $RUNNER_NAME \
93+
--label ci-run=$GITHUB_RUN_ID \
9194
--rm --pull \
9295
--file docker/Dockerfile.devito \
9396
--tag "${DOCKER_IMAGE}" \
@@ -102,19 +105,40 @@ jobs:
102105
docker run ${{ matrix.flags }} "${DOCKER_IMAGE}" ${{ matrix.test_drive_cmd }}
103106
104107
- name: Test with pytest
108+
env:
109+
# Exported earlier in the job; needed inside the container for codecov
110+
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
105111
run: |
112+
# ------------------------------------------------------------------
113+
# 1. Add Codecov’s environment variables (GITHUB_SHA, etc.)
114+
# ------------------------------------------------------------------
106115
ci_env=$(bash <(curl -s https://codecov.io/env))
107116
108-
# docker run ${{ matrix.flags }} $ci_env -e CI=true "${DOCKER_IMAGE}" \
109-
docker run ${{ matrix.flags }} $ci_env -e CI=true \
117+
# ------------------------------------------------------------------
118+
# 2. Make sure the runner really gave us a GPU mask
119+
# ------------------------------------------------------------------
120+
: "${CUDA_VISIBLE_DEVICES:?CUDA_VISIBLE_DEVICES not set}"
121+
122+
# ------------------------------------------------------------------
123+
# 3. Run the test suite inside the image we just built
124+
# ------------------------------------------------------------------
125+
docker run \
126+
--init --rm -t \
127+
--name "${CONTAINER_BASENAME}" \
128+
--env CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES}" \
129+
--gpus "device=${CUDA_VISIBLE_DEVICES}" \
130+
${ci_env} \
131+
-e CI=true \
110132
-e PYTHONFAULTHANDLER=1 \
111133
-e CUDA_LAUNCH_BLOCKING=1 \
112134
-e NV_ACC_NOTIFY=3 \
113135
-e NV_ACC_DEBUG=1 \
114136
-e DEVITO_LOGGING=DEBUG \
137+
-e CODECOV_TOKEN \
115138
"${DOCKER_IMAGE}" \
116139
pytest -vv -ra -l -s --full-trace --maxfail=1 \
117-
--cov --cov-config=.coveragerc --cov-report=xml ${{ matrix.test_files }}
140+
--cov --cov-config=.coveragerc --cov-report=xml \
141+
${{ matrix.test_files }}
118142
119143
- name: Test examples
120144
run: |
@@ -128,6 +152,9 @@ jobs:
128152
- name: Clean up test image
129153
if: always()
130154
run: |
131-
docker rmi -f "${DOCKER_IMAGE}" || true # remove the image
132-
docker system prune -f # free dangling layers
155+
# Remove only the image we just built
156+
docker rmi -f "${DOCKER_IMAGE}" || true
133157
158+
# Guard global prune the layers we created
159+
# (label ci-run=$GITHUB_RUN_ID)
160+
docker image prune -f --filter label=ci-run=$GITHUB_RUN_ID

0 commit comments

Comments
 (0)