-
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (96 loc) · 2.98 KB
/
vitest.yml
File metadata and controls
99 lines (96 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: 'Vitest'
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- ${{ github.head_ref }}
- "main"
permissions:
# Required to checkout the code
contents: read
# Required to put a comment into the pull-request
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- name: Prepare Name for Artifacts
id: prep_artifact_name
run: |
# Calculate a unique string which applies to the matrix entry
# that we can use to construct unique and valid artifact names.
# We achieve that by squashing runs of characters are invalid
# in artifact names, and also whitespace and dashes, into a
# single dash character. The unique string will appear as
# the environment variable ARTIFACT_NAME in subsequent actions.
if [ "${{ matrix.branch }}" != "" ] ; then
name="${{ matrix.branch }}"
else
name="${{ github.head_ref }}"
fi
# The option to enable + in sed regexps differs by OS so we avoid it
name=$(echo -n "$name" | sed -e 's/[ \t:\/\\"<>|*?]/-/g' -e 's/--*/-/g')
# Add 'coverage-'
name="coverage-$name"
# Push to Env
echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV
- name: 'Install Node'
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: 'Install pnpm'
uses: pnpm/action-setup@v3
with:
version: 8
run_install: false
- name: Get pnpm store
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Run Vitest
run: pnpm run test:coverage
- name: 'Upload Coverage'
uses: actions/upload-artifact@v4
with:
name: "${{ env.ARTIFACT_NAME }}"
path: coverage
report:
needs: test
runs-on: ubuntu-latest
steps:
- name: 'Download Coverage Artifacts'
uses: actions/download-artifact@v4
with:
name: "${{ env.ARTIFACT_NAME }}"
path: coverage
- name: 'Retrieve "main" Coverage Artifacts'
uses: actions/download-artifact@v4
with:
name: coverage-main
path: coverage
- name: "Report Coverage"
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-path: coverage/coverage-summary.json
json-final-path: coverage/coverage-final.json
vite-config-path: vite.config.ts
file-coverage-mode: changes
# json-summary-compare-path: coverage/coverage-main.json