Skip to content

Commit 310f11f

Browse files
authored
Run tests on PR to main (#4)
* Run tests on PR to main, not merge * Also run tests on deploy * Fix redundant test runs on every push to main #4 (comment) * Address duplicated test job across two workflow files #4 (comment)
1 parent 4166531 commit 310f11f

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
jobs:
8+
test:
9+
uses: ./.github/workflows/test.yml

.github/workflows/deploy.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ concurrency:
1616
cancel-in-progress: false
1717

1818
jobs:
19+
test:
20+
uses: ./.github/workflows/test.yml
21+
1922
build:
23+
needs: test
2024
runs-on: ubuntu-latest
2125
steps:
2226
- name: Checkout
@@ -49,7 +53,7 @@ jobs:
4953
- name: Setup Node
5054
uses: actions/setup-node@v4
5155
with:
52-
node-version: "20"
56+
node-version-file: ".nvmrc"
5357
cache: ${{ steps.detect-package-manager.outputs.manager }}
5458

5559
- name: Setup Pages
@@ -67,12 +71,6 @@ jobs:
6771
- name: Install dependencies
6872
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
6973

70-
- name: Install Playwright Browsers
71-
run: npx playwright install --with-deps chromium
72-
73-
- name: Run tests
74-
run: npm test
75-
7674
- name: Build with Next.js
7775
run: ${{ steps.detect-package-manager.outputs.runner }} next build
7876
env:

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Setup Node
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version-file: ".nvmrc"
17+
cache: "npm"
18+
19+
- name: Install dependencies
20+
run: npm ci
21+
22+
- name: Install Playwright Browsers
23+
run: npx playwright install --with-deps chromium
24+
25+
- name: Run tests
26+
run: npm test

0 commit comments

Comments
 (0)