Skip to content

Commit 8e4a7dd

Browse files
DrJKLampcode-com
andcommitted
ci: run browser typecheck for browser_tests changes
Amp-Thread-ID: https://ampcode.com/threads/T-019c8271-c617-76ae-9405-a0818f481af4 Co-authored-by: Amp <amp@ampcode.com>
1 parent c9d6ec9 commit 8e4a7dd

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

.github/workflows/ci-lint-format.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ jobs:
2626
- name: Setup frontend
2727
uses: ./.github/actions/setup-frontend
2828

29+
- name: Detect browser_tests changes
30+
id: changed-paths
31+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
32+
with:
33+
filters: |
34+
browser_tests:
35+
- 'browser_tests/**'
36+
2937
- name: Run ESLint with auto-fix
3038
run: pnpm lint:fix
3139

@@ -60,6 +68,10 @@ jobs:
6068
pnpm format:check
6169
pnpm knip
6270
71+
- name: Typecheck browser tests
72+
if: steps.changed-paths.outputs.browser_tests == 'true'
73+
run: pnpm typecheck:browser
74+
6375
- name: Comment on PR about auto-fix
6476
if: steps.verify-changed-files.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository
6577
continue-on-error: true

lint-staged.config.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ export default {
66

77
'./**/*.js': (stagedFiles: string[]) => formatAndEslint(stagedFiles),
88

9-
'./**/*.{ts,tsx,vue,mts}': (stagedFiles: string[]) => [
10-
...formatAndEslint(stagedFiles),
11-
'pnpm typecheck'
12-
]
9+
'./**/*.{ts,tsx,vue,mts}': (stagedFiles: string[]) => {
10+
const commands = [...formatAndEslint(stagedFiles), 'pnpm typecheck']
11+
12+
const hasBrowserTestsChanges = stagedFiles
13+
.map((f) => path.relative(process.cwd(), f).replace(/\\/g, '/'))
14+
.some((f) => f.startsWith('browser_tests/'))
15+
16+
if (hasBrowserTestsChanges) {
17+
commands.push('pnpm typecheck:browser')
18+
}
19+
20+
return commands
21+
}
1322
}
1423

1524
function formatAndEslint(fileNames: string[]) {

0 commit comments

Comments
 (0)