@plainconceptsplatform/workflows 1.21.4 → 1.21.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -410,10 +410,18 @@ for line in "${candidates[@]}"; do
410
410
  continue
411
411
  fi
412
412
 
413
- meta=$(gh pr view "$pr" --repo "$REPO" --json reviewDecision,commits,closingIssuesReferences 2>/dev/null || echo '{}')
413
+ meta=$(gh pr view "$pr" --repo "$REPO" --json reviewDecision,commits,closingIssuesReferences,body 2>/dev/null || echo '{}')
414
414
  review_decision=$(jq -r '.reviewDecision // ""' <<<"$meta")
415
415
  head_committed=$(jq -r '[.commits[]?.committedDate] | max // ""' <<<"$meta")
416
416
  linked_issue=$(jq -r '.closingIssuesReferences[0].number // ""' <<<"$meta")
417
+ # GitHub links closing keywords only on pull requests into the default branch, so a stack
418
+ # child (into feat/N) has none. The gate reads `Closes #N` from the body instead
419
+ # (identify-gate-subject); the train must find the same issue, or it misses the attempt the
420
+ # gate recorded there, counts a failed gate as a silent one and never retries it.
421
+ if [ -z "$linked_issue" ]; then
422
+ linked_issue=$(jq -r '.body // ""' <<<"$meta" |
423
+ grep -oiE '(close[sd]?|fixe?[sd]?|resolve[sd]?) +#[0-9]+' | grep -oE '[0-9]+' | head -n 1 || true)
424
+ fi
417
425
 
418
426
  # The latest verdict on the pull request or its issue, and how many retries it has had.
