An open source design system that's fully customizable and agent ready
TypeScript
ci: the Swift check names a run CI admission turned away (#10459)
Cindy Zhanga19d45a5dd92
diff --git a/.github/scripts/ci-native-swift.test.mjs b/.github/scripts/ci-native-swift.test.mjsindex 5fc0486465..9564d63b3a 100644--- a/.github/scripts/ci-native-swift.test.mjs+++ b/.github/scripts/ci-native-swift.test.mjs@@ -59,7 +59,11 @@ describe('native Swift routing', () => {expect(runner.steps.find(s => s.id === 'scope').uses).toBe('./.test-scope/.github/actions/test-scope',);- expect(swift.needs).toEqual(['heavy-ci', 'native-swift-runner']);+ expect(swift.needs).toEqual([+ 'admission',+ 'heavy-ci',+ 'native-swift-runner',+ ]);expect(swift['runs-on']).toBe(`\${{ ${applies} && 'macos-15' || 'ubuntu-slim' }}`,);@@ -72,11 +76,12 @@ describe('native Swift routing', () => {it('fails closed when the runner cannot be decided', () => {expect(step(swift, 'Require a decided Swift runner').if).toBe(- "needs.native-swift-runner.result != 'success'",+ "needs.admission.result != 'failure' && needs.native-swift-runner.result != 'success'",);for (const candidate of swift.steps) {if ([+ 'Stop when CI admission refused the run','Require a decided Swift runner','Skip Swift work outside its scope',].includes(candidate.name)@@ -87,6 +92,43 @@ describe('native Swift routing', () => {}});+ it('fails a run CI admission turned away with that reason, not as a Swift failure', () => {+ const refused = step(swift, 'Stop when CI admission refused the run');+ expect(swift.steps[0]).toBe(refused);+ expect(refused.if).toBe("needs.admission.result == 'failure'");+ expect(refused.run).toContain(+ 'CI admission refused this run (CI full); re-run all jobs.',+ );+ expect(refused.run).toContain('exit 1');+ // Admission's own stop is the failure this step reads.+ expect(+ ci.jobs.admission.steps.filter(s =>+ /Stop when CI is full/.test(s.name ?? ''),+ ),+ ).toHaveLength(2);+ // Each runs alone: a refused run gets one message, and a decided run+ // never gets the admission one.+ const evaluate = (condition, admission, runner) =>+ Function(+ 'needs',+ `return (${condition});`,+ )({+ admission: {result: admission},+ 'native-swift-runner': {result: runner},+ });+ const decided = step(swift, 'Require a decided Swift runner');+ const asJs = condition =>+ condition.replace(+ /needs\.native-swift-runner/g,+ "needs['native-swift-runner']",+ );+ expect(evaluate(asJs(refused.if), 'failure', 'skipped')).toBe(true);+ expect(evaluate(asJs(decided.if), 'failure', 'skipped')).toBe(false);+ expect(evaluate(asJs(refused.if), 'success', 'failure')).toBe(false);+ expect(evaluate(asJs(decided.if), 'success', 'failure')).toBe(true);+ expect(evaluate(asJs(decided.if), 'success', 'success')).toBe(false);+ });+it('keeps its own steps in scope, so changing them runs them', () => {expect(step(swift, 'Build and test each native Swift package').run).toBe('bash .github/scripts/native-swift.sh',diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 462ad7f0cf..f6181e4233 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1196,7 +1196,7 @@ jobs:paths: '^packages/native/.*(\.swift|/Package\.swift)$|^\.github/scripts/native-swift\.sh$|^\.github/actions/test-scope/'test-native-swift:- needs: [heavy-ci, native-swift-runner]+ needs: [admission, heavy-ci, native-swift-runner]if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft && (github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run'))) && (!cancelled() && needs.heavy-ci.outputs.deferred != 'true' && (github.event_name != 'workflow_dispatch' && always() && !cancelled())) }}runs-on: ${{ needs.native-swift-runner.outputs.applies == 'true' && 'macos-15' || 'ubuntu-slim' }}# The slim branch only reports that Swift is out of scope; a slim job@@ -1205,8 +1205,16 @@ jobs:permissions:contents: readsteps:+ # A run CI admission turned away decides no runner either; say so, so the+ # required check fails with the true reason.+ - name: Stop when CI admission refused the run+ if: needs.admission.result == 'failure'+ run: |+ echo "::error title=CI is full::CI admission refused this run (CI full); re-run all jobs."+ exit 1+- name: Require a decided Swift runner- if: needs.native-swift-runner.result != 'success'+ if: needs.admission.result != 'failure' && needs.native-swift-runner.result != 'success'run: |echo "The Swift runner could not be decided; refusing to skip required work."exit 1