Skip to content

Commit 923b90a

Browse files
committed
Correct conditional logic for publishing steps of build workflow
The "Arduino IDE" GitHub Actions workflow is used to generate several distinct types of builds: - Tester builds of commits - Nightly builds - Release builds Different actions must be performed depending on which type of build is being produced. The workflow uses dedicated jobs for publishing the nightly builds and for publishing the release builds. Those jobs are configured to run only when certain criteria are met. One such criteria is that the merge-channel-files job ran as expected. There are four possible result types of a job, which should be handled as follows: | Result | Run dependent job? | | -------- | ------------------ | | success | Yes | | failure | No | | canceled | No | | skipped | Yes | GitHub Actions automatically takes the desired action regarding whether the dependent job should run for the first three result types, but that is not the case for the "skipped" result. The merge-channel-files job dependency is skipped when a channel file merge is not needed and so this is not cause to cancel the build publishing. The only way to make a dependent job run when the dependency was skipped is to add the `always()` expression to the job conditional. This goes too far in the other direction by causing the job to run even when the dependency failed or was canceled. So it is necessary to also add logic for each of the dependency job result types to the conditional, which makes it quite complex when combined with the logic for the other criteria of the job. In order to reduce the amount of complexity of the conditionals of the dependent jobs, a job was interposed in the dependency chain, which was intended to act simply as a container for the logic about the merge-channel-files job result. Unfortunately it turns out that even if the direct dependency job's result was success, if any ancestor in the dependency chain was skipped, GitHub Actions still skips all dependent jobs without an `always()` expression in their conditional, meaning the intermediate job was pointless. This caused the build publishing jobs to be skipped under the conditions where they should have ran. The pointless intermediate job is hereby removed, an `always()` expression added to the conditionals of the dependent jobs, and the full logic for how to handle each dependent job result type added there as well.
1 parent ce01351 commit 923b90a

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

Diff for: .github/workflows/build.yml

+18-21
Original file line numberDiff line numberDiff line change
@@ -452,24 +452,6 @@ jobs:
452452
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
453453
path: ${{ env.CHANNEL_FILES_PATH }}
454454

455-
# This job serves only as a container for the logic necessary to allow dependent jobs to run if the
456-
# merge-channel-files job was skipped.
457-
merge-channel-files-complete:
458-
needs:
459-
- merge-channel-files
460-
if: >
461-
always() &&
462-
(
463-
needs.merge-channel-files.result == 'skipped' ||
464-
needs.merge-channel-files.result == 'success'
465-
)
466-
runs-on: ubuntu-latest
467-
permissions: {}
468-
steps:
469-
# GitHub Actions requires every job to have >=1 step.
470-
- name: Dummy step
471-
run: ''
472-
473455
artifacts:
474456
name: ${{ matrix.artifact.name }} artifact
475457
needs:
@@ -546,9 +528,16 @@ jobs:
546528
publish:
547529
needs:
548530
- build-type-determination
549-
- merge-channel-files-complete
531+
- merge-channel-files
550532
- changelog
551533
if: >
534+
always() &&
535+
needs.build-type-determination.result == 'success' &&
536+
(
537+
needs.merge-channel-files.result == 'skipped' ||
538+
needs.merge-channel-files.result == 'success'
539+
) &&
540+
needs.changelog.result == 'success' &&
552541
needs.build-type-determination.outputs.publish-to-s3 == 'true' &&
553542
needs.build-type-determination.outputs.is-nightly == 'true'
554543
runs-on: ubuntu-latest
@@ -572,9 +561,17 @@ jobs:
572561
release:
573562
needs:
574563
- build-type-determination
575-
- merge-channel-files-complete
564+
- merge-channel-files
576565
- changelog
577-
if: needs.build-type-determination.outputs.is-release == 'true'
566+
if: >
567+
always() &&
568+
needs.build-type-determination.result == 'success' &&
569+
(
570+
needs.merge-channel-files.result == 'skipped' ||
571+
needs.merge-channel-files.result == 'success'
572+
) &&
573+
needs.changelog.result == 'success' &&
574+
needs.build-type-determination.outputs.is-release == 'true'
578575
runs-on: ubuntu-latest
579576
steps:
580577
- name: Download [GitHub Actions]

0 commit comments

Comments
 (0)