Skip to content

Commit 1efa212

Browse files
cknittclaude
andauthored
Build the dev container in CI only when its inputs change (#9298)
The test-devcontainer job built the container from scratch on every pull request, about 10 minutes. It now lists the pull request's files first and builds only when the container definition, the opam or yarn dependencies its setup installs, the Makefile or ci.yml change; pushes, and pull requests whose files can't be listed, still build it. The job always runs, so ci-ok still sees it succeed. Claude-Session: https://claude.ai/code/session_01Kbf3gKyiYMf54wPRxFdUWe Signed-off-by: Christoph Knittel <ck@cca.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9523348 commit 1efa212

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,31 @@ jobs:
665665
test-devcontainer:
666666
runs-on: ubuntu-26.04-arm
667667
steps:
668+
# Building the dev container takes about 10 minutes. On pull requests it
669+
# runs only when the container's inputs change: its definition, the opam
670+
# and yarn dependencies its setup installs, the Makefile, or this
671+
# workflow. If the changed files can't be listed, it runs.
672+
- name: Check whether the dev container is affected
673+
id: changes
674+
env:
675+
GH_TOKEN: ${{ github.token }}
676+
EVENT: ${{ github.event_name }}
677+
PR_NUMBER: ${{ github.event.pull_request.number }}
678+
run: |
679+
affected=true
680+
if [ "$EVENT" = pull_request ] &&
681+
files=$(gh pr diff "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --name-only) &&
682+
! grep -qE '^(\.devcontainer/|Makefile$|dune-project$|[^/]*\.opam(\.template)?$|\.yarnrc\.yml$|yarn\.lock$|\.yarn/|\.github/workflows/ci\.yml$)|(^|/)package\.json$' <<< "$files"; then
683+
affected=false
684+
fi
685+
echo "affected=$affected" | tee -a "$GITHUB_OUTPUT"
668686
- name: Checkout
687+
if: steps.changes.outputs.affected == 'true'
669688
uses: actions/checkout@v7
670689
- name: Run make in dev container
690+
if: steps.changes.outputs.affected == 'true'
671691
uses: devcontainers/ci@v0.3
672-
with:
692+
with:
673693
push: never
674694
runCmd: make
675695

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Build the dev container in CI only for pull requests that change its inputs.

0 commit comments

Comments
 (0)