Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 35 additions & 31 deletions .github/workflows/pr-require-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ permissions:
#
# The cost of the branch: a contract-only run no longer queues behind the full
# run whose `ci-lanes` status it carries forward, so the two race. The
# `ci-status` composite closes that without waiting: with `yield-to-full-run` a
# contract-only run fails at once while a full run is in flight on the same head
# SHA, whose newer ci-status then decides the gate; see the job below.
# `report-ci-status` composite closes that without waiting: a contract-only run
# fails at once while a full run is in flight on the same head SHA, whose newer
# ci-status then decides the gate; see the job below.
#
# One hazard the branch does not remove, because no concurrency setting both
# removes it and keeps supersession: the full branch is keyed on the pull
Expand Down Expand Up @@ -1054,9 +1054,10 @@ jobs:
name: CI Status
if: ${{ !cancelled() }}
permissions:
# `yield-to-full-run` lists this workflow's runs on the head SHA, and
# `rerun-contract-only-siblings` re-runs the red contract-only ones once
# the full run records `success`. Write covers the read.
# The composite lists this workflow's runs on the head SHA (its fixed
# `yield-to-full-run`) and re-runs the red contract-only ones once the
# full run records `success` (`rerun-contract-only-siblings`). Write
# covers the read.
actions: write
contents: read
# check-contract upserts the advisory linkage comment and moves the
Expand Down Expand Up @@ -1088,35 +1089,30 @@ jobs:
# ends `cancelled`, which counts as red.
timeout-minutes: 8
steps:
- name: Check the pull-request contract
uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/check-contract@24067add42f5fa04743c587c6a22aa7d4059e7b8 # v0.75.0
# The contract, the draft policy and the aggregation in one step. The
# step keeps the aggregation step's old name: a contract-only run finds
# the writer step of the full run it carries forward by this name.
# The composite fixes `yield-to-full-run: 'true'` and
# `carry-forward-wait-seconds: '0'`, the values this job set before
# (https://github.com/melodic-software/ci-workflows/blob/ebd0e3bed99ae1365fcb4ef47ce97cfa745fcf2f/.github/actions/pr-require-checks/report-ci-status/action.yml#L128-L129):
# a contract-only run never waits; while a full run on the SHA is in
# flight it fails with "superseded by full run <url>", and once that run
# records `success` it re-runs the red contract-only runs
# (`rerun-contract-only-siblings`, default `true`; this workflow is not
# draft-gated, so the re-run is unconditional). `treat-skipped-as` stays
# at its default `fail`, as before.
- name: Aggregate lane results
id: report
uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/report-ci-status@ebd0e3bed99ae1365fcb4ef47ce97cfa745fcf2f # v0.76.0
with:
token: ${{ github.token }}
# Carried over from the pr-issue-linkage.yml caller this step
# replaces, so Dependabot's bodies keep skipping the linkage check
step-name: Aggregate lane results
# Carried over from the pr-issue-linkage.yml caller the contract step
# replaced, so Dependabot's bodies keep skipping the linkage check
# rather than starting to fail it. Exact-login match, never a
# `*[bot]` pattern.
exempt-authors: 'dependabot[bot]'
- name: Aggregate lane results
# `!cancelled()` so a failing check-contract step does not skip the
# aggregation: the job still fails on the contract step's exit code,
# and the `ci-lanes` status is on the SHA for the next contract-only
# run.
if: ${{ !cancelled() }}
uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/aggregate-results@24067add42f5fa04743c587c6a22aa7d4059e7b8 # v0.75.0
with:
treat-skipped-as: fail
step-name: Aggregate lane results
token: ${{ github.token }}
# A contract-only run never waits: while a full run on the SHA is in
# flight it fails with "superseded by full run <url>", and that run's
# newer ci-status decides the gate. Once the full run records
# `success` it re-runs those red contract-only runs, which then read
# the `success` and replace their red check runs. This workflow is
# not draft-gated, so the re-run is unconditional.
yield-to-full-run: 'true'
rerun-contract-only-siblings: 'true'
carry-forward-wait-seconds: '0'
# This workflow is not draft-gated (no `ready_for_review` trigger), so a draft passes.
draft: allow
results: >-
${{ needs.check-shell.result }}
${{ needs.check-markdown-and-links.result }}
Expand All @@ -1134,3 +1130,11 @@ jobs:
${{ needs.pr-scan-dependencies.result }}
${{ needs.test-cloud-environment.result }}
${{ needs.test-distribution.result }}
# The composite's step concludes on the lanes alone; the contract and
# draft results fail the job here. Anything but `success` fails, so an
# empty or renamed output fails closed.
- name: Fail on the contract or draft policy
if: ${{ !cancelled() && (steps.report.outputs.contract != 'success' || steps.report.outputs.draft != 'success') }}
run: |
echo "::error::ci-status: the pull-request contract or the draft policy failed; see the step above."
exit 1
8 changes: 5 additions & 3 deletions components/commit-convention/commit-convention.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ assert_eq 'types equal pr-convention-policy title.allowedTypes' "$policy_types"
require_scope="$(node -e 'process.stdout.write(String(JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")).title.requireScope))' "$policy")"
assert_eq 'pr-convention-policy keeps the scope optional, as the pattern does' 'false' "$require_scope"

contract_pin="$(sed -E -n 's#^ *uses: melodic-software/ci-workflows/\.github/actions/pr-require-checks/check-contract@([0-9a-f]{40}).*#\1#p' \
# report-ci-status runs check-contract through `$/` at the commit it is pinned
# to, so either pin names the check-contract that gates.
contract_pin="$(sed -E -n 's#^ *uses: melodic-software/ci-workflows/\.github/actions/pr-require-checks/(check-contract|report-ci-status)@([0-9a-f]{40}).*#\2#p' \
"$root/.github/workflows/pr-require-checks.yml" | sort -u)"
if [[ "$contract_pin" =~ ^[0-9a-f]{40}$ ]]; then
pass 'pr-require-checks.yml pins one check-contract SHA'
pass 'pr-require-checks.yml pins one check-contract or report-ci-status SHA'
else
fail 'pr-require-checks.yml pins one check-contract SHA' "got: $contract_pin"
fail 'pr-require-checks.yml pins one check-contract or report-ci-status SHA' "got: $contract_pin"
fi
action_yml="$TEST_TMPDIR/check-contract-action.yml"
auth=()
Expand Down
Loading