-
-
Notifications
You must be signed in to change notification settings - Fork 214
183 lines (153 loc) · 7.94 KB
/
Copy pathtest.yml
File metadata and controls
183 lines (153 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Tests
on:
pull_request:
branches: [dev]
push:
branches: [dev]
concurrency:
group: tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Classify test scope
runs-on: ubuntu-latest
outputs:
run_integration: ${{ steps.scope.outputs.run_integration }}
run_unit: ${{ steps.scope.outputs.run_unit }}
skip_reason: ${{ steps.scope.outputs.skip_reason }}
steps:
- name: Classify changed paths
id: scope
uses: actions/github-script@v9
with:
script: |
const eventName = context.eventName;
async function getChangedFiles() {
if (eventName === 'pull_request') {
const files = await github.paginate(github.rest.pulls.listFiles, {
owner : context.repo.owner,
repo : context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page : 100
});
return files.map(file => file.filename);
}
if (eventName === 'push') {
const before = context.payload.before;
const after = context.payload.after;
if (!before || !after || /^0+$/.test(before)) {
return null;
}
const comparison = await github.rest.repos.compareCommitsWithBasehead({
owner : context.repo.owner,
repo : context.repo.repo,
basehead: `${before}...${after}`,
per_page: 100
});
return comparison.data.files?.map(file => file.filename) || null;
}
return null;
}
const files = await getChangedFiles();
if (!files || files.length === 0) {
core.info('Changed files are unavailable; running full test suites.');
core.setOutput('run_integration', 'true');
core.setOutput('run_unit', 'true');
core.setOutput('skip_reason', 'changed files unavailable');
return;
}
const normalizedFiles = files.map(file => file.replace(/\\/g, '/'));
// Keep explicit unit/integration statuses on docs-only PRs instead of
// workflow-level paths-ignore. Missing checks can block protected branches.
const isDocsOnlyPath = file =>
file.endsWith('.md') ||
file.startsWith('learn/') ||
file.startsWith('resources/content/');
// Unit has committed content guards, notably the release-note mutable
// GitHub-link scan, discussion markdown fixture reads, and generated
// portal index fixtures.
const requiresUnitForContent = file =>
file.startsWith('resources/content/release-notes/') ||
file.startsWith('resources/content/discussions/') ||
file.startsWith('apps/portal/resources/data/');
// Whitelist: integration runs only on changes that can affect the integration
// stack — engine (src/), Agent OS (ai/, incl. ai/deploy compose), the integration
// specs/fixtures + shared test infra, dep manifests, or this workflow. Keep this
// COMPLETE — a missed path silently skips integration (false-negative).
const isIntegrationRelevantPath = file =>
file.startsWith('src/') ||
file.startsWith('ai/') ||
file.startsWith('test/playwright/integration/') ||
file.startsWith('test/playwright/util/') ||
file === 'test/playwright/fixtures.mjs' ||
file === 'test/playwright/setup.mjs' ||
file === 'test/playwright/playwright.config.integration.mjs' ||
file === 'package.json' ||
file === 'package-lock.json' ||
file === '.github/workflows/test.yml';
const runIntegration = normalizedFiles.some(isIntegrationRelevantPath);
const runUnit = normalizedFiles.some(file => !isDocsOnlyPath(file) || requiresUnitForContent(file));
core.info(`Changed files: ${normalizedFiles.join(', ')}`);
core.info(`run_integration=${runIntegration}`);
core.info(`run_unit=${runUnit}`);
core.setOutput('run_integration', String(runIntegration));
core.setOutput('run_unit', String(runUnit));
core.setOutput(
'skip_reason',
'change does not touch relevant paths for this suite (docs/content/config or unrelated test suite)'
);
test:
name: ${{ matrix.suite }}
runs-on: ubuntu-latest
needs: changes
strategy:
fail-fast: false
matrix:
# Bucket A-F audit (#10903) closed via #10907/#10921/#10910/#10919/#10920.
# Bucket G (#10924) substrate fixes landed via #10940 (TestLifecycleHelper
# primitive + daemon-spec migration) + open trackers for residual flakes
# (#10941/#10936/#10937/#10946 — all unit-skip-guarded via NEO_TEST_SKIP_CI).
suite: [integration-unified, unit]
steps:
- name: Checkout repository
if: ${{ (matrix.suite == 'integration-unified' && needs.changes.outputs.run_integration == 'true') || (matrix.suite == 'unit' && needs.changes.outputs.run_unit == 'true') }}
uses: actions/checkout@v6
- name: Setup Node.js
if: ${{ (matrix.suite == 'integration-unified' && needs.changes.outputs.run_integration == 'true') || (matrix.suite == 'unit' && needs.changes.outputs.run_unit == 'true') }}
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
# Pre-create .neo-ai-data so the `prepare` lifecycle's downloadKnowledgeBase
# short-circuits via its existing-dir guard. Integration tests use a tmpfs
# Chroma per `ai/deploy/docker-compose.test.yml`; unit tests are mocked.
# Neither suite needs the canonical KB artifact in CI.
- name: Skip Knowledge Base download in prepare lifecycle
if: ${{ (matrix.suite == 'integration-unified' && needs.changes.outputs.run_integration == 'true') || (matrix.suite == 'unit' && needs.changes.outputs.run_unit == 'true') }}
run: mkdir -p .neo-ai-data
- name: Install dependencies
if: ${{ (matrix.suite == 'integration-unified' && needs.changes.outputs.run_integration == 'true') || (matrix.suite == 'unit' && needs.changes.outputs.run_unit == 'true') }}
run: npm ci
# Required for the unit-test runner per bootstrapWorktree.mjs precedent.
# Harmless for the integration suite.
- name: Bundle parse5
if: ${{ (matrix.suite == 'integration-unified' && needs.changes.outputs.run_integration == 'true') || (matrix.suite == 'unit' && needs.changes.outputs.run_unit == 'true') }}
run: npm run bundle-parse5
- name: Skip ${{ matrix.suite }} tests
if: ${{ (matrix.suite == 'integration-unified' && needs.changes.outputs.run_integration != 'true') || (matrix.suite == 'unit' && needs.changes.outputs.run_unit != 'true') }}
run: |
echo "${{ matrix.suite }} skipped: ${{ needs.changes.outputs.skip_reason }}"
- name: Run ${{ matrix.suite }} tests
if: ${{ (matrix.suite == 'integration-unified' && needs.changes.outputs.run_integration == 'true') || (matrix.suite == 'unit' && needs.changes.outputs.run_unit == 'true') }}
run: npm run test-${{ matrix.suite }}
env:
NEO_INTEGRATION_STACK_TIMEOUT_MS: '240000'
# Keep the unit residual skip guards active without gating integration specs.
NEO_TEST_SKIP_CI: ${{ matrix.suite == 'unit' && 'true' || '' }}
- name: Upload test artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.suite }}-${{ github.run_id }}
path: test/playwright/test-results/
retention-days: 14