generated from graasp/graasp-app-starter-ts-vite
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 2.4 KB
/
tests.yml
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
name: Tests
on:
push:
branches:
- main
merge_group:
pull_request:
env:
VITE_PORT: 3000
VITE_API_HOST: http://localhost:3636
VITE_GRAASP_APP_KEY: id-1234567890
VITE_ENABLE_MOCK_API: true
VITE_VERSION: ci-tests
CI: true
jobs:
run-tests:
concurrency: tests-${{ github.head_ref || github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Yarn Install and Cache
uses: graasp/graasp-deploy/.github/actions/yarn-install-and-cache@v1
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Build App
run: yarn build:test
shell: bash
env:
VITE_PORT: ${{ env.VITE_PORT }}
VITE_API_HOST: ${{ env.VITE_API_HOST }}
VITE_GRAASP_APP_KEY: ${{ env.VITE_GRAASP_APP_KEY }}
VITE_ENABLE_MOCK_API: ${{ env.VITE_ENABLE_MOCK_API }}
VITE_VERSION: ${{ env.VITE_VERSION }}
CI: ${{ env.CI }}
- name: Vitest Run
run: yarn unittest
shell: bash
- name: Playwright Run
run: yarn playwright
shell: bash
env:
VITE_PORT: ${{ env.VITE_PORT }}
VITE_API_HOST: ${{ env.VITE_API_HOST }}
VITE_GRAASP_APP_KEY: ${{ env.VITE_GRAASP_APP_KEY }}
VITE_ENABLE_MOCK_API: ${{ env.VITE_ENABLE_MOCK_API }}
VITE_VERSION: ${{ env.VITE_VERSION }}
CI: ${{ env.CI }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report
- name: coverage report
run: npx nyc report --reporter=text-summary
- name: coverage commit status
run: |
total=$(cat coverage/coverage-summary.json | jq .total.lines.pct)
echo Total coverage ${total}
curl -S -s \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
https://api.github.com/repos/${REPO_PATH}/statuses/${COMMIT_SHA} \
-d "{\"state\":\"success\",\"target_url\":\"https://github.com/${REPO_PATH}/actions/runs/${RUN_ID}\",\"description\":\"${total}%\",\"context\":\"code-coverage\"}"
env:
GITHUB_TOKEN: ${{ github.token }}
REPO_PATH: ${{ github.repository }}
COMMIT_SHA: ${{ github.sha }}
RUN_ID: ${{ github.run_id }}