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
24 changes: 18 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,29 @@ updates:
timezone: America/New_York
cooldown:
default-days: 7
# First-party releases take no soak (the synced Dependabot policy's
# `fastTrack.own`).
exclude:
- "melodic-software/ci-workflows/*"
open-pull-requests-limit: 5
commit-message:
prefix: build
# ci-workflows pins move only in the org-wide repin wave, so every repo stays on one
# ci-workflows release; a Dependabot bump would move this repo's pins alone.
# The one first-party pin Dependabot leaves alone sits in the sync-managed
# pr-check-managed-files-hosted.yml, which the standards sync owns.
ignore:
- dependency-name: "melodic-software/ci-workflows/*"
# The `vendor-actions` group (non-major only) is the auto-merge lane armed
# by pr-automerge-dependabot.yml; a dependency joins the first group that
# matches it, so majors fall through to the reviewed `github-actions` group.
- dependency-name: "melodic-software/ci-workflows/.github/actions/check-managed-files"
# The `first-party-actions` group and the `vendor-actions` group (non-major
# only) are the auto-merge lanes armed by pr-automerge-dependabot.yml. A
# dependency joins the first group that matches it: a vendor major falls
# through to the reviewed `github-actions` group, and a first-party major
# stays in `first-party-actions`, where the lane does not arm a pull
# request that holds a major bump, so a person merges it.
groups:
# Every ci-workflows composite-action pin moves in one pull request, so
# the repository stays on one ci-workflows release.
first-party-actions:
patterns:
- "melodic-software/*"
Comment thread
kyle-sexton marked this conversation as resolved.
Resolved
vendor-actions:
patterns:
- actions/*
Expand Down
22 changes: 22 additions & 0 deletions .github/scripts/release-pins.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const checkout = readdirSync(workflowDirectory)
.map((name) => /actions\/checkout@[0-9a-f]{40} # v[0-9]+\.[0-9]+\.[0-9]+/u.exec(readFileSync(join(workflowDirectory, name), "utf8"))?.[0])
.find((reference) => reference !== undefined);
const bumpedCheckout = `actions/checkout@${"a".repeat(40)} # v999.0.0`;
const ciWorkflowsPin = /uses: melodic-software\/ci-workflows\/\.github\/actions\/\S+@([0-9a-f]{40} # v[0-9]+\.[0-9]+\.[0-9]+)/u.exec(
readFileSync(join(workflowDirectory, "pr-require-checks.yml"), "utf8"),
)?.[1];
const bumpedCiWorkflowsPin = `${"c".repeat(40)} # v999.0.0`;
const runnerFrom = /^FROM ghcr\.io\/actions\/actions-runner:\S+$/mu.exec(readFileSync(join(repositoryRoot, "Dockerfile"), "utf8"))?.[0];

// Runs Test-ReleasePins.ps1 against a copy of the repository after `edit`
Expand Down Expand Up @@ -66,6 +70,24 @@ test("a grouped Action bump passes without a manifest edit", () => {
assert.equal(result.status, 0, result.stderr + result.stdout);
});

test("a grouped ci-workflows bump passes without a manifest edit", () => {
const result = checkPins((root) => {
rewrite(join(root, ".github", "workflows", "pr-require-checks.yml"), `@${ciWorkflowsPin}`, `@${bumpedCiWorkflowsPin}`);
});
assert.equal(result.status, 0, result.stderr + result.stdout);
});

test("ci-workflows actions that name different releases fail with their locations", () => {
const result = checkPins((root) => {
const path = join(root, ".github", "workflows", "pr-require-checks.yml");
const source = readFileSync(path, "utf8");
assert.ok(source.includes(`@${ciWorkflowsPin}`), `${path} does not contain ${ciWorkflowsPin}`);
writeFileSync(path, source.replace(`@${ciWorkflowsPin}`, `@${bumpedCiWorkflowsPin}`));
});
assert.notEqual(result.status, 0);
assert.match(result.stderr + result.stdout, /\.yml:\d+ pins melodic-software\/ci-workflows@[0-9a-f]{40} # v[0-9.]+, but \S+\.yml:\d+ pins/u);
});

test("a runner image bump passes without a manifest edit", () => {
const result = checkPins((root) => {
rewrite(join(root, "Dockerfile"), runnerFrom, `FROM ghcr.io/actions/actions-runner:999.0.0@sha256:${"b".repeat(64)}`);
Expand Down
38 changes: 7 additions & 31 deletions .github/scripts/workflow-pin-metadata.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const test = require("node:test");
const repositoryRoot = path.resolve(__dirname, "..", "..");
const workflowDirectory = path.join(repositoryRoot, ".github", "workflows");
const ciWorkflowsReference = "melodic-software/ci-workflows/";
const syncManagedMarker = "SYNC-MANAGED FILE";
const syncManagedMarker = /^#\s*SYNC-MANAGED FILE/mu;
const canonicalReference =
/^\s*uses:\s+melodic-software\/ci-workflows\/(?<reference>[^\s@#]+)@(?<sha>[0-9a-f]{40})\s+#\s+(?<version>v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*))\s*$/;
const advisoryReference =
Expand Down Expand Up @@ -106,24 +106,19 @@ function workflowFiles(directory) {
.sort();
}

// The reviewed ci-workflows pin is whatever the canonical references agree on,
// not a constant repeated here. A grouped Dependabot bump rewrites every
// canonical `uses:` line at once and cannot touch this file or
// `release/dependencies.json`, so hardcoding the SHA, the version and the
// reference count made every bump red by construction and cost three manual
// edits. The tests below assert the properties that matter instead: the
// expected callers are all present, the references agree with each other, and
// the release manifest agrees with them. None of the three moves when only a
// SHA moves, which leaves `release/dependencies.json` as the single manual
// edit per bump.
// The ci-workflows pin is whatever the canonical references agree on: the
// `uses:` lines are its only record. A grouped Dependabot bump rewrites every
// canonical line at once and cannot edit this file, so the test asserts what a
// SHA move leaves alone: the expected callers are all present and the
// references name one commit and one release.
function ciWorkflowsPin() {
const references = [];
const versions = [];
const callers = [];

for (const file of workflowFiles(workflowDirectory)) {
const source = fs.readFileSync(file, "utf8");
const advisory = source.includes(syncManagedMarker);
const advisory = syncManagedMarker.test(source);
const lines = source.split(/\r?\n/u);
for (const [index, line] of lines.entries()) {
if (!line.includes(ciWorkflowsReference)) {
Expand Down Expand Up @@ -222,25 +217,6 @@ test("pr-run-checks-go uses the exact reusable caller contract", () => {
);
});

test("release metadata tracks the same ci-workflows release", () => {
const { sha } = ciWorkflowsPin();
const dependencies = JSON.parse(
fs.readFileSync(path.join(repositoryRoot, "release", "dependencies.json"), "utf8"),
);
assert.deepEqual(
dependencies.repositoryPins.filter(
({ repository }) => repository === "melodic-software/ci-workflows",
),
[
{
repository: "melodic-software/ci-workflows",
commit: sha,
source: `https://github.com/melodic-software/ci-workflows/tree/${sha}`,
},
],
);
});

test("local Go jobs do not duplicate reusable quality checks", () => {
const source = workflowSource("pr-require-checks.yml");
assert.doesNotMatch(source, /^ {2}go:\s*$/mu);
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/pr-require-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
with:
persist-credentials: false
- name: Lint Markdown
uses: melodic-software/ci-workflows/.github/actions/markdownlint@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/markdownlint@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
config: .markdownlint-cli2.jsonc

Expand All @@ -103,7 +103,7 @@ jobs:
with:
persist-credentials: false
- name: Lint shell
uses: melodic-software/ci-workflows/.github/actions/shellcheck@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/shellcheck@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
rcfile: .shellcheckrc

Expand All @@ -118,7 +118,7 @@ jobs:
with:
persist-credentials: false
- name: Check shell formatting
uses: melodic-software/ci-workflows/.github/actions/shfmt@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/shfmt@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0

typos:
name: Spelling
Expand All @@ -131,7 +131,7 @@ jobs:
with:
persist-credentials: false
- name: Check spelling
uses: melodic-software/ci-workflows/.github/actions/typos@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/typos@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
config: _typos.toml

Expand All @@ -146,7 +146,7 @@ jobs:
with:
persist-credentials: false
- name: Check EditorConfig conformance
uses: melodic-software/ci-workflows/.github/actions/editorconfig-checker@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/editorconfig-checker@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
config: .editorconfig-checker.json

Expand All @@ -162,7 +162,7 @@ jobs:
fetch-depth: 0
persist-credentials: false
- name: Scan for secrets
uses: melodic-software/ci-workflows/.github/actions/gitleaks@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/gitleaks@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
config: .gitleaks.toml

Expand All @@ -177,7 +177,7 @@ jobs:
with:
persist-credentials: false
- name: Check local links and anchors
uses: melodic-software/ci-workflows/.github/actions/lychee-offline@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/lychee-offline@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
config: lychee.toml

Expand All @@ -192,7 +192,7 @@ jobs:
with:
persist-credentials: false
- name: Scan comment hygiene
uses: melodic-software/ci-workflows/.github/actions/check-comment-markers@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/check-comment-markers@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0

actionlint:
name: Actionlint
Expand All @@ -205,7 +205,7 @@ jobs:
with:
persist-credentials: false
- name: Lint workflows
uses: melodic-software/ci-workflows/.github/actions/actionlint@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/actionlint@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0

jsonschema:
name: Jsonschema
Expand All @@ -218,12 +218,12 @@ jobs:
with:
persist-credentials: false
- name: Validate Dependabot configuration
uses: melodic-software/ci-workflows/.github/actions/check-jsonschema@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/check-jsonschema@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
builtin-schema: vendor.dependabot
files: .github/dependabot.yml
- name: Validate workflows
uses: melodic-software/ci-workflows/.github/actions/check-jsonschema@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/check-jsonschema@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
builtin-schema: vendor.github-workflows
files: .github/workflows/*.yml
Expand All @@ -239,7 +239,7 @@ jobs:
with:
persist-credentials: false
- name: Check executable bits
uses: melodic-software/ci-workflows/.github/actions/check-exec-bit@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/check-exec-bit@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0

check-machine-paths:
name: Check Machine Paths
Expand All @@ -252,7 +252,7 @@ jobs:
with:
persist-credentials: false
- name: Check machine-specific paths
uses: melodic-software/ci-workflows/.github/actions/check-machine-paths@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/check-machine-paths@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
# These files assert the official image's fixed in-container runner
# home. They contain no host/user path; keep the exception exact.
Expand All @@ -275,7 +275,7 @@ jobs:
with:
persist-credentials: false
- name: Check index-level EOL drift
uses: melodic-software/ci-workflows/.github/actions/check-line-endings@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/check-line-endings@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0

pr-audit-workflows:
name: Zizmor
Expand Down Expand Up @@ -503,7 +503,7 @@ jobs:
statuses: write # Records and reads back the `ci-lanes` commit status.
steps:
- name: Check the pull-request contract
uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/check-contract@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/check-contract@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
token: ${{ github.token }}
# Dependabot and the standards sync open pull requests that close no
Expand All @@ -519,7 +519,7 @@ jobs:
# 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@9bfbca898bff801f5a8fd3d0f98ae6a0538e4386 # v0.73.0
uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/aggregate-results@944d346c487c79eaf85dff752586fb59b0f5c539 # v0.74.0
with:
results: >-
${{ needs.markdownlint.result }}
Expand Down
35 changes: 20 additions & 15 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,18 @@ Actions. The workflow `uses:` lines and the Dockerfile `FROM` line are the only
record of those pins, so a Dependabot bump needs no other edit:
`scripts/ReleasePinSources.ps1` reads them, and `Test-ReleasePins.ps1` requires
every external Action to carry a `# vX.Y.Z` comment and name one release per
repository. `release/dependencies.json` keeps only what those lines cannot
carry: archive checksums, image digests of release tooling, sources, and the
`melodic-software/ci-workflows` repository pin. The release workflow's freshness
gate validates each Action's current tag and tag-to-commit mapping, the runner
tag's GHCR digest, and the runner archive digest against the SHA-256 the runner
release notes publish. Minor and patch bumps of `actions/*`, `github/*` and
`anthropics/*` Actions take the `vendor-actions` auto-merge lane
(`pr-automerge-dependabot.yml`), which merges once `CI Status` passes; every
other update PR is review-only.
repository. The `melodic-software/ci-workflows` composite actions follow the
same rule: every one outside a sync-managed file pins one commit with one
`# vX.Y.Z` release comment. `release/dependencies.json` keeps only what those
lines cannot carry: archive checksums, image digests of release tooling, and
sources. The release workflow's freshness gate validates each Action's current
tag and tag-to-commit mapping, ci-workflows included, the runner tag's GHCR
digest, and the runner archive digest against the SHA-256 the runner release
notes publish. Two Dependabot groups take the auto-merge lane
(`pr-automerge-dependabot.yml`), which merges once `CI Status` passes:
`first-party-actions` moves every ci-workflows composite-action pin in one pull
request (a non-major bump; a ci-workflows major is left for a person), and `vendor-actions` carries minor and patch bumps of `actions/*`,
`github/*` and `anthropics/*` Actions. Every other update PR is review-only.

On a first run, the workflow pushes the BuildKit result without a tag, pulls and
contract-tests that exact registry digest, publishes and verifies the immutable
Expand Down Expand Up @@ -173,14 +176,16 @@ installer or `latest`:
when the digest behind the pinned runner tag changes;
- retain at least the latest three known-good compatibility pairs;
- never auto-merge controller, runner, image, toolchain, Scale Set Client,
Action, or release changes, except the `vendor-actions` lane's minor and
patch Action bumps.
Action, or release changes, except the `first-party-actions` lane's
non-major ci-workflows bumps and the `vendor-actions` lane's minor and patch Action
bumps.

A partial drain may advance mechanical toolchain and publication pins while
holding a cross-repository SHA pin such as `melodic-software/ci-workflows`.
Record the reviewed hold in `release/dependency-drift-review.json`; the release
freshness gate continues to report the held row until a dedicated
compatibility PR moves every reference together.
holding an Action pin such as `melodic-software/ci-workflows`. Record the
reviewed hold in `release/dependency-drift-review.json` under the gate's row
name (`github-action:melodic-software/ci-workflows`); the release freshness gate
continues to report the held row until one pull request moves every reference
together.

Between releases, `.github/workflows/maintenance-check-dependency-freshness.yml`
runs the same check daily at 06:41 UTC, or on a manual dispatch, so drift is
Expand Down
8 changes: 1 addition & 7 deletions release/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@
"digest": "sha256:3c70e6d5979364cefdc22b51617a78fd264574d3bd6b4f84a351204147025e2a",
"source": "https://github.com/anchore/syft/releases/tag/v1.57.0"
},
"repositoryPins": [
{
"repository": "melodic-software/ci-workflows",
"commit": "9bfbca898bff801f5a8fd3d0f98ae6a0538e4386",
"source": "https://github.com/melodic-software/ci-workflows/tree/9bfbca898bff801f5a8fd3d0f98ae6a0538e4386"
}
],
"repositoryPins": [],
"reusableWorkflows": []
}
13 changes: 11 additions & 2 deletions scripts/ReleasePinSources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ function Get-RunnerBasePin([string] $Dockerfile) {
}

# One pin per external Action repository, from every `uses: owner/repo[/path]@<sha> # vX.Y.Z`
# line outside the excluded repositories. Every use of a repository must agree.
# line outside the excluded repositories. Every use of a repository must agree, so the
# melodic-software/ci-workflows composite actions name one release. Two ci-workflows
# references are not Action pins: a reusable workflow called at @main (standards#911),
# and the pin in a SYNC-MANAGED file, which the standards sync owns.
function Get-WorkflowActionPins([string] $WorkflowDirectory, [string[]] $ExcludedRepositories = @()) {
$pins = [ordered]@{}
foreach ($file in Get-ChildItem -LiteralPath $WorkflowDirectory -Filter '*.yml' -File | Sort-Object Name) {
$lines = @(Get-Content -LiteralPath $file.FullName)
$syncManaged = @($lines | Where-Object { $_ -cmatch '^#\s*SYNC-MANAGED FILE' }).Count -gt 0
$lineNumber = 0
foreach ($line in Get-Content -LiteralPath $file.FullName) {
foreach ($line in $lines) {
$lineNumber++
if ($line -notmatch '^\s*(?:-\s+)?uses:\s*(?<reference>[^\s#]+)(?<rest>.*)$') {
continue
Expand All @@ -38,6 +43,10 @@ function Get-WorkflowActionPins([string] $WorkflowDirectory, [string[]] $Exclude
if ($ExcludedRepositories -contains $repository) {
continue
}
if ($repository -eq 'melodic-software/ci-workflows' -and
($syncManaged -or $reference -cmatch '^melodic-software/ci-workflows/\.github/workflows/[A-Za-z0-9_.-]+\.ya?ml@main$')) {
continue
}
$location = "$($file.Name):$lineNumber"
if ($reference -notmatch '@(?<commit>[0-9a-f]{40})$' ) {
throw "$location pins $reference, not a full commit SHA"
Expand Down
Loading
Loading