Files
sim/.github/workflows/companion.yml
T
dependabot[bot] 20f581e36f ci: bump the actions group across 4 directories with 19 updates (#8789)
Bumps the actions group with 14 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `6.0.3` | `7.0.1` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.6.2` | `7.0.1` |
| [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) | `6.2.0` | `6.3.0` |
| [aws-actions/amazon-ecr-login](https://github.com/aws-actions/amazon-ecr-login) | `2.1.6` | `2.1.7` |
| [docker/login-action](https://github.com/docker/login-action) | `4.2.0` | `4.6.0` |
| [anchore/sbom-action](https://github.com/anchore/sbom-action) | `0.24.2` | `0.24.3` |
| [dorny/paths-filter](https://github.com/dorny/paths-filter) | `4.0.1` | `4.0.3` |
| [actions/github-script](https://github.com/actions/github-script) | `7.1.0` | `9.0.0` |
| [actions/cache](https://github.com/actions/cache) | `5.0.5` | `6.1.0` |
| [actions/setup-node](https://github.com/actions/setup-node) | `6.4.0` | `7.0.0` |
| [azure/setup-helm](https://github.com/azure/setup-helm) | `4.3.1` | `5.0.1` |
| [helm/kind-action](https://github.com/helm/kind-action) | `1.14.0` | `1.15.0` |
| [oras-project/setup-oras](https://github.com/oras-project/setup-oras) | `2.0.1` | `2.0.2` |
| [actions/setup-python](https://github.com/actions/setup-python) | `5.6.0` | `7.0.0` |

Bumps the actions group with 2 updates in the /.github/actions/cache directory: [actions/cache](https://github.com/actions/cache) and [useblacksmith/stickydisk](https://github.com/useblacksmith/stickydisk).
Bumps the actions group with 4 updates in the /.github/actions/image directory: [useblacksmith/setup-docker-builder](https://github.com/useblacksmith/setup-docker-builder), [useblacksmith/build-push-action](https://github.com/useblacksmith/build-push-action), [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) and [docker/build-push-action](https://github.com/docker/build-push-action).
Bumps the actions group with 1 update in the /.github/actions/setup directory: [actions/setup-node](https://github.com/actions/setup-node).


Updates `actions/checkout` from 6.0.3 to 7.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/df4cb1c069e1874edd31b4311f1884172cec0e10...3d3c42e5aac5ba805825da76410c181273ba90b1)

Updates `actions/upload-artifact` from 4.6.2 to 7.0.1
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/ea165f8d65b6e75b540449e92b4886f43607fa02...043fb46d1a93c77aae656e7c1c64a875d1fc6a0a)

Updates `aws-actions/configure-aws-credentials` from 6.2.0 to 6.3.0
- [Release notes](https://github.com/aws-actions/configure-aws-credentials/releases)
- [Changelog](https://github.com/aws-actions/configure-aws-credentials/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws-actions/configure-aws-credentials/compare/e7f100cf4c008499ea8adda475de1042d6975c7b...e1253824e5c10ff9df46874f81ed3ec929e19cfd)

Updates `aws-actions/amazon-ecr-login` from 2.1.6 to 2.1.7
- [Release notes](https://github.com/aws-actions/amazon-ecr-login/releases)
- [Changelog](https://github.com/aws-actions/amazon-ecr-login/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws-actions/amazon-ecr-login/compare/d539f0932e70871a027e9d5a9d8fc38589180a64...03f1aad4c6c7ffd436567f42f9384779290529bd)

Updates `docker/login-action` from 4.2.0 to 4.6.0
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/650006c6eb7dba73a995cc03b0b2d7f5ca915bee...dbcb813823bdd20940b903addbd779551569679f)

Updates `anchore/sbom-action` from 0.24.2 to 0.24.3
- [Release notes](https://github.com/anchore/sbom-action/releases)
- [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md)
- [Commits](https://github.com/anchore/sbom-action/compare/3ad7283483fc7af8ff2b4ea19663c2d5ca935e26...66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c)

Updates `dorny/paths-filter` from 4.0.1 to 4.0.3
- [Release notes](https://github.com/dorny/paths-filter/releases)
- [Changelog](https://github.com/dorny/paths-filter/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dorny/paths-filter/compare/fbd0ab8f3e69293af611ebaee6363fc25e6d187d...ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d)

Updates `actions/github-script` from 7.1.0 to 9.0.0
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/f28e40c7f34bde8b3046d885e986cb6290c5673b...3a2844b7e9c422d3c10d287c895573f7108da1b3)

Updates `actions/cache` from 5.0.5 to 6.1.0
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/27d5ce7f107fe9357f9df03efb73ab90386fccae...55cc8345863c7cc4c66a329aec7e433d2d1c52a9)

Updates `actions/setup-node` from 6.4.0 to 7.0.0
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e...820762786026740c76f36085b0efc47a31fe5020)

Updates `azure/setup-helm` from 4.3.1 to 5.0.1
- [Release notes](https://github.com/azure/setup-helm/releases)
- [Changelog](https://github.com/Azure/setup-helm/blob/main/CHANGELOG.md)
- [Commits](https://github.com/azure/setup-helm/compare/1a275c3b69536ee54be43f2070a358922e12c8d4...9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310)

Updates `helm/kind-action` from 1.14.0 to 1.15.0
- [Release notes](https://github.com/helm/kind-action/releases)
- [Commits](https://github.com/helm/kind-action/compare/ef37e7f390d99f746eb8b610417061a60e82a6cc...06c1ae10762d3b9c1644e7fe69596ae519e015a2)

Updates `oras-project/setup-oras` from 2.0.1 to 2.0.2
- [Release notes](https://github.com/oras-project/setup-oras/releases)
- [Commits](https://github.com/oras-project/setup-oras/compare/1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d...005458ad77f1c8facd38a094e4af2e69e5607ff4)

Updates `actions/setup-python` from 5.6.0 to 7.0.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/a26af69be951a213d495a4c3e4e4022e16d87065...5fda3b95a4ea91299a34e894583c3862153e4b97)

Updates `actions/cache` from 5.0.5 to 6.1.0
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/27d5ce7f107fe9357f9df03efb73ab90386fccae...55cc8345863c7cc4c66a329aec7e433d2d1c52a9)

Updates `useblacksmith/stickydisk` from 4c034ba57b706cf0e3b4b0ce098c2a3b1071580c to 3f6be1451e3cad893b778bc93495c80452a5da26
- [Release notes](https://github.com/useblacksmith/stickydisk/releases)
- [Commits](https://github.com/useblacksmith/stickydisk/compare/4c034ba57b706cf0e3b4b0ce098c2a3b1071580c...3f6be1451e3cad893b778bc93495c80452a5da26)

Updates `useblacksmith/setup-docker-builder` from 2.1.0 to 2.2.0
- [Release notes](https://github.com/useblacksmith/setup-docker-builder/releases)
- [Commits](https://github.com/useblacksmith/setup-docker-builder/compare/a5256a73e30f09e37e3eceb8ca36043d17621d24...19215110ab936351210feebdfa5b440b4493e184)

Updates `useblacksmith/build-push-action` from 2.2.0 to 2.3.0
- [Release notes](https://github.com/useblacksmith/build-push-action/releases)
- [Commits](https://github.com/useblacksmith/build-push-action/compare/fb9e3e6a9299c78462bfadd0d93352c316adc9b8...9b0579bbec7a6cad2f171596c57e7ac1e7658850)

Updates `docker/setup-buildx-action` from 4.2.0 to 4.4.1
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/bb05f3f5519dd87d3ba754cc423b652a5edd6d2c...f87e5991a6d7451dcb8d9637bfbc97413f497069)

Updates `docker/build-push-action` from 7.3.0 to 7.4.0
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/53b7df96c91f9c12dcc8a07bcb9ccacbed38856a...c3c9e263c25d99ce0380d002d59b67737d91b0dc)

Updates `actions/setup-node` from 6.4.0 to 7.0.0
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e...820762786026740c76f36085b0efc47a31fe5020)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: aws-actions/configure-aws-credentials
  dependency-version: 6.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: aws-actions/amazon-ecr-login
  dependency-version: 2.1.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: docker/login-action
  dependency-version: 4.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: anchore/sbom-action
  dependency-version: 0.24.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: dorny/paths-filter
  dependency-version: 4.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/github-script
  dependency-version: 9.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/cache
  dependency-version: 6.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/setup-node
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: azure/setup-helm
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: helm/kind-action
  dependency-version: 1.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: oras-project/setup-oras
  dependency-version: 2.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/setup-python
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/cache
  dependency-version: 6.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: useblacksmith/stickydisk
  dependency-version: 3f6be1451e3cad893b778bc93495c80452a5da26
  dependency-type: direct:production
  dependency-group: actions
- dependency-name: useblacksmith/setup-docker-builder
  dependency-version: 2.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: useblacksmith/build-push-action
  dependency-version: 2.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: docker/setup-buildx-action
  dependency-version: 4.4.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: docker/build-push-action
  dependency-version: 7.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: actions/setup-node
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-07 23:47:38 -07:00

221 lines
12 KiB
YAML

name: companion
# Soft, NON-BLOCKING warning: when a PR targeting staging/main declares a
# cross-repo "Companion:" PR, surface whether that companion is merged yet, so
# copilot and sim stay in lockstep (a change in one often needs the other).
#
# Declare in a PR description (repeatable; shorthand OR full URL both parse):
# Companion: simstudioai/sim#1234
# Companion: https://github.com/simstudioai/sim/pull/1234
#
# Requires a CROSS_REPO_TOKEN secret (fine-grained PAT with pull-requests:read on
# BOTH repos) to read the other repo's PR state. Without it the check still
# surfaces the declared link but reports "couldn't verify".
on:
# PR-driven only: runs on the one PR being opened/edited/synced — no periodic
# bulk scan. We assume companions are declared on BOTH sides, so the per-PR
# trigger keeps each side's status fresh; to refresh after a companion merges,
# re-edit the PR (or run this workflow manually via the Actions tab).
pull_request:
types: [opened, edited, reopened, synchronize]
branches: [staging, main]
workflow_dispatch: {}
# One live run per PR: a newer opened/edited/synchronize event supersedes the
# previous run's work entirely (the sticky comment/label upsert is idempotent
# and only the latest body matters), so cancel in-flight runs instead of
# letting them race the new one. workflow_dispatch bulk scans get a unique
# group via run_id and are never cancelled. No paths filter on purpose: the
# check reads the PR body and cross-repo PR state, not changed files, so a
# paths filter would both be semantically wrong and stop status refreshes.
concurrency:
group: companion-pr-check-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
pull-requests: write
issues: write
contents: read
jobs:
companion:
name: companion
runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 5
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
CROSS_REPO_TOKEN: ${{ secrets.CROSS_REPO_TOKEN }}
with:
script: |
const STICKY = '<!-- companion-pr-check -->';
const { owner, repo } = context.repo;
// Directional label: copilot/mothership PRs get "requires-sim-merge",
// sim PRs get "requires-mothership-merge". Applied whenever the PR
// declares a companion; removed when it declares none.
const otherSide = repo === 'sim' ? 'mothership/copilot' : 'sim';
const LABEL = repo === 'sim' ? 'requires-mothership-merge' : 'requires-sim-merge';
const LABEL_DESC = `Has a companion PR on the ${otherSide} side — merge in lockstep`;
const crossToken = process.env.CROSS_REPO_TOKEN;
// Read the OTHER repo's PR via a plain REST fetch with the PAT in the
// header — keeps the PAT strictly READ-ONLY and avoids re-instantiating
// Octokit inside github-script (which can't require('@actions/github')).
// Commenting/labeling uses the default GITHUB_TOKEN via `github`.
async function crossGetPR(c) {
const res = await fetch(`https://api.github.com/repos/${c.owner}/${c.repo}/pulls/${c.number}`, {
headers: {
authorization: `Bearer ${crossToken}`,
accept: 'application/vnd.github+json',
'x-github-api-version': '2022-11-28',
'user-agent': 'companion-pr-check',
},
});
if (!res.ok) { const e = new Error(`HTTP ${res.status}`); e.status = res.status; throw e; }
return res.json();
}
// Two ways to declare a companion (either works; both feed this warning):
// 1) a trailer anywhere: Companion: owner/repo#N (or a full PR URL)
// 2) refs in a task list under a "## Companion..." heading — which ALSO
// renders a native live badge + progress bar on the PR (the "both" path):
// ## Companion PRs
// - [ ] owner/repo#N
// Regexes are local + matchAll, so there's no shared lastIndex state to leak
// between calls (stateless by construction).
function parseCompanions(body) {
body = body || '';
const TRAILER = /Companion:\s*(?:https?:\/\/github\.com\/)?([\w.-]+)\/([\w.-]+)(?:\/pull\/|#)(\d+)/gi;
const REF = /(?:https?:\/\/github\.com\/)?([\w.-]+)\/([\w.-]+)(?:\/pull\/|#)(\d+)/g;
const out = [];
const seen = new Set();
const add = (o, r, n) => {
const ref = `${o}/${r}#${n}`;
if (seen.has(ref)) return;
seen.add(ref);
out.push({ owner: o, repo: r, number: Number(n), ref });
};
// (1) "Companion:" trailers anywhere in the body.
for (const m of body.matchAll(TRAILER)) add(m[1], m[2], m[3]);
// (2) refs in a task list under a "## Companion..." heading, until the next heading.
let inSection = false;
for (const line of body.split(/\r?\n/)) {
if (/^#{1,6}\s/.test(line)) { inSection = /^#{1,6}\s*companion/i.test(line); continue; }
if (!inSection) continue;
for (const mm of line.matchAll(REF)) add(mm[1], mm[2], mm[3]);
}
return out;
}
async function findSticky(prNumber) {
const comments = await github.paginate(github.rest.issues.listComments, {
owner, repo, issue_number: prNumber, per_page: 100,
});
return comments.find((c) => (c.body || '').includes(STICKY));
}
async function upsert(prNumber, body) {
const ex = await findSticky(prNumber);
if (ex) await github.rest.issues.updateComment({ owner, repo, comment_id: ex.id, body });
else await github.rest.issues.createComment({ owner, repo, issue_number: prNumber, body });
}
async function clear(prNumber) {
const ex = await findSticky(prNumber);
if (ex) await github.rest.issues.deleteComment({ owner, repo, comment_id: ex.id });
// Drop the label too, so a PR edited to remove all companions doesn't
// keep a stale badge. 404 (not present) is expected; surface anything else.
try { await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: LABEL }); }
catch (e) { if (e.status !== 404) core.warning(`companion: removeLabel ${LABEL} on #${prNumber} failed (${e.status || e.message})`); }
}
async function ensureLabel() {
try { await github.rest.issues.getLabel({ owner, repo, name: LABEL }); return; }
catch (e) { if (e.status && e.status !== 404) { core.warning(`companion: getLabel ${LABEL} failed (${e.status})`); return; } }
// 404 → label doesn't exist yet, create it. 422 = another run beat us (fine).
try { await github.rest.issues.createLabel({ owner, repo, name: LABEL, color: 'd93f0b', description: LABEL_DESC }); }
catch (e) { if (e.status !== 422) core.warning(`companion: createLabel ${LABEL} failed (${e.status || e.message})`); }
}
// staging PRs are a single feature → just this PR's body ("the one").
// main (prod) release PRs bundle MANY feature PRs → aggregate the
// companions declared on each squashed feature PR too, so "does any
// commit in this release have a companion?" is answered.
async function collectCompanions(pr) {
const companions = parseCompanions(pr.body);
const seen = new Set(companions.map((c) => c.ref));
if (pr.base.ref === 'main') {
let commits = [];
try {
commits = await github.paginate(github.rest.pulls.listCommits, {
owner, repo, pull_number: pr.number, per_page: 100,
});
} catch {}
const featurePRs = new Set();
const SQUASH = /\(#(\d+)\)/g; // squash-merge refs like "...(#306)"
for (const c of commits) {
const msg = (c.commit && c.commit.message) || '';
let m;
SQUASH.lastIndex = 0;
while ((m = SQUASH.exec(msg)) !== null) featurePRs.add(Number(m[1]));
}
for (const n of featurePRs) {
if (n === pr.number) continue;
try {
const { data: fpr } = await github.rest.pulls.get({ owner, repo, pull_number: n });
for (const c of parseCompanions(fpr.body)) {
if (!seen.has(c.ref)) { seen.add(c.ref); companions.push(c); }
}
} catch {}
}
}
return companions;
}
async function checkPR(pr) {
const companions = await collectCompanions(pr);
if (companions.length === 0) { await clear(pr.number); return; }
await ensureLabel();
try { await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: [LABEL] }); }
catch (e) { core.warning(`companion: addLabels ${LABEL} on #${pr.number} failed (${e.status || e.message})`); }
const base = pr.base.ref;
const lines = [];
let warn = false;
for (const c of companions) {
if (!crossToken) {
lines.push(`- ❓ \`${c.ref}\` — set the **CROSS_REPO_TOKEN** secret to verify merge status`);
warn = true;
continue;
}
try {
const cp = await crossGetPR(c);
const title = (cp.title || '').slice(0, 80);
if (cp.merged) {
const tierOk = cp.base.ref === base;
lines.push(`- ${tierOk ? '✅' : '⚠️'} [\`${c.ref}\`](${cp.html_url}) — merged into \`${cp.base.ref}\`${tierOk ? '' : ` (this PR targets \`${base}\`)`} — ${title}`);
if (!tierOk) warn = true;
} else {
lines.push(`- ❌ [\`${c.ref}\`](${cp.html_url}) — **${String(cp.state).toUpperCase()}, not merged** (targets \`${cp.base.ref}\`) — ${title}`);
warn = true;
}
} catch (e) {
lines.push(`- ❓ \`${c.ref}\` — couldn't read (${e.status || e.message}); check CROSS_REPO_TOKEN scope`);
warn = true;
}
}
const heading = warn ? '## ⚠️ Cross-repo companion check' : '## ✅ Cross-repo companion check';
const scope = base === 'main' ? ' (aggregated across the feature PRs in this release)' : '';
const note = warn
? `One or more companion PRs aren't merged into \`${base}\` yet${scope}. Merging this without them will leave copilot and sim out of sync — merge them in lockstep.`
: `All declared companion PRs are merged into \`${base}\`${scope}.`;
await upsert(pr.number, `${STICKY}\n${heading}\n\n${note}\n\n${lines.join('\n')}`);
}
if (context.eventName === 'pull_request') {
await checkPR(context.payload.pull_request);
} else {
// workflow_dispatch only: manual full re-scan of open staging/main PRs.
for (const b of ['staging', 'main']) {
const prs = await github.paginate(github.rest.pulls.list, { owner, repo, base: b, state: 'open', per_page: 100 });
for (const pr of prs) await checkPR(pr);
}
}