Skip to content

Commit ee062d2

Browse files
authored
🤖 ci: simplify change detection (#959)
The previous approach was brittle: 1. `docs-only` required checking that multiple filters were false, breaking silently when new categories were added 2. `browser-only` had the same problem, plus the negation pattern `!tests/e2e/**` matched ALL non-e2e files due to dorny/paths-filter's OR logic **Root cause of #958:** The negation `!tests/e2e/**` returns `true` for any path NOT under `tests/e2e/`, so browser files like `src/browser/components/VimTextArea.tsx` triggered `backend=true`. **New approach uses additive checks:** - Run tests/builds when `src == true || config == true` - Skip backend tests (ipc, runtime) when `backend != true` This is robust to new file categories - if something needs testing, add it to `src` or `config`. The filters only list what they care about, not what they want to exclude. Also removed unused `docs` and `browser` filters. --- _Generated with `mux`_
1 parent 3601a2e commit ee062d2

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

.github/workflows/pr.yml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,26 @@ jobs:
2121
name: Detect Changes
2222
runs-on: ubuntu-latest
2323
outputs:
24-
docs-only: ${{ steps.filter.outputs.docs == 'true' && steps.filter.outputs.src == 'false' && steps.filter.outputs.config == 'false' }}
25-
browser-only: ${{ steps.filter.outputs.browser == 'true' && steps.filter.outputs.backend == 'false' && steps.filter.outputs.config == 'false' }}
24+
src: ${{ steps.filter.outputs.src }}
25+
config: ${{ steps.filter.outputs.config }}
26+
backend: ${{ steps.filter.outputs.backend }}
2627
steps:
2728
- uses: actions/checkout@v4
2829
- uses: dorny/paths-filter@v3
2930
id: filter
3031
with:
3132
filters: |
32-
docs:
33-
- 'docs/**'
34-
- '*.md'
35-
- 'LICENSE'
36-
- '.vscode/**'
3733
src:
3834
- 'src/**'
3935
- 'tests/**'
4036
- 'vscode/**'
41-
browser:
42-
- 'src/browser/**'
43-
- 'src/styles/**'
44-
- '**/*.stories.tsx'
45-
- '.storybook/**'
4637
backend:
4738
- 'src/node/**'
4839
- 'src/cli/**'
4940
- 'src/desktop/**'
5041
- 'src/common/**'
51-
- 'tests/**'
52-
- '!tests/e2e/**'
42+
- 'tests/ipc/**'
43+
- 'tests/runtime/**'
5344
config:
5445
- '.github/**'
5546
- 'jest.config.cjs'
@@ -91,7 +82,7 @@ jobs:
9182
test-unit:
9283
name: Test / Unit
9384
needs: [changes]
94-
if: ${{ needs.changes.outputs.docs-only != 'true' }}
85+
if: ${{ needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true' }}
9586
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
9687
steps:
9788
- uses: actions/checkout@v4
@@ -110,7 +101,7 @@ jobs:
110101
test-integration:
111102
name: Test / Integration
112103
needs: [changes]
113-
if: ${{ needs.changes.outputs.docs-only != 'true' }}
104+
if: ${{ needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true' }}
114105
timeout-minutes: 10
115106
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
116107
steps:
@@ -127,14 +118,15 @@ jobs:
127118
exit 0
128119
fi
129120
130-
# Browser-only PRs skip IPC tests but run all other integration tests
131-
if [[ "${{ needs.changes.outputs.browser-only }}" == "true" ]]; then
132-
echo "Browser-only PR - skipping tests/ipc"
133-
TEST_INTEGRATION=1 bun x jest --coverage --maxWorkers=100% --silent --testPathIgnorePatterns='tests/ipc' tests/
121+
# Skip integration tests when no backend changes
122+
# Integration tests in tests/ are backend-focused (IPC, runtime, etc.)
123+
# Browser changes are covered by unit tests, storybook, and E2E
124+
if [[ "${{ needs.changes.outputs.backend }}" != "true" ]]; then
125+
echo "No backend changes - skipping integration tests (browser changes covered by unit/storybook/e2e)"
134126
exit 0
135127
fi
136128
137-
# Default: run ALL integration tests (future-proof for new test directories)
129+
# Backend changed: run ALL integration tests
138130
TEST_INTEGRATION=1 bun x jest --coverage --maxWorkers=100% --silent tests/
139131
env:
140132
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
@@ -150,7 +142,7 @@ jobs:
150142
test-storybook:
151143
name: Test / Storybook
152144
needs: [changes]
153-
if: ${{ needs.changes.outputs.docs-only != 'true' && github.event.inputs.test_filter == '' }}
145+
if: ${{ (needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true') && github.event.inputs.test_filter == '' }}
154146
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
155147
steps:
156148
- uses: actions/checkout@v4
@@ -167,7 +159,7 @@ jobs:
167159
test-e2e:
168160
name: Test / E2E (${{ matrix.os }})
169161
needs: [changes]
170-
if: ${{ needs.changes.outputs.docs-only != 'true' && github.event.inputs.test_filter == '' }}
162+
if: ${{ (needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true') && github.event.inputs.test_filter == '' }}
171163
strategy:
172164
fail-fast: false
173165
matrix:
@@ -200,7 +192,7 @@ jobs:
200192
smoke-server:
201193
name: Smoke / Server
202194
needs: [changes]
203-
if: ${{ needs.changes.outputs.docs-only != 'true' }}
195+
if: ${{ needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true' }}
204196
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
205197
steps:
206198
- uses: actions/checkout@v4
@@ -258,7 +250,7 @@ jobs:
258250
build-linux:
259251
name: Build / Linux
260252
needs: [changes]
261-
if: ${{ needs.changes.outputs.docs-only != 'true' }}
253+
if: ${{ needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true' }}
262254
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
263255
steps:
264256
- uses: actions/checkout@v4
@@ -277,7 +269,7 @@ jobs:
277269
build-macos:
278270
name: Build / macOS
279271
needs: [changes]
280-
if: ${{ needs.changes.outputs.docs-only != 'true' }}
272+
if: ${{ needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true' }}
281273
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-15' || 'macos-latest' }}
282274
steps:
283275
- uses: actions/checkout@v4
@@ -301,7 +293,7 @@ jobs:
301293
build-vscode:
302294
name: Build / VS Code
303295
needs: [changes]
304-
if: ${{ needs.changes.outputs.docs-only != 'true' }}
296+
if: ${{ needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true' }}
305297
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
306298
steps:
307299
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)