Skip to content

Commit 67a310b

Browse files
authored
fix(ci): publish maturity scorecards when main advances (#129955)
* fix(ci): retry stale maturity scorecard runs * fix(ci): refreeze queued scorecard successors * fix(ci): allow scorecard publication after main advances
1 parent 8ce8085 commit 67a310b

3 files changed

Lines changed: 31 additions & 19 deletions

File tree

‎.github/actions/publish-generated-pr/action.yml‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ inputs:
3434
required: true
3535
invalidation-paths:
3636
description: Newline-delimited generator input paths that make an older run stale.
37-
required: true
37+
required: false
38+
default: ""
3839
working-directory:
3940
description: Repository root containing the generated files.
4041
required: false
@@ -123,10 +124,6 @@ runs:
123124
invalidation_paths+=("${invalidation_path}")
124125
fi
125126
done <<< "${INVALIDATION_PATHS}"
126-
if [[ "${#invalidation_paths[@]}" -eq 0 ]]; then
127-
echo "Generated PR publication requires at least one invalidation path." >&2
128-
exit 1
129-
fi
130127
131128
find_open_pr() {
132129
timeout --signal=TERM --kill-after=10s 60s \
@@ -143,7 +140,8 @@ runs:
143140
echo "::error::Resolved workflow source is not an ancestor of latest ${BASE_BRANCH}."
144141
return 1
145142
fi
146-
if ! git diff --quiet "${source_commit}" "${base_ref}" -- "${invalidation_paths[@]}"; then
143+
if [[ "${#invalidation_paths[@]}" -gt 0 ]] &&
144+
! git diff --quiet "${source_commit}" "${base_ref}" -- "${invalidation_paths[@]}"; then
147145
neutralize_outcome=stale-input
148146
elif find_owned_path_overlap; then
149147
neutralize_outcome=overlap
@@ -274,7 +272,8 @@ runs:
274272
275273
# A completed older run must never publish output after a newer base changed generator
276274
# inputs. The caller chooses whether a guaranteed successor can own reconciliation.
277-
if ! git diff --quiet "${source_commit}" "${base_ref}" -- "${invalidation_paths[@]}"; then
275+
if [[ "${#invalidation_paths[@]}" -gt 0 ]] &&
276+
! git diff --quiet "${source_commit}" "${base_ref}" -- "${invalidation_paths[@]}"; then
278277
echo "::notice::Stale generated output detected because generator inputs changed on ${BASE_BRANCH}."
279278
prepare_outcome=stale-input
280279
return 0

‎.github/workflows/maturity-scorecard.yml‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,7 @@ jobs:
806806
qa/maturity-scores.yaml
807807
docs/maturity/scorecard.md
808808
docs/maturity/taxonomy.md
809-
invalidation-paths: |
810-
.
811-
:(exclude)qa/maturity-scores.yaml
812-
:(exclude)docs/maturity/scorecard.md
813-
:(exclude)docs/maturity/taxonomy.md
809+
invalidation-paths: ""
814810
overlap-policy: fail
815811
pr-body: |
816812
## What Problem This Solves

‎test/scripts/ci-workflow-guards.test.ts‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ function runGeneratedPublisherScenario(
13281328
existingPr?: boolean;
13291329
expectFailure?: boolean;
13301330
failGeneratedPush?: boolean;
1331+
invalidationPaths?: string;
13311332
mergeGeneratedPush?: boolean;
13321333
noGeneratedChange?: boolean;
13331334
overlapPolicy?: string;
@@ -1495,7 +1496,7 @@ ${actionRun}`;
14951496
FAKE_STALE_HEAD_ONCE: stalePrHeadOnce,
14961497
FAKE_STALE_PR_VIEW_HEAD_ONCE: stalePrViewHeadOnce,
14971498
GENERATED_PATHS: "generated",
1498-
INVALIDATION_PATHS: "source",
1499+
INVALIDATION_PATHS: options.invalidationPaths ?? "source",
14991500
OVERLAP_POLICY: options.overlapPolicy ?? "defer",
15001501
CONTENTS_TOKEN: "contents-token",
15011502
GH_TOKEN: "test-token",
@@ -2394,6 +2395,11 @@ NODE
23942395
expect(actionPublishStep.env.CONTENTS_TOKEN).toBe("${{ steps.tokens.outputs.contents-token }}");
23952396
expect(actionPublishStep.env.GH_TOKEN).toBe("${{ steps.tokens.outputs.pull-request-token }}");
23962397
expect(actionPublishStep.env.INVALIDATION_PATHS).toBe("${{ inputs.invalidation-paths }}");
2398+
expect(publishAction.inputs["invalidation-paths"]).toEqual({
2399+
description: "Newline-delimited generator input paths that make an older run stale.",
2400+
required: false,
2401+
default: "",
2402+
});
23972403
expect(publishAction.inputs["working-directory"]).toEqual({
23982404
description: "Repository root containing the generated files.",
23992405
required: false,
@@ -2741,6 +2747,21 @@ NODE
27412747
},
27422748
);
27432749

2750+
it.skipIf(process.platform === "win32")(
2751+
"publishes after unrelated source changes when input invalidation is disabled",
2752+
() => {
2753+
const result = runGeneratedPublisherScenario(null, {
2754+
invalidationPaths: "",
2755+
overlapPolicy: "fail",
2756+
updateSource: true,
2757+
});
2758+
2759+
expect(result.branchExists).toBe(true);
2760+
expect(result.generatedA).toBe("desired-a");
2761+
expect(result.publishOutput).not.toContain("Refusing stale generated output");
2762+
},
2763+
);
2764+
27442765
it.skipIf(process.platform === "win32")(
27452766
"neutralizes an existing pull request when generation has no changes",
27462767
() => {
@@ -9028,6 +9049,7 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
90289049

90299050
expect(publishPrJob.needs).toEqual(["validate_selected_ref", "publisher_preflight", "publish"]);
90309051
expect(publishPrJob["runs-on"]).toBe("ubuntu-24.04");
9052+
expect(publishPrJob.permissions).toEqual({ actions: "read", contents: "read" });
90319053
for (const fragment of [
90329054
"needs.publisher_preflight.result == 'success'",
90339055
"needs.publish.result == 'success'",
@@ -9084,17 +9106,12 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
90849106
"working-directory": "selected",
90859107
"commit-message": "docs: update maturity scorecard",
90869108
"pr-title": "docs: update maturity scorecard",
9109+
"invalidation-paths": "",
90879110
"overlap-policy": "fail",
90889111
});
90899112
expect(openDocsPrStep.with["generated-paths"].trim().split("\n")).toEqual(
90909113
MATURITY_GENERATED_PR_PATHS,
90919114
);
9092-
expect(openDocsPrStep.with["invalidation-paths"].trim().split("\n")).toEqual([
9093-
".",
9094-
":(exclude)qa/maturity-scores.yaml",
9095-
":(exclude)docs/maturity/scorecard.md",
9096-
":(exclude)docs/maturity/taxonomy.md",
9097-
]);
90989115
for (const heading of [
90999116
"## What Problem This Solves",
91009117
"## Why This Change Was Made",

0 commit comments

Comments
 (0)