-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (116 loc) · 3.61 KB
/
ci.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
---
name: CI
on:
pull_request:
branches:
- main
types:
- opened
- ready_for_review
- synchronize
- reopened
push:
branches:
- main
workflow_dispatch:
inputs:
debug:
type: choice
description: Debug mode
required: false
options:
- 'true'
- 'false'
# Allow one concurrent
concurrency:
group: ${{ format('{0}-{1}-{2}-{3}-{4}', github.workflow, github.event_name, github.ref, github.base_ref, github.head_ref) }}
cancel-in-progress: true
env:
DEBUG: ${{ inputs.debug || secrets.ACTIONS_RUNNER_DEBUG || vars.ACTIONS_RUNNER_DEBUG || secrets.ACTIONS_STEP_DEBUG || vars.ACTIONS_STEP_DEBUG || false }}
jobs:
build-test:
name: Build and Test
if: ${{ contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) || (github.event_name == 'pull_request' && !github.event.pull_request.draft) }}
permissions:
contents: read
issues: read
checks: write
pull-requests: write
actions: write
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: 🩺 Debug
if: ${{ env.DEBUG == 'true' }}
uses: raven-actions/debug@v1
with:
vars-context: ${{ toJson(vars) }}
secrets-context: ${{ toJson(secrets) }}
needs-context: ${{ toJson(needs) }}
inputs-context: ${{ toJson(inputs) }}
- name: ⤵️ Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔄️ Detect changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
app:
- 'src/**'
- 'tests/**'
- 'package.json'
- 'package-lock.json'
- '.node-version'
- 'jest.config.js'
- 'tsconfig.json'
- name: 🚧 Setup Node
if: ${{ steps.changes.outputs.app == 'true' }}
uses: actions/setup-node@v3
with:
node-version-file: .node-version
cache: npm
- name: 🔀 Install dependencies
if: ${{ steps.changes.outputs.app == 'true' }}
run: npm ci
- name: 🏗️ Build
if: ${{ steps.changes.outputs.app == 'true' }}
run: npm run build:ci
- name: 🧪 Test
if: ${{ steps.changes.outputs.app == 'true' }}
run: npm run test:ci:cov
continue-on-error: true
- name: 📤 Upload test results
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v3
with:
name: test-results
path: 'reports/jest-*.xml'
if-no-files-found: warn
- name: 📤 Upload coverage results
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: coverage
if-no-files-found: warn
- name: 📜 Test report
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: phoenix-actions/test-reporting@v12
with:
name: 📜 Test report
path: 'reports/jest-*.xml'
reporter: jest-junit
- name: 📜 Coverage report
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/cobertura-coverage.xml