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
5 changes: 5 additions & 0 deletions .changeset/skip-storyboards-on-draft-prs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"adcontextprotocol": patch
---

Skip the training-agent storyboard CI matrix on draft pull requests and run it when a draft is marked ready for review. Push runs and non-draft PRs are unchanged, and so are storyboard selection and floors.
6 changes: 6 additions & 0 deletions .github/workflows/broken-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ on:
types:
- completed

# Cancel a PR's superseded run when a newer commit is pushed. Non-PR runs
# each get their own group (run_id), so they are never cancelled or evicted.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
broken-links:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ on:
schedule:
- cron: "0 0 * * 0"

# Cancel a PR's superseded analysis when a newer commit is pushed. Push and
# schedule runs each get their own group (run_id), so main-branch analyses are
# never cancelled or evicted.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
analyze:
name: Analyze
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/migration-smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ on:
- "server/tsconfig.json"
- "Dockerfile"

# Cancel a PR's superseded run when a newer commit is pushed. Non-PR runs
# each get their own group (run_id), so they are never cancelled or evicted.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
migrate:
name: Built migrations against Postgres
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
permissions:
contents: read

# Cancel a PR's superseded scan when a newer commit is pushed. Push runs each
# get their own group (run_id), so main-branch scans are never cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
semgrep:
name: Scan
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/training-agent-storyboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Training Agent Storyboards
on:
pull_request:
branches: [main, '3.2.x', '3.1.x', '3.0.x']
# Draft PRs skip this matrix (see the job-level `if`s): it is ~22 jobs and
# ~200 runner-minutes per push, about half of the repo's Actions minutes,
# against an org-wide hosted-runner concurrency cap. `ready_for_review`
# runs the full matrix when a draft is marked ready. This workflow is not
# a required check, so skipped draft runs never block a merge.
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'server/src/training-agent/**'
- 'server/src/services/hosted-compliance-version.ts'
Expand Down Expand Up @@ -49,6 +55,8 @@ concurrency:
jobs:
storyboards:
name: Storyboards (${{ matrix.surface }} /${{ matrix.tenant }})
# Skip draft PRs; push events have no pull_request payload and always run.
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
Expand Down Expand Up @@ -536,6 +544,7 @@ jobs:

sales_storyboard_orchestrators:
name: Sales storyboard orchestrator (${{ matrix.orchestrator }}/8)
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
Expand Down Expand Up @@ -606,7 +615,7 @@ jobs:

sales_storyboards:
name: Storyboards (current /sales)
if: always()
if: always() && github.event.pull_request.draft != true
needs: sales_storyboard_orchestrators
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down
42 changes: 42 additions & 0 deletions tests/ci-runner-demand-workflows.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, it, expect } from 'vitest';
import YAML from 'yaml';

// The org's hosted runners are capped at 60 concurrent jobs shared across
// every AAO repo. These guards keep the heaviest PR workflows from spending
// that capacity on drafts and superseded commits.
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const load = (name) => YAML.parse(fs.readFileSync(path.join(repoRoot, '.github/workflows', name), 'utf8'));

describe('training-agent-storyboards.yml draft skipping', () => {
const wf = load('training-agent-storyboards.yml');

it('re-runs when a draft is marked ready for review', () => {
expect(wf.on.pull_request.types).toEqual(['opened', 'synchronize', 'reopened', 'ready_for_review']);
});

it('skips every job on draft PRs', () => {
for (const [id, job] of Object.entries(wf.jobs)) {
expect(job.if, `${id} must skip drafts`).toContain('github.event.pull_request.draft != true');
}
});
});

describe.each([
['codeql.yml'],
['semgrep.yml'],
['broken-links.yml'],
['migration-smoke-test.yml'],
])('%s superseded-run cancellation', (name) => {
const wf = load(name);

it('cancels only pull_request runs, grouped per PR', () => {
expect(wf.concurrency['cancel-in-progress']).toBe("${{ github.event_name == 'pull_request' }}");
expect(wf.concurrency.group).toContain('github.event.pull_request.number');
// Non-PR runs (push to main, schedule, workflow_run) each get a unique
// group so they are never cancelled or evicted from a pending slot.
expect(wf.concurrency.group).toContain('github.run_id');
});
});
Loading