419
427
  verdicts=$(
@@ -1951,6 +1951,11 @@ fi
1951
1951
  if ! grep -qF 'contains($prefix)' "$ROUTER_YML" || ! grep -qF 'REFINE_PREFIX: "Refinement update"' "$ROUTER_YML"; then
1952
1952
  LEAD_OK=0; echo "FAIL: the refine auto-accept must find the questions by refine's visible prefix, not only the stripped marker" >&2
1953
1953
  fi
1954
+ # A stack child (into feat/N) has no closingIssuesReferences; the train must read `Closes #N` from the body like the
1955
+ # gate does, or a failed gate's attempt on the issue is invisible and the child is parked as a silent gate forever.
1956
+ if [ -f "${HERE}/../merge-train/merge-train.sh" ] && ! grep -qF "(close[sd]?|fixe?[sd]?|resolve[sd]?) +#[0-9]+" "${HERE}/../merge-train/merge-train.sh"; then
1957
+ LEAD_OK=0; echo "FAIL: the merge train must find a stack child's issue from 'Closes #N' in the body" >&2
1958
+ fi
1954
1959
  if [ "$LEAD_OK" -eq 1 ]; then PASS=$((PASS + 1)); else FAIL=$((FAIL + 1)); fi
1955
1960
  # The harness plugins only load with .opencode/node_modules installed; without it every CI run
1956
1961
  # spawned untiered workers on the session's model. And the tier model a worker pins has to be one
@@ -3744,6 +3749,10 @@ rc 'test-timings\.mjs' "$CI_DOTNET" 'the .NET template must summarise the test t
3744
3749
  SYNC_YML="${HERE}/../../templates/platform-template/.github/workflows/platform-template-sync.yml"
3745
3750
  rc '^ UV_SHA256: [0-9a-f]{64}$' "$SYNC_YML" 'the template sync must pin uv by SHA-256'
3746
3751
  rc 'sha256sum --check --strict' "$SYNC_YML" 'the template sync must check the uv download'
3752
+ # A conformance run that could not read the template must not pass as a comparison.
3753
+ rc 'compare\+=\(--require-source\)' "$CI_DOTNET" 'the conformance job must require the template when it has a token'
3754
+ rc 'create-github-app-token@[0-9a-f]{40}' "$CI_DOTNET" 'the conformance job must mint a token that reads the template'
3755
+ rc "requireSource \\? \\{ failures: \\[message\\]" "${HERE}/../../templates/platform-template/scripts/check-platform-conformance.mjs" 'check-platform-conformance must fail on an unread template with --require-source'
3747
3756
  rc "python3 -c 'import ensurepip'" "$SYNC_YML" 'the template sync must not try a venv where ensurepip is missing'
3748
3757
  if [ "$RC_OK" -eq 1 ]; then PASS=$((PASS + 1)); else FAIL=$((FAIL + 1)); fi
3749
3758
 
@@ -33,6 +33,12 @@ on:
33
33
  secrets:
34
34
  NPM_REGISTRY_TOKEN:
35
35
  required: false
36
+ # The bot App, for the platform conformance job to read the template repository when it is
37
+ # private. A deploy pipeline passes them; without them the owned files are not compared.
38
+ BOT_APP_ID:
39
+ required: false
40
+ BOT_PRIVATE_KEY:
41
+ required: false
36
42
 
37
43
  permissions:
38
44
  contents: read
@@ -518,17 +524,34 @@ jobs:
518
524
  name: Platform conformance
519
525
  runs-on: ${{ vars.CI_RUNNER || 'agents-arc' }}
520
526
  timeout-minutes: 5
527
+ env:
528
+ HAS_BOT_APP: ${{ secrets.BOT_APP_ID != '' && secrets.BOT_PRIVATE_KEY != '' }}
521
529
  steps:
522
530
  - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
523
531
  with:
524
532
  fetch-depth: 0
533
+ # The template repository is usually private, and GITHUB_TOKEN reads only this one. Without a
534
+ # token the comparison could not run and the job still said the owned files matched.
535
+ - name: Token that reads the platform template
536
+ id: app-token
537
+ if: env.HAS_BOT_APP == 'true'
538
+ uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
539
+ with:
540
+ app-id: ${{ secrets.BOT_APP_ID }}
541
+ private-key: ${{ secrets.BOT_PRIVATE_KEY }}
542
+ owner: ${{ github.repository_owner }}
525
543
  - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
526
544
  with:
527
545
  node-version: ${{ env.NODE_VERSION }}
546
+ # The token reaches git through process-scoped config only, never a file on the runner.
528
547
  - name: Owned files change only through a template sync
529
548
  env:
530
549
  EVENT: ${{ github.event_name }}
531
550
  BASE_REF: ${{ github.base_ref }}
551
+ GIT_CONFIG_COUNT: ${{ steps.app-token.outputs.token != '' && '1' || '0' }}
552
+ GIT_CONFIG_KEY_0: url.https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/.insteadOf
553
+ GIT_CONFIG_VALUE_0: https://github.com/
554
+ HAS_TOKEN: ${{ steps.app-token.outputs.token != '' }}
532
555
  run: |
533
556
  set -euo pipefail
534
557
  if [ ! -f .platform/contract.yml ] && { [ ! -f .copier-answers.yml ] || [ ! -f .platform/manifest ]; }; then
@@ -539,11 +562,19 @@ jobs:
539
562
  echo "::error::This repository has a platform contract but no scripts/check-platform-conformance.mjs. Install it with: npx @plainconceptsplatform/workflows add --template platform-template"
540
563
  exit 1
541
564
  fi
565
+ # With a token the template must be read; without one (Dependabot, a caller that passes no
566
+ # secrets) the job still checks for changes outside a sync, and says it did not compare.
567
+ compare=(--compare)
568
+ if [ "$HAS_TOKEN" = true ]; then
569
+ compare+=(--require-source)
570
+ else
571
+ echo "::warning::No bot App token in this run, so the owned files were not compared with the template. Pass BOT_APP_ID and BOT_PRIVATE_KEY to this workflow."
572
+ fi
542
573
  if [ "$EVENT" = pull_request ]; then
543
574
  git fetch origin "$BASE_REF"
544
- node scripts/check-platform-conformance.mjs --compare --base "origin/$BASE_REF" | tee -a "$GITHUB_STEP_SUMMARY"
575
+ node scripts/check-platform-conformance.mjs "${compare[@]}" --base "origin/$BASE_REF" | tee -a "$GITHUB_STEP_SUMMARY"
545
576
  else
546
- node scripts/check-platform-conformance.mjs --compare | tee -a "$GITHUB_STEP_SUMMARY"
577
+ node scripts/check-platform-conformance.mjs "${compare[@]}" | tee -a "$GITHUB_STEP_SUMMARY"
547
578
  fi
548
579
 
549
580
  secret-scan:
@@ -3,10 +3,11 @@
3
3
  // Keeps the paths a platform contract (.platform/contract.yml) marks as `owned` equal to the template
4
4
  // they come from. A pull request may change them only in a template sync (it changes `sync.marker` or
5
5
  // moves `sync.version`) or under an unexpired exception; conflict markers and expired exceptions fail.
6
- // With --compare, owned files are also compared with `source.url` at the recorded version.
6
+ // With --compare, owned files are also compared with `source.url` at the recorded version; with
7
+ // --require-source as well, a template it cannot read is a failure rather than a note.
7
8
  // Without a contract it passes silently. .copier-answers.yml + .platform/manifest is read as one.
8
9
  //
9
- // Usage: node scripts/check-platform-conformance.mjs [--base <git ref>] [--compare]
10
+ // Usage: node scripts/check-platform-conformance.mjs [--base <git ref>] [--compare [--require-source]]
10
11
  // node scripts/check-platform-conformance.mjs --contract (key=value lines for $GITHUB_OUTPUT)
11
12
 
12
13
  import { execFileSync } from 'node:child_process';
@@ -321,7 +322,7 @@ function sourceBlobs(url, version) {
321
322
  }
322
323
  }
