-
Notifications
You must be signed in to change notification settings - Fork 3
215 lines (204 loc) · 6.08 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: CI/CD
on:
push:
branches:
- "master"
pull_request:
branches:
- "master"
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: 20
jobs:
# Run unit tests
unit_tests:
runs-on: ${{ matrix.os }}
name: Unit tests on ${{ matrix.os }}
if: always()
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test-ci
env:
FORCE_COLOR: 3
- name: Upload coverage to Codecov
if: ${{ github.event_name != 'release' }}
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
# Run linters on code
lint:
runs-on: ubuntu-latest
name: Lint code
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Run prettier
run: npm run format-check
- name: Run eslint
run: npm run lint
# Test if build is successful
build:
runs-on: ubuntu-latest
name: Test build
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Build Typescript
run: npm run build
- name: Package with NCC
run: npm run package
- name: Upload built action
uses: actions/upload-artifact@v4
with:
name: built-action
path: |
dist/index.js
.github/
action.yml
retention-days: 1
if-no-files-found: error
include-hidden-files: true
# Test build of different python versions
create_matrix:
name: Create matrix
runs-on: ubuntu-latest
outputs:
matrix-json: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install wheel
run: pip install wheel
- name: Install requirements
run: pip install -r ./.github/scripts/requirements.txt
- name: Create matrix
id: matrix
run: python ./.github/scripts/create_python_matrix.py
test_python_build:
needs: [create_matrix, build]
runs-on: ${{ matrix.os }}
name: Test build Python ${{ matrix.python-version }} for ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.create_matrix.outputs.matrix-json) }}
steps:
- name: Download built action
uses: actions/download-artifact@v4
with:
name: built-action
- name: Test action with Python ${{ matrix.python-version }}
id: build
uses: ./
with:
python-version: ${{ matrix.python-version }}
allow-build: force
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: setup
with:
python-version: ${{ steps.build.outputs.python-version }}
architecture: ${{ steps.build.outputs.architecture }}
- name: Setup pip
run: ./.github/scripts/setup_pip.ps1
shell: pwsh
env:
PYTHON_VERSION: ${{ steps.setup.outputs.python-version }}
- name: Check Python version
run: python ./.github/scripts/check_python_version.py ${{ matrix.python-version }}
- name: Check strict Python version
run: python ./.github/scripts/check_python_version.py ${{ steps.build.outputs.python-version }}
check_test_python_build:
needs: test_python_build
if: always()
runs-on: ubuntu-latest
name: Check build is successfull for all Python versions
steps:
- name: Emit failure
if: ${{ needs.test_python_build.result != 'success' }}
run: exit 1
- name: Emit success
run: echo All Python versions have been successfully built and installed...
# CodeQL security scan
codeql:
runs-on: ubuntu-latest
name: CodeQL Scan
if: ${{ github.event_name != 'release' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
queries: security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
# Update release tag
release:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
name: Build and release
needs: [build, lint, unit_tests, check_test_python_build]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ github.event.release.tag_name }}
- name: Setup NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Build Typescript
run: npm run build
- name: Package with NCC
run: npm run package
- name: Force update tag
uses: JasonEtco/build-and-tag-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}