-
-
Notifications
You must be signed in to change notification settings - Fork 3
190 lines (164 loc) · 7.6 KB
/
package-tests.yml
File metadata and controls
190 lines (164 loc) · 7.6 KB
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
# #
# @type github workflow
# @author Aetherinox
# @url https://github.com/Aetherinox
# @usage performs tests on the NodeJS package noxenv
#
# @secrets secrets.SELF_TOKEN self github personal access token (fine-grained)
# secrets.SELF_TOKEN_CL self github personal access token (classic)
# secrets.NPM_TOKEN self npmjs access token
# secrets.PYPI_API_TOKEN self Pypi API token (production site) - https://pypi.org/
# secrets.PYPI_API_TEST_TOKEN self Pypi API token (test site) - https://test.pypi.org/
# secrets.SELF_DOCKERHUB_TOKEN self Dockerhub token
# secrets.CODECOV_TOKEN codecov upload token for nodejs projects
# secrets.MAXMIND_GELITE_TOKEN maxmind API token
# secrets.CF_ACCOUNT_ID cloudflare account id
# secrets.CF_ACCOUNT_TOKEN cloudflare account token
# secrets.ORG_TOKEN org github personal access token (fine-grained)
# secrets.ORG_TOKEN_CL org github personal access token (classic)
# secrets.ORG_DOCKERHUB_TOKEN org dockerhub secret
# secrets.ORG_GITEA_TOKEN org gitea personal access token (classic) with package:write permission
# secrets.BOT_GPG_KEY_ASC bot gpg private key (armored) | BEGIN PGP PRIVATE KEY BLOCK
# secrets.BOT_GPG_KEY_B64 bot gpg private key (binary) converted to base64
# secrets.BOT_GPG_PASSPHRASE bot gpg private key passphrase
# secrets.DISCORD_WEBHOOK_CHAN_GITHUB_RELEASES discord webhook to report release notifications from github to discord
# secrets.DISCORD_WEBHOOK_CHAN_GITHUB_WORKFLOWS discord webhook to report workflow notifications from github to discord
# secrets.DISCORD_WEBHOOK_CHAN_GITHUB_UPDATES discord webhook to report activity notifications from github to discord
#
# @local these workflows can be tested locally through the use of `act`
# https://github.com/nektos/act
# Extract act to folder
# Add system env var with path to act.exe
# Run the commands:
# git pull https://github.com/username/repo
# act -W .github/workflows/package-tests.yml -P ubuntu-latest=catthehacker/ubuntu:full-22.04
# act -W .github/workflows/package-tests.yml -s TOKEN_CL=XXXXXXXXXX --pull=false
# #
name: '📦 Package › Tests'
run-name: '📦 Package › Tests'
on:
push:
branches:
- '+([0-9])?(.{+([0-9]),x}).x'
- 'main'
- '!all-contributors/**'
pull_request:
workflow_dispatch:
jobs:
job-tests-run:
name: >-
📦 Test
if: |
${{ !contains(github.head_ref, 'all-contributors') }}
strategy:
matrix:
os: [windows-latest, macOS-latest, ubuntu-latest]
node-version: [16.x, 18.x, 20.x, 21.x, 22.x]
runs-on: ${{ matrix.os }}
env:
CI: true
permissions:
contents: write
packages: write
steps:
# #
# Job > Tests > Fix Line Endings
# #
- name: '🛒 Fix Git Checkout Line Endings'
id: task_tests_git-fixlines
run: |
git config --global core.autocrlf input
# #
# Job > Tests > Checkout
# #
- name: '☑️ Checkout'
id: task_tests_run_checkout
uses: actions/checkout@v4
# #
# Job > Tests > Cancel existing runs
# #
- name: '🛑 Cancel Previous Runs'
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.ADMINSERV_TOKEN_CL }}
# #
# Job > Tests > Setup Node
# #
- name: '⚙️ Setup Node'
id: task_tests_node_setup
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org/'
always-auth: true
scope: '@aetherinox'
# #
# Job > Tests > Get NPM Cache Directory
#
# must set `shell:bash` otherwise command will fail on Windows runner.
# bash can be used for both Linux and Windows
# #
- name: '📂 Get NPM Cache Directory'
id: task_tests_npm_cache_dir_get
shell: bash
run: |
cacheDir=$(npm config get cache)
echo "dir=$cacheDir" >> $GITHUB_OUTPUT
# #
# Job > Tests > NPM Cache
# #
- name: '📑 NPM cache'
id: task_tests_npm_cache_dir_run # use this to check for `cache-hit` ==> if: steps.task_tests_npm_cache_dir_run.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: ${{ steps.task_tests_npm_cache_dir_get.outputs.dir }}
key: ${{ runner.OS }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.OS }}-node-
# #
# Job > Tests > NPM Install
# #
- name: '📦 NPM › Install'
id: task_tests_npm_install
run: |
npm install
# #
# Job > Tests > NPM Pretty and Linter
# #
- name: '📦 NPM › Pretty & Linter'
id: task_tests_npm_prettylint
run: |
npm run pretty
npm run lint
# #
# Job > Tests > Run Validation Script
# #
- name: '▶️ Run Build'
run: |
npm run validate
# #
# Job > Tests > Upload Coverage to Codecov
# #
- name: '📝 Upload Coverage Reports › Codecov'
id: task_tests_codecov_upload
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Aetherinox/noxenv
env_vars: CI_OS,NODE_VERSION
env:
CI_OS: ${{ matrix.os }}
NODE_VERSION: ${{ matrix.node-version }}
# #
# JOB > TESTS > COMPLETE
# #
job-tests-complete:
name: >-
📦 Tests › Complete
needs: job-tests-run
runs-on: ubuntu-latest
steps:
- name: '☑️ Tests Complete'
id: task_tests_complete
run: |
echo 'Tests passed'