323
324
 
324
- function compareWithSource(root, contract, patterns, live, version) {
325
+ function compareWithSource(root, contract, patterns, live, version, requireSource = false) {
325
326
  const failures = [];
326
327
  const notes = [];
327
328
  const { name, url, changes } = contract.source;
@@ -331,7 +332,8 @@ function compareWithSource(root, contract, patterns, live, version) {
331
332
  source = sourceBlobs(url, version);
332
333
  } catch (error) {
333
334
  const reason = String(error.stderr ?? error.message).trim().split('\n').at(-1);
334
- return { failures, notes: [`cannot read ${url} at ${version} (${reason}); owned files were not compared with the source`] };
335
+ const message = `cannot read ${url} at ${version} (${reason}); owned files were not compared with the source`;
336
+ return requireSource ? { failures: [message], notes, compared: false } : { failures, notes: [message], compared: false };
335
337
  }
336
338
  const local = blobIds(git(root, ['ls-files', '-s', '-z']), 1);
337
339
  for (const [path, id] of source) {
@@ -343,10 +345,10 @@ function compareWithSource(root, contract, patterns, live, version) {
343
345
  }
344
346
  const onlyHere = [...local.keys()].filter((path) => isOwned(patterns, path) && !source.has(path));
345
347
  if (onlyHere.length > 0) notes.push(`${onlyHere.length} owned file(s) are not in ${name} at ${version} under the same path; not compared`);
346
- return { failures, notes };
348
+ return { failures, notes, compared: true };
347
349
  }
348
350
 
349
- export function checkConformance(root, { base, compare = false, today = new Date().toISOString().slice(0, 10) } = {}) {
351
+ export function checkConformance(root, { base, compare = false, requireSource = false, today = new Date().toISOString().slice(0, 10) } = {}) {
350
352
  const read = (path) => (existsSync(join(root, path)) ? readFileSync(join(root, path), 'utf8') : undefined);
351
353
  let contract;
352
354
  try {
@@ -395,12 +397,14 @@ export function checkConformance(root, { base, compare = false, today = new Date
395
397
  }
396
398
  }
397
399
  }
400
+ let compared;
398
401
  if (compare) {
399
- const result = compareWithSource(root, contract, patterns, live, version);
402
+ const result = compareWithSource(root, contract, patterns, live, version, requireSource);
400
403
  failures.push(...result.failures);
401
404
  notes.push(...result.notes);
405
+ compared = result.compared;
402
406
  }
403
- return { adopted: true, failures, notes };
407
+ return { adopted: true, failures, notes, compared };
404
408
  }
405
409
 
406
410
  // One key=value line per field, for $GITHUB_OUTPUT; contract=absent when there is none.
@@ -428,9 +432,9 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
428
432
  const args = process.argv.slice(2);
429
433
  const baseIndex = args.indexOf('--base');
430
434
  const base = baseIndex === -1 ? undefined : args[baseIndex + 1];
431
- const unknown = args.filter((arg, i) => i !== baseIndex + 1 || baseIndex === -1).filter((arg) => !['--base', '--compare', '--contract'].includes(arg));
435
+ const unknown = args.filter((arg, i) => i !== baseIndex + 1 || baseIndex === -1).filter((arg) => !['--base', '--compare', '--require-source', '--contract'].includes(arg));
432
436
  if ((baseIndex !== -1 && !base) || unknown.length > 0) {
433
- console.error('usage: node scripts/check-platform-conformance.mjs [--base <git ref>] [--compare] | --contract');
437
+ console.error('usage: node scripts/check-platform-conformance.mjs [--base <git ref>] [--compare [--require-source]] | --contract');
434
438
  process.exit(2);
435
439
  }
436
440
  const root = fileURLToPath(new URL('..', import.meta.url));
@@ -444,10 +448,11 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
444
448
  process.exit(1);
445
449
  }
446
450
  }
447
- const { adopted, failures, notes } = checkConformance(root, { base, compare: args.includes('--compare') });
451
+ const { adopted, failures, notes, compared } = checkConformance(root, { base, compare: args.includes('--compare'), requireSource: args.includes('--require-source') });
448
452
  if (!adopted) process.exit(0);
449
453
  for (const note of notes) console.log(`· ${note}`);
450
454
  for (const failure of failures) console.error(`✗ ${failure}`);
451
- if (failures.length === 0) console.log('✓ owned files match the template');
455
+ // Only a comparison that ran may say the files match: an unread template proves nothing.
456
+ if (failures.length === 0) console.log(compared === false ? '✓ no owned file changed outside a template sync (not compared with the template)' : '✓ owned files match the template');
452
457
  process.exit(failures.length === 0 ? 0 : 1);
453
458
  }
@@ -120,7 +120,10 @@ jobs:
120
120
  # The tag above was created with GITHUB_TOKEN, so its push starts no workflow: a release does
121
121
  # not ship by itself. A workflow_dispatch is the exception GitHub allows that token, so a
122
122
  # release that asked for a deploy starts DEPLOY_WORKFLOW on the tag explicitly. The deploy
123
- # workflow's own `pro` environment rules (required reviewers) still apply.
123
+ # workflow's own `pro` environment rules (required reviewers) still apply. The tagged commit is
124
+ # the one the release pull request just merged, so its main run is usually still building PRE:
125
+ # the platform template's deploy waits for that run, skips the CI it passed and promotes its
126
+ # image, rather than test the same commit again.
124
127
  - name: Deploy the release to production
125
128
  if: steps.release.outputs.deploy == 'true'
126
129
  env:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plainconceptsplatform/workflows",
3
- "version": "1.21.4",
3
+ "version": "1.21.6",
4
4
  "description": "Install and update Platform GitHub agentic workflows.",
5
5
  "keywords": [
6
6
  "github-actions",