-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (64 loc) · 2.21 KB
/
test.yaml
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
name: Test Workflow
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize] # default PR types
branches: [main, next]
paths: ["src/**/*", "package*.json"]
push:
branches: [main, next]
paths: ["src/**/*", "package*.json"]
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
permissions:
contents: read # to checkout the code
pull-requests: write # to add coverage reports to the PR
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- run: npm ci --include=dev
- name: Lint
run: npm run lint
- name: Run Tests
if: success()
id: run-tests
run: npm run test:ci
- name: Update GitHub Commit Status
if: ${{ !cancelled() }}
run: |
if [ ${{ steps.run-tests.outcome }} == 'success' ]; then
commit_status_state='success'
description='Tests passed'
else
commit_status_state='failure'
description='Tests failed'
fi
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data "{
\"context\": \"tests\",
\"state\": \"$commit_status_state\",
\"description\": \"$description\",
\"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"
}"
- name: Update CodeCov
if: success()
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Update PR with Coverage Reports
if: github.event_name == 'pull_request'
uses: davelosert/vitest-coverage-report-action@v2
release:
name: Release if Tests Passed (push/dispatch only)
needs: test
if: github.event_name != 'pull_request' && needs.test.result == 'success'
uses: ./.github/workflows/release.yaml
secrets:
SEMANTIC_RELEASE_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}