Skip to content

Commit fc56a5d

Browse files
committed
add github action
1 parent 945c152 commit fc56a5d

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Build and test"
2+
on:
3+
# Runs on pushes targeting the default branch
4+
push:
5+
branches: ["master"]
6+
# pull_request:
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
# Required to checkout the code
16+
contents: read
17+
# Required to put a comment into the pull-request
18+
# pull-requests: write
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: "Install Node"
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: "20.x"
26+
- name: "Install Deps"
27+
run: npm install
28+
- name: "Build Next.js"
29+
run: npm run build
30+
- name: "Test"
31+
run: npx vitest --coverage.enabled true
32+
- name: "Report Coverage"
33+
# Set if: always() to also generate the report if tests are failing
34+
# Only works if you set `reportOnFailure: true` in your vite config as specified above
35+
if: always()
36+
uses: davelosert/vitest-coverage-report-action@v2

vitest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export default defineConfig({
66
globals: true,
77
environment: "node",
88
setupFiles: ["./__tests__/setup.ts"],
9+
reporters: process.env.GITHUB_ACTIONS
10+
? ["dot", "github-actions"]
11+
: ["default"],
912
},
1013
plugins: [tsconfigPaths()],
1114
});

0 commit comments

Comments
 (0)