Skip to content

Commit 97365a8

Browse files
committed
feat[ci]: run tests and report coverage for PR
1 parent 81b9d60 commit 97365a8

File tree

2 files changed

+70
-25
lines changed

2 files changed

+70
-25
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,29 @@ name: Deploy
22
on:
33
push:
44
branches:
5-
- ci-test
65
- master
7-
workflow_dispatch:
8-
inputs:
9-
logLevel:
10-
description: 'Log level'
11-
required: true
12-
default: 'warning'
136

147
jobs:
158
deploy:
16-
name: deploy
179
runs-on: ubuntu-latest
1810
steps:
19-
- name: checkout code
20-
uses: actions/checkout@v4
11+
- uses: actions/checkout@v4
2112

22-
- name: Get yarn cache directory path
23-
id: yarn-cache-dir-path
24-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
25-
26-
- uses: actions/cache@v4
27-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
13+
- name: "Install Node"
14+
uses: actions/setup-node@v4
2815
with:
29-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
30-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
31-
restore-keys: |
32-
${{ runner.os }}-yarn-
16+
node-version: "20"
17+
cache: "yarn"
3318

34-
- name: setup
35-
run: yarn
19+
- name: "Setup"
20+
run: yarn install
3621

37-
- name: test
22+
- name: "Test"
3823
run: yarn test
3924

40-
- name: deploy
25+
- name: "Deploy"
4126
env:
4227
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
4328
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
4429
run: |
4530
yarn deploy
46-

.github/workflows/pr.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: PR tests
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
branch:
11+
- ${{ github.head_ref }}
12+
- "master"
13+
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: ${{ matrix.branch }}
21+
22+
- name: "Install Node"
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: "20"
26+
cache: "yarn"
27+
28+
- name: "Install Deps"
29+
run: yarn install
30+
31+
- name: "Test"
32+
run: yarn coverage
33+
34+
- name: "Upload Coverage"
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: coverage-${{ matrix.branch }}
38+
path: coverage
39+
40+
report-coverage:
41+
needs: test
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: "Download HEAD coverage artifacts"
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: coverage-${{ github.head_ref }}
50+
path: coverage
51+
52+
- name: "Download master coverage artifacts"
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: coverage-master
56+
path: coverage-master
57+
58+
- name: "Report Coverage"
59+
uses: davelosert/vitest-coverage-report-action@v2
60+
with:
61+
json-summary-compare-path: coverage-master/coverage-summary.json

0 commit comments

Comments
 (0)