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,46 @@ 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/);
70- core.info(JSON.stringify(pkgs, null, 2));
71- core.setOutput('pkgs', JSON.stringify(pkgs));
73+ const pkgs = core.getMultilineInput('pkgs');
74+ const matrix = pkgs.length ? pkgs : [''];
75+ core.info(JSON.stringify(matrix, null, 2));
76+ core.setOutput('pkgs', JSON.stringify(matrix));
7277 });
7378 await core.group(`Set kinds matrix`, async () => {
74- const kinds = `${{ inputs.kinds }}`.trim().split(/\r?\n/);
75- core.info(JSON.stringify(kinds, null, 2));
76- core.setOutput('kinds', JSON.stringify(kinds));
79+ const kinds = core.getMultilineInput('kinds');
80+ const matrix = kinds.length ? kinds : [''];
81+ core.info(JSON.stringify(matrix, null, 2));
82+ core.setOutput('kinds', JSON.stringify(matrix));
7783 });
7884 await core.group(`Set tags matrix`, async () => {
79- const tags = `${{ inputs.tags }}`.trim().split(/\r?\n/);
80- core.info(JSON.stringify(tags, null, 2));
81- core.setOutput('tags', JSON.stringify(tags));
85+ const tags = core.getMultilineInput('tags');
86+ const matrix = tags.length ? tags : [''];
87+ core.info(JSON.stringify(matrix, null, 2));
88+ core.setOutput('tags', JSON.stringify(matrix));
8289 });
8390 await core.group(`Set includes`, async () => {
84- const includes = yaml.load(`${{ inputs.includes }}`.trim( ));
91+ const includes = yaml.load(core.getInput('includes' ));
8592 core.info(JSON.stringify(includes, null, 2));
8693 core.setOutput('includes', JSON.stringify(includes ?? []));
8794 });
8895 -
8996 name : Build
90- uses : docker/bake-action@v7
97+ uses : docker/bake-action@82490499d2e5613fcead7e128237ef0b0ea210f7 # v7.0.0
9198 with :
9299 targets : integration-tests-base
93100 set : |
94101 *.cache-from=type=gha,scope=${{ inputs.cache_scope }}
95- *.cache-to=type=gha,scope=${{ inputs.cache_scope }},repository=${{ github.repository }},ghtoken=${{ secrets.GITHUB_TOKEN }}
102+ *.cache-to=type=gha,scope=${{ inputs.cache_scope }},repository=${{ github.repository }},ghtoken=${{ github.token }}
96103
97104 run :
98105 runs-on : ubuntu-24.04
@@ -122,38 +129,41 @@ jobs:
122129 steps :
123130 -
124131 name : Prepare
132+ env :
133+ PKG : ${{ matrix.pkg }}
134+ KIND : ${{ matrix.kind }}
135+ WORKER : ${{ matrix.worker }}
136+ TAGS : ${{ matrix.tags }}
137+ SKIP_INTEGRATION_TESTS : ${{ matrix.skip-integration-tests }}
125138 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 }}"
139+ echo "TEST_REPORT_NAME=${GITHUB_JOB}-$(echo "${PKG}-${SKIP_INTEGRATION_TESTS}-${KIND}-${WORKER}-${TAGS}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
140+ testFlags="${TESTFLAGS}"
141+ if [ -n "$TAGS" ]; then
142+ testFlags="${testFlags} --tags=${TAGS}"
133143 fi
134- if [ -n "${{ matrix.worker } }" ]; then
135- testFlags="${testFlags} --run=//worker=${{ matrix.worker } }$"
144+ if [ -n "${WORKER }" ]; then
145+ testFlags="${testFlags} --run=//worker=${WORKER }$"
136146 fi
137147 echo "TESTFLAGS=${testFlags}" >> $GITHUB_ENV
138148 -
139149 name : Checkout
140- uses : actions/checkout@v6
150+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
141151 -
142152 name : Expose GitHub Runtime
143- uses : crazy-max/ghaction-github-runtime@v4
153+ uses : crazy-max/ghaction-github-runtime@04d248b84655b509d8c44dc1d6f990c879747487 # v4.0.0
144154 -
145155 name : Set up QEMU
146- uses : docker/setup-qemu-action@v4
156+ uses : docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
147157 -
148158 name : Set up Docker Buildx
149- uses : docker/setup-buildx-action@v4
159+ uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
150160 with :
151161 version : ${{ env.SETUP_BUILDX_VERSION }}
152162 driver-opts : image=${{ env.SETUP_BUILDKIT_IMAGE }}
153163 buildkitd-flags : --debug
154164 -
155165 name : Build test image
156- uses : docker/bake-action@v7
166+ uses : docker/bake-action@82490499d2e5613fcead7e128237ef0b0ea210f7 # v7.0.0
157167 with :
158168 targets : integration-tests
159169 set : |
@@ -164,8 +174,9 @@ jobs:
164174 -
165175 name : Test
166176 run : |
167- ./hack/test ${{ matrix.kind } }
177+ ./hack/test ${KIND }
168178 env :
179+ KIND : ${{ matrix.kind }}
169180 TEST_REPORT_SUFFIX : -${{ env.TEST_REPORT_NAME }}
170181 TEST_COVERAGE : 1
171182 TESTPKGS : ${{ matrix.pkg }}
@@ -174,12 +185,12 @@ jobs:
174185 -
175186 name : Send to Codecov
176187 if : always()
177- uses : codecov/codecov-action@v5
188+ uses : codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5.5.4
178189 with :
179190 directory : ./bin/testreports
180191 flags : ${{ matrix.codecov_flags }}
181192 disable_file_fixes : true
182- token : ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
193+ token : ${{ secrets.codecov_token }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
183194 -
184195 name : Generate annotations
185196 if : always()
@@ -189,12 +200,8 @@ jobs:
189200 -
190201 name : Upload test reports
191202 if : always()
192- uses : actions/upload-artifact@v7
203+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
193204 with :
194205 name : test-reports-${{ env.TEST_REPORT_NAME }}
195206 path : ./bin/testreports
196207 retention-days : 1
197- -
198- name : Dump context
199- if : failure()
200- uses : crazy-max/ghaction-dump-context@v2
0 commit comments