File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI - Test Images
2+
3+ on :
4+ push :
5+ branches :
6+ - develop
7+ paths :
8+ - " images/**"
9+ pull_request :
10+ paths :
11+ - " images/**"
12+ workflow_dispatch :
13+
14+ jobs :
15+ detect :
16+ runs-on : ubuntu-latest
17+ outputs :
18+ images : ${{ steps.set-matrix.outputs.images }}
19+ steps :
20+ - name : Checkout
21+ uses : actions/checkout@v4
22+ with :
23+ fetch-depth : 0
24+
25+ - name : Detect changed images
26+ id : set-matrix
27+ run : |
28+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
29+ images=$(ls -d images/*/ | xargs -n1 basename | jq -R -s -c 'split("\n")[:-1]')
30+ elif [ "${{ github.event_name }}" = "pull_request" ]; then
31+ base="${{ github.event.pull_request.base.sha }}"
32+ images=$(git diff --name-only "$base" HEAD -- images/ | cut -d/ -f2 | sort -u | jq -R -s -c 'split("\n")[:-1]')
33+ else
34+ images=$(git diff --name-only "${{ github.event.before }}" HEAD -- images/ | cut -d/ -f2 | sort -u | jq -R -s -c 'split("\n")[:-1]')
35+ fi
36+ echo "images=$images" >> $GITHUB_OUTPUT
37+
38+ test :
39+ needs : detect
40+ runs-on : ubuntu-latest
41+ strategy :
42+ fail-fast : false
43+ matrix :
44+ image : ${{ fromJson(needs.detect.outputs.images) }}
45+ steps :
46+ - name : Checkout
47+ uses : actions/checkout@v4
48+
49+ - name : Install devcontainer CLI
50+ run : npm install -g @devcontainers/cli
51+
52+ - name : Build image
53+ run : devcontainer up --workspace-folder images/${{ matrix.image }}
54+
55+ - name : Run tests
56+ run : |
57+ devcontainer exec --workspace-folder images/${{ matrix.image }} \
58+ /bin/sh -c 'if [ -f test-project/test.sh ]; then cd test-project && chmod +x test.sh && ./test.sh; else echo "No test-project/test.sh found, skipping."; fi'
Original file line number Diff line number Diff line change @@ -10,8 +10,20 @@ Base devcontainer image with common tools.
1010}
1111```
1212
13- ## Included Features
13+ ## Included Tools
1414
15- - [ Claude Code] ( ../features/claude-code )
16- - [ Gemini Cli] ( ../features/gemini-cli )
17- - [ Prettier] ( ../features/prettier )
15+ | Tool | Source |
16+ | --- | --- |
17+ | common-utils (` developer ` user, UID/GID 1000) | [ devcontainers/features/common-utils] ( https://github.com/devcontainers/features/tree/main/src/common-utils ) |
18+ | git | [ devcontainers/features/git] ( https://github.com/devcontainers/features/tree/main/src/git ) |
19+ | Node.js 24 + npm | [ devcontainers/features/node] ( https://github.com/devcontainers/features/tree/main/src/node ) |
20+ | prettier | [ prettier] ( https://www.npmjs.com/package/prettier ) |
21+ | Claude Code | [ @anthropic-ai/claude-code ] ( https://www.npmjs.com/package/@anthropic-ai/claude-code ) |
22+ | Gemini CLI | [ @google/gemini-cli ] ( https://www.npmjs.com/package/@google/gemini-cli ) |
23+
24+ ## Testing
25+
26+ ``` bash
27+ devcontainer up --workspace-folder images/base
28+ devcontainer exec --workspace-folder images/base /bin/sh -c ' cd test-project && chmod +x test.sh && ./test.sh'
29+ ```
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ USERNAME=${1:- developer}
4+
5+ if [ -z " $HOME " ]; then
6+ HOME=" /root"
7+ fi
8+
9+ FAILED=" "
10+
11+ check () {
12+ LABEL=$1
13+ shift
14+ printf ' \n🧪 Testing %s\n' " $LABEL "
15+ if " $@ " ; then
16+ echo " ✅ Passed!"
17+ return 0
18+ else
19+ echo " ❌ $LABEL check failed."
20+ FAILED=" $FAILED $LABEL "
21+ return 1
22+ fi
23+ }
24+
25+ check_version_ge () {
26+ LABEL=$1
27+ CURRENT_VERSION=$2
28+ REQUIRED_VERSION=$3
29+ printf ' \n🧪 Testing %s: ' \' ' %s' \' ' is >= ' \' ' %s' \' ' \n' " $LABEL " " $CURRENT_VERSION " " $REQUIRED_VERSION "
30+ GREATER_VERSION=$( printf ' %s\n%s\n' " $CURRENT_VERSION " " $REQUIRED_VERSION " | sort -V | tail -1)
31+ if [ " $CURRENT_VERSION " = " $GREATER_VERSION " ]; then
32+ echo " ✅ Passed!"
33+ return 0
34+ else
35+ echo " ❌ $LABEL check failed."
36+ FAILED=" $FAILED $LABEL "
37+ return 1
38+ fi
39+ }
40+
41+ reportResults () {
42+ if [ -n " $FAILED " ]; then
43+ printf ' \n💥 Failed tests:%s\n' " $FAILED "
44+ exit 1
45+ else
46+ printf ' \n💯 All passed!\n'
47+ exit 0
48+ fi
49+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ cd " $( dirname " $0 " ) "
3+
4+ . ./test-utils.sh developer
5+
6+ # User checks
7+ check " non-root-user" id ${USERNAME}
8+ check " uid" test " $( id -u ${USERNAME} ) " = " 1000"
9+ check " gid" test " $( id -g ${USERNAME} ) " = " 1000"
10+
11+ # Tool checks
12+ check " git" git --version
13+ check " node" node --version
14+
15+ node_version=$( node --version)
16+ check_version_ge " node-requirement" " ${node_version} " " v24.0.0"
17+
18+ check " npm" npm --version
19+ check " prettier" prettier --version
20+ check " claude" claude --version
21+ check " gemini" gemini --version
22+
23+ # Config checks
24+ check " prettierrc" test -f /workspaces/.prettierrc
25+
26+ # Report result
27+ reportResults
You can’t perform that action at this time.
0 commit comments