11# reusable workflow
22name : .test
33
4- # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
54permissions :
65 contents : read
76
2625 includes :
2726 required : false
2827 type : string
29- env :
30- required : false
31- type : string
28+ secrets :
29+ codecov_token :
30+ required : true
3231
3332env :
3433 GO_VERSION : " 1.26"
@@ -46,10 +45,10 @@ jobs:
4645 steps :
4746 -
4847 name : Set up QEMU
49- uses : docker/setup-qemu-action@v4
48+ uses : docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
5049 -
5150 name : Set up Docker Buildx
52- uses : docker/setup-buildx-action@v4
51+ uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
5352 with :
5453 version : ${{ env.SETUP_BUILDX_VERSION }}
5554 driver-opts : image=${{ env.SETUP_BUILDKIT_IMAGE }}
@@ -61,38 +60,43 @@ jobs:
6160 -
6261 name : Set outputs
6362 id : set
64- uses : actions/github-script@v8
63+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
64+ env :
65+ INPUT_PKGS : ${{ inputs.pkgs }}
66+ INPUT_KINDS : ${{ inputs.kinds }}
67+ INPUT_TAGS : ${{ inputs.tags }}
68+ INPUT_INCLUDES : ${{ inputs.includes }}
6569 with :
6670 script : |
6771 const yaml = require('js-yaml');
6872 await core.group(`Set pkgs matrix`, async () => {
69- const pkgs = `${{ inputs.pkgs }}`.trim().split(/\r?\n/ );
73+ const pkgs = core.getMultilineInput('pkgs' );
7074 core.info(JSON.stringify(pkgs, null, 2));
7175 core.setOutput('pkgs', JSON.stringify(pkgs));
7276 });
7377 await core.group(`Set kinds matrix`, async () => {
74- const kinds = `${{ inputs.kinds }}`.trim().split(/\r?\n/ );
78+ const kinds = core.getMultilineInput('kinds' );
7579 core.info(JSON.stringify(kinds, null, 2));
7680 core.setOutput('kinds', JSON.stringify(kinds));
7781 });
7882 await core.group(`Set tags matrix`, async () => {
79- const tags = `${{ inputs.tags }}`.trim().split(/\r?\n/ );
83+ const tags = core.getMultilineInput('tags' );
8084 core.info(JSON.stringify(tags, null, 2));
8185 core.setOutput('tags', JSON.stringify(tags));
8286 });
8387 await core.group(`Set includes`, async () => {
84- const includes = yaml.load(`${{ inputs.includes }}`.trim( ));
88+ const includes = yaml.load(core.getInput('includes' ));
8589 core.info(JSON.stringify(includes, null, 2));
8690 core.setOutput('includes', JSON.stringify(includes ?? []));
8791 });
8892 -
8993 name : Build
90- uses : docker/bake-action@v7
94+ uses : docker/bake-action@82490499d2e5613fcead7e128237ef0b0ea210f7 # v7.0.0
9195 with :
9296 targets : integration-tests-base
9397 set : |
9498 *.cache-from=type=gha,scope=${{ inputs.cache_scope }}
95- *.cache-to=type=gha,scope=${{ inputs.cache_scope }},repository=${{ github.repository }},ghtoken=${{ secrets.GITHUB_TOKEN }}
99+ *.cache-to=type=gha,scope=${{ inputs.cache_scope }},repository=${{ github.repository }},ghtoken=${{ github.token }}
96100
97101 run :
98102 runs-on : ubuntu-24.04
@@ -122,38 +126,41 @@ jobs:
122126 steps :
123127 -
124128 name : Prepare
129+ env :
130+ PKG : ${{ matrix.pkg }}
131+ KIND : ${{ matrix.kind }}
132+ WORKER : ${{ matrix.worker }}
133+ TAGS : ${{ matrix.tags }}
134+ SKIP_INTEGRATION_TESTS : ${{ matrix.skip-integration-tests }}
125135 run : |
126- for l in "${{ inputs.env }}"; do
127- echo "${l?}" >> $GITHUB_ENV
128- done
129- echo "TEST_REPORT_NAME=${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.skip-integration-tests }}-${{ matrix.kind }}-${{ matrix.worker }}-${{ matrix.tags }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
130- testFlags="${{ env.TESTFLAGS }}"
131- if [ -n "${{ matrix.tags }}" ]; then
132- testFlags="${testFlags} --tags=${{ matrix.tags }}"
136+ echo "TEST_REPORT_NAME=${GITHUB_JOB}-$(echo "${PKG}-${SKIP_INTEGRATION_TESTS}-${KIND}-${WORKER}-${TAGS}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
137+ testFlags="${TESTFLAGS}"
138+ if [ -n "$TAGS" ]; then
139+ testFlags="${testFlags} --tags=${TAGS}"
133140 fi
134- if [ -n "${{ matrix.worker } }" ]; then
135- testFlags="${testFlags} --run=//worker=${{ matrix.worker } }$"
141+ if [ -n "${WORKER }" ]; then
142+ testFlags="${testFlags} --run=//worker=${WORKER }$"
136143 fi
137144 echo "TESTFLAGS=${testFlags}" >> $GITHUB_ENV
138145 -
139146 name : Checkout
140- uses : actions/checkout@v6
147+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
141148 -
142149 name : Expose GitHub Runtime
143- uses : crazy-max/ghaction-github-runtime@v4
150+ uses : crazy-max/ghaction-github-runtime@04d248b84655b509d8c44dc1d6f990c879747487 # v4.0.0
144151 -
145152 name : Set up QEMU
146- uses : docker/setup-qemu-action@v4
153+ uses : docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
147154 -
148155 name : Set up Docker Buildx
149- uses : docker/setup-buildx-action@v4
156+ uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
150157 with :
151158 version : ${{ env.SETUP_BUILDX_VERSION }}
152159 driver-opts : image=${{ env.SETUP_BUILDKIT_IMAGE }}
153160 buildkitd-flags : --debug
154161 -
155162 name : Build test image
156- uses : docker/bake-action@v7
163+ uses : docker/bake-action@82490499d2e5613fcead7e128237ef0b0ea210f7 # v7.0.0
157164 with :
158165 targets : integration-tests
159166 set : |
@@ -164,8 +171,9 @@ jobs:
164171 -
165172 name : Test
166173 run : |
167- ./hack/test ${{ matrix.kind } }
174+ ./hack/test ${KIND }
168175 env :
176+ KIND : ${{ matrix.kind }}
169177 TEST_REPORT_SUFFIX : -${{ env.TEST_REPORT_NAME }}
170178 TEST_COVERAGE : 1
171179 TESTPKGS : ${{ matrix.pkg }}
@@ -174,12 +182,12 @@ jobs:
174182 -
175183 name : Send to Codecov
176184 if : always()
177- uses : codecov/codecov-action@v5
185+ uses : codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5.5.4
178186 with :
179187 directory : ./bin/testreports
180188 flags : ${{ matrix.codecov_flags }}
181189 disable_file_fixes : true
182- token : ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
190+ token : ${{ secrets.codecov_token }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
183191 -
184192 name : Generate annotations
185193 if : always()
@@ -189,12 +197,8 @@ jobs:
189197 -
190198 name : Upload test reports
191199 if : always()
192- uses : actions/upload-artifact@v7
200+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
193201 with :
194202 name : test-reports-${{ env.TEST_REPORT_NAME }}
195203 path : ./bin/testreports
196204 retention-days : 1
197- -
198- name : Dump context
199- if : failure()
200- uses : crazy-max/ghaction-dump-context@v2
0 commit comments