Skip to content

Commit 4c5331c

Browse files
committed
ci: don't run test jobs after a failed or skipped build
A job with `needs:` and no `if:` gets an implicit `success()`, but an explicit `if:` replaces it rather than adding to it. Four jobs which carry a condition of their own therefore run whatever their dependency did: `test` in build.yml, `test-debian` in build-debian.yml and `debos-linux-deb` and `test-linux-deb` in linux.yml. Once the build they need fails, the image URL they pass on is empty and LAVA jobs are submitted against nothing, which is the exact inverse of the missing results this branch otherwise fixes. Check the result of the dependency in the condition. Comparing it against 'success' rather than calling `success()` also covers the case where the dependency was skipped, e.g. when build-linux-deb is guarded out because the workflow runs from a fork. Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
1 parent f0d2b1c commit 4c5331c

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

.github/workflows/build-debian.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ jobs:
4747
test-debian:
4848
# don't run cron from forks of the main repository or from other branches;
4949
# manual runs are allowed from any branch of the main repository so
50-
# that changes to the workflows can be tested before they are merged
50+
# that changes to the workflows can be tested before they are merged.
51+
# this explicit if: replaces the implicit success(), so the state of the
52+
# build job has to be checked too, otherwise LAVA jobs would be submitted
53+
# with an empty image url once it fails; checking the result rather than
54+
# calling success() also covers the case where the build was skipped
5155
if: >-
5256
github.repository == 'qualcomm-linux/qcom-deb-images' &&
5357
(github.event_name == 'workflow_dispatch' ||
54-
github.ref == 'refs/heads/main')
58+
github.ref == 'refs/heads/main') &&
59+
needs.build-debian.result == 'success'
5560
strategy:
5661
fail-fast: false
5762
matrix:

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@ jobs:
5757
test:
5858
# don't run from forks of the main repository or from other branches;
5959
# manual runs are allowed from any branch of the main repository so
60-
# that changes to the workflows can be tested before they are merged
60+
# that changes to the workflows can be tested before they are merged.
61+
# this explicit if: replaces the implicit success(), so the state of the
62+
# build job has to be checked too, otherwise LAVA jobs would be submitted
63+
# with an empty image url once it fails; checking the result rather than
64+
# calling success() also covers the case where the build was skipped
6165
if: >-
6266
github.repository == 'qualcomm-linux/qcom-deb-images' &&
6367
(github.event_name == 'workflow_dispatch' ||
64-
github.ref == 'refs/heads/main')
68+
github.ref == 'refs/heads/main') &&
69+
needs.build.result == 'success'
6570
strategy:
6671
fail-fast: false
6772
matrix:

.github/workflows/linux.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,14 @@ jobs:
183183
destination: ${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ github.run_id }}-${{ github.run_attempt }}/
184184

185185
debos-linux-deb:
186-
if: ${{ !inputs.skip_image_build }}
186+
# an explicit if: replaces the implicit success(), so the state of the
187+
# dependency has to be checked here as well; without it the image would
188+
# be built from a kernel build which failed or never ran. checking the
189+
# result rather than calling success() also covers the skipped case,
190+
# e.g. when build-linux-deb is guarded out on a fork
191+
if: >-
192+
${{ !inputs.skip_image_build &&
193+
needs.build-linux-deb.result == 'success' }}
187194
needs: build-linux-deb
188195
strategy:
189196
fail-fast: false
@@ -199,7 +206,11 @@ jobs:
199206
skip_qemu_tests: ${{ inputs.skip_qemu_tests || false }}
200207

201208
test-linux-deb:
202-
if: ${{ !inputs.skip_lava_tests }}
209+
# as above: without checking the dependency's result, LAVA jobs would be
210+
# submitted with an empty image url after a failed or skipped image build
211+
if: >-
212+
${{ !inputs.skip_lava_tests &&
213+
needs.debos-linux-deb.result == 'success' }}
203214
strategy:
204215
fail-fast: false
205216
matrix:

0 commit comments

Comments
 (0)