-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (130 loc) · 4.43 KB
/
test.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: TEST
run-name: 'TEST@${{github.ref_name}}'
on:
workflow_call:
push:
branches:
- main
paths:
- '*'
- src/**
- '!**.md'
- '!.github/renovate.json5'
concurrency:
group: test-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
name: Test & build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [20.x]
steps:
- uses: mato533/cicd-actions/setup-pnpm@main
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Type check
working-directory: packages/electron-typed-ipc-bridge
run: pnpm run typecheck
- name: Run the test
working-directory: packages/electron-typed-ipc-bridge
run: pnpm run test
- name: Build
id: build
shell: bash
working-directory: packages/electron-typed-ipc-bridge
run: |
pnpm run build
TAR_INFO="$(pnpm pack --json)"
TAR_NAME="$(jq -r .filename <<<"${TAR_INFO}")"
ls -l "${TAR_NAME}"
RESULT="tar-name=${TAR_NAME}"
echo "${RESULT}" >>"${GITHUB_OUTPUT}"
echo "${RESULT}"
- name: Setup playground
env:
TAR_NAME: ${{ steps.build.outputs.tar-name }}
working-directory: packages/sample-app
shell: bash
run: |
pnpm add "../electron-typed-ipc-bridge/${TAR_NAME}"
- name: Type check
working-directory: packages/sample-app
run: pnpm run typecheck
- name: Build (Windows)
if: runner.os == 'Windows'
working-directory: packages/sample-app
run: pnpm build:win
- name: Test (E2E) on Windows
if: runner.os == 'Windows'
working-directory: packages/sample-app
run: pnpm test:e2e
- name: Build (Linux)
if: runner.os == 'Linux'
working-directory: packages/sample-app
run: pnpm build:linux
- name: Test (E2E) on Linux
if: runner.os == 'Linux'
working-directory: packages/sample-app
run: |
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
dbus-daemon --session --address=${DBUS_SESSION_BUS_ADDRESS} --nofork --nopidfile --syslog-only &
xvfb-run -a pnpm test:e2e
coverage:
name: Report Coverage
runs-on: ubuntu-latest
if: ${{ success() || failure() }}
needs:
- test
permissions:
contents: read
pull-requests: write
steps:
- name: Setup node environments
uses: mato533/cicd-actions/setup-pnpm@main
with:
cache: 'pnpm'
- name: Run tests with coverage
id: test
env:
TEST_RESULT: 'coverage/junit.xml'
working-directory: packages/electron-typed-ipc-bridge
run: |
pnpm exec vitest run --coverage \
--coverage.reportOnFailure \
--coverage.reporter=json-summary \
--coverage.reporter=json \
--coverage.reporter=clover \
--reporter=default \
--reporter=junit \
--outputFile="coverage/junit.xml"
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: packages/electron-typed-ipc-bridge/coverage/coverage-final.json
verbose: true
- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: packages/electron-typed-ipc-bridge/coverage/junit.xml
verbose: true
- name: Upload coverage report to the code climate
uses: paambaati/codeclimate-action@v9
if: ${{ github.event_name == 'push' }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: packages/electron-typed-ipc-bridge/coverage/clover.xml:clover
- name: Write coverage report to pull request
if: ${{ github.event_name == 'pull_request' }}
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: packages/electron-typed-ipc-bridge/