forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
354 lines (292 loc) · 11.3 KB
/
windows_test_npm_install.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#/
# @license Apache-2.0
#
# Copyright (c) 2021 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/
# Workflow name:
name: windows_test_npm_install
# Workflow triggers:
on:
# Run nightly:
schedule:
- cron: '0 9 * * *'
# Allow the workflow to be manually run:
workflow_dispatch:
# Workflow concurrency group:
concurrency:
# Specify a group name:
group: ${{ github.workflow }}
# Specify whether to cancel any currently running workflow in the same concurrency group:
cancel-in-progress: true
# Global permissions:
permissions:
# Allow read-only access to the repository contents:
contents: read
# Workflow jobs:
jobs:
# Define a job for testing project installation on Windows...
test_npm_install:
# Define a display name:
name: "Node.js v${{ matrix.NODE_VERSION }}"
# Ensure the job does not run on forks:
if: github.repository == 'stdlib-js/stdlib'
# Define the type of virtual host machine on which to run the job:
runs-on: ${{ matrix.OS }}
# Define environment variables:
env:
FC: 'gfortran'
FORTRAN_COMPILER: 'gfortran'
CC: 'gcc'
C_COMPILER: 'gcc'
CXX: 'g++'
CXX_COMPILER: 'g++'
LINKER: 'g++'
GITHUB: 'true'
LOG_DIR: "${{ github.workspace }}\\tmp\\var\\log"
LOG_FILE_BUILD_TASK: "${{ github.workspace }}\\\\tmp\\\\var\\\\log\\\\${{ matrix.BUILD_TASK }}.log"
LOG_NUM_LINES: 5000
# Define the build matrix strategy...
strategy:
# Specify whether to cancel all in-progress jobs if any matrix job fails:
fail-fast: false
# Define the build matrix:
matrix:
# Define the list of build tasks:
BUILD_TASK: ['test-npm-install']
# Define the list of Node.js versions:
NODE_VERSION: ['20', '18', '16', '14', '12', '10', '8', '6', '4']
# Define the list of operating systems:
OS: ['windows-latest']
# Define the list of host architectures:
ARCHITECTURE:
- x64
# Define configuration options for each Node.js version:
include:
- OS: 'windows-latest'
PLATFORM: 'windows'
- NODE_VERSION: '20'
NPM_VERSION: '>10.0.0'
- NODE_VERSION: '18'
NPM_VERSION: '>10.0.0'
- NODE_VERSION: '16'
NPM_VERSION: '>2.7.0 <10.0.0'
- NODE_VERSION: '14'
NPM_VERSION: '>2.7.0 <10.0.0'
- NODE_VERSION: '12'
NPM_VERSION: '>2.7.0 <9.0.0'
- NODE_VERSION: '10'
NPM_VERSION: '>2.7.0 <7.0.0'
- NODE_VERSION: '8'
NPM_VERSION: '>2.7.0 <6.0.0'
- NODE_VERSION: '6'
NPM_VERSION: '>2.7.0 <6.0.0'
- NODE_VERSION: '4'
NPM_VERSION: '>2.7.0 <6.0.0'
# Set defaults:
defaults:
run:
# Set the default shell to MSYS2:
shell: msys2 {0}
# Define the sequence of job steps...
steps:
# Checkout the repository:
- name: 'Checkout repository'
# Pin action to full length commit SHA
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# Specify whether to remove untracked files before checking out the repository:
clean: false
# Limit clone depth to the most recent 100 commits:
fetch-depth: 100
# Specify whether to download Git-LFS files:
lfs: false
timeout-minutes: 10
# Install MSYS2:
- name: 'Install MSYS2'
# Pin action to full length commit SHA
uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2.24.1
with:
# Set the MSYS system:
msystem: MINGW64
# Ensure packages are updated:
update: true
# Install packages after updating the system:
install: git make base mingw-w64-x86_64-toolchain
timeout-minutes: 10
# Initialize log files:
- name: 'Initialize log files'
run: |
mkdir -p "${{ env.LOG_DIR }}"
touch "${{ env.LOG_FILE_BUILD_TASK }}"
timeout-minutes: 2
# Configure Git:
- name: 'Configure Git'
# Instruct Git to convert CRLF line endings (Windows) to LF on commit and force Git to use HTTPS rather than SSH.
#
# [1]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace
run: |
git config --global core.autocrlf input
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://
timeout-minutes: 2
# Configure NVS:
- name: 'Configure NVS'
run: |
echo "NVS_HOME=$HOME/.nvs" >> $GITHUB_ENV
echo "NVS_LINK_TO_SYSTEM=1" >> $GITHUB_ENV
timeout-minutes: 2
# Install Node.js:
- name: 'Install Node.js'
run: |
echo 'Cloning NVS...'
git clone https://github.com/jasongin/nvs "${{ env.NVS_HOME }}"
echo ''
echo 'Running NVS installation script...'
. "${{ env.NVS_HOME }}/nvs.sh" install
echo ''
echo "Installing Node.js version ${{ matrix.NODE_VERSION }}..."
. "${{ env.NVS_HOME }}/nvs.sh" && nvs add ${{ matrix.NODE_VERSION }}
echo ''
echo "Activating Node.js version ${{matrix.NODE_VERSION }}..."
. "${{ env.NVS_HOME }}/nvs.sh" && nvs use ${{ matrix.NODE_VERSION }}
timeout-minutes: 15
# Print debug info:
- name: 'Print debug info'
run: |
. "${{ env.NVS_HOME }}/nvs.sh" && nvs use ${{ matrix.NODE_VERSION }}
echo 'PATH:'
echo $PATH
echo ''
echo 'gcc:'
gcc --version
echo ''
echo 'g++:'
g++ --version
echo ''
echo 'Git:'
git --version
echo ''
echo 'Node.js:'
node --version
node -p 'process.platform + "@" + process.arch'
echo ''
echo 'npm:'
npm --version
npm config get registry
timeout-minutes: 2
# Update the npm client (older clients cannot handle scoped modules):
- name: 'Update npm'
run: |
. "${{ env.NVS_HOME }}/nvs.sh" && nvs use ${{ matrix.NODE_VERSION }}
npm install -g npm@"${{ matrix.NPM_VERSION }}"
npm --version
timeout-minutes: 5
# Install Windows build tools for compiling Node.js native add-ons.
- name: 'Install Windows build tools'
# Pin action to full length commit SHA
uses: crazy-max/ghaction-chocolatey@2ae99523e93879734d432250f87e2c45c379cd60 # v3.2.0
with:
args: install -y visualstudio2019buildtools visualstudio2019-workload-vctools
timeout-minutes: 10
# View the log file if the previous step fails:
- name: 'View log file'
if: failure()
run: |
echo "Printing the last ${{ env.LOG_NUM_LINES }} lines of log output..."
tail -${{ env.LOG_NUM_LINES }} 'C:\ProgramData\chocolatey\logs\chocolatey.log'
timeout-minutes: 5
# Configure npm:
- name: 'Configure npm'
run: |
. "${{ env.NVS_HOME }}/nvs.sh" && nvs use ${{ matrix.NODE_VERSION }}
npm config set msvs_version 2019
timeout-minutes: 2
# Run the build task:
- name: 'Run build task'
env:
# Explicitly set computed environment variables:
TEST_NPM_INSTALL_PKG: '@stdlib/stdlib'
TEST_NPM_INSTALL_GITHUB_URL: 'https://github.com/stdlib-js/stdlib'
run: |
. "${{ env.NVS_HOME }}/nvs.sh" && nvs use ${{ matrix.NODE_VERSION }}
. "$GITHUB_WORKSPACE/.github/workflows/scripts/task_runner" ${{ matrix.BUILD_TASK }} "${{ env.LOG_FILE_BUILD_TASK }}"
timeout-minutes: 360
# View the log file if the previous step fails:
- name: 'View log file'
if: failure()
run: |
echo "Printing the last ${{ env.LOG_NUM_LINES }} lines of log output..."
tail -${{ env.LOG_NUM_LINES }} "${{ env.LOG_FILE_BUILD_TASK }}"
timeout-minutes: 5
# Upload the log file:
- name: 'Upload log file'
# Pin action to full length commit SHA
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: always()
with:
# Define a name for the uploaded artifact (ensuring a unique name for each job):
name: ${{ matrix.BUILD_TASK }}_log_nodejs_v${{ matrix.NODE_VERSION }}_${{ matrix.PLATFORM }}
# Specify the path to the file to upload:
path: ${{ env.LOG_FILE_BUILD_TASK }}
# Specify the number of days to retain the artifact (default is 90 days):
retention-days: 5
timeout-minutes: 10
# Define a job for sending notifications to Slack...
slack:
# Define a display name:
name: 'Slack notification'
# Define the type of virtual host machine:
runs-on: 'ubuntu-latest'
# Indicate that this job depends on the prior job finishing:
needs: test_npm_install
# Run this job regardless of the outcome of the prior job:
if: success() || failure()
# Set defaults:
defaults:
run:
# Set the default shell to `bash`:
shell: bash --noprofile --norc -eo pipefail {0}
# Define the sequence of job steps...
steps:
# Resolve notification data:
- name: 'Resolve notification data'
run: |
echo 'NOTIFICATION_STATUS=${{ needs.test_npm_install.result}}' >> $GITHUB_ENV
if [[ "${{ needs.test_npm_install.result }}" = "success" ]]; then
echo 'NOTIFICATION_TEXT=**test_npm_install** workflow succeeded (windows)' >> $GITHUB_ENV
echo 'NOTIFICATION_AUTHOR_NAME=Success' >> $GITHUB_ENV
elif [[ "${{ needs.test_npm_install.result }}" = "failure" ]]; then
echo 'NOTIFICATION_TEXT=**test_npm_install** workflow failed (windows)' >> $GITHUB_ENV
echo 'NOTIFICATION_AUTHOR_NAME=Failure' >> $GITHUB_ENV
elif [[ "${{ needs.test_npm_install.result }}" = "cancelled" ]]; then
echo 'NOTIFICATION_TEXT=**test_npm_install** workflow was canceled (windows)' >> $GITHUB_ENV
echo 'NOTIFICATION_AUTHOR_NAME=Canceled' >> $GITHUB_ENV
else
exit 1
fi
timeout-minutes: 5
# Send notification to Slack:
- name: 'Send notification'
# Pin action to full length commit SHA
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
if: success()
with:
status: "${{ env.NOTIFICATION_STATUS }}"
fields: repo,commit,message
text: "${{ env.NOTIFICATION_TEXT }}"
author_name: "${{ env.NOTIFICATION_AUTHOR_NAME }}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.REPO_SLACK_WEBHOOK_URL }}
timeout-minutes: 5