Skip to content

Commit e50ca3e

Browse files
authored
Merge branch 'main' into add-verify-clean-pkl
2 parents a12fb06 + 85a5884 commit e50ca3e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/pkl.impl.ghactions/PklCI.pkl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import "@gha/Context.pkl"
2020
import "@gha/Workflow.pkl"
2121

2222
import "actions/PublishUnitTestResult.pkl"
23+
import "helpers.pkl"
2324
import "jobs/CheckPklEval.pkl"
2425
import "util.pkl"
2526

@@ -408,6 +409,7 @@ local withPublishTestResultsForMultipleJobs: Mixin<Workflow.Jobs> = (it) -> (it)
408409
}
409410
["publish-test-results"] {
410411
needs = it.keys.filter((key) -> testReports.includes(key)).toListing()
412+
`if` = helpers.ifNoUpstreamFailures
411413
`runs-on` = "ubuntu-latest"
412414
permissions {
413415
checks = "write"
@@ -477,6 +479,8 @@ local function withTriggerWorkflows(triggerType: String): Mixin<Workflow.Jobs> =
477479
}
478480
`runs-on` = "ubuntu-latest"
479481
`if` = "github.repository_owner == 'apple'"
482+
// NOTE: not using helpers.ifNoUpstreamFailures here because nothing should be skipped
483+
// for release, releaseBranch, or main workflows
480484
steps {
481485
new {
482486
name = "Create app token"

packages/pkl.impl.ghactions/helpers.pkl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,19 @@ const withMavenPublishSecrets: Mixin<Workflow.Step> = new {
2727
["ORG_GRADLE_PROJECT_sonatypeUsername"] = Context.secrets("ORG_GRADLE_PROJECT_SONATYPEUSERNAME")
2828
}
2929
}
30+
31+
/// Use this for an `if` condition on jobs that "fan in" from multiple ancestors when one or more of
32+
/// those ancestors runs conditionally.
33+
///
34+
/// The four job states in GHA are:
35+
/// * success - completed successfully, checked by `success()`.
36+
/// * failure - ran unsuccessfully, checked by `failure()`.
37+
/// * cancelled - explicit user cancellation, checked by `cancelled()`.
38+
/// * skipped - skipped due to `if` condition, no check function.
39+
///
40+
/// Per [the docs](https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#status-check-functions):
41+
/// > A default status check of success() is applied unless you include one of these functions.
42+
///
43+
/// This condition overrides the default behavior to proceed if all ancestor jobs have result
44+
/// `success` or `skipped`.
45+
const ifNoUpstreamFailures: String = "!failure() && !cancelled()"

0 commit comments

Comments
 (0)