Skip to content
This repository was archived by the owner on Mar 7, 2023. It is now read-only.

Commit b1623e9

Browse files
Fix GitHub Actions CI failing on Windows runners (prebuild failing to build binaries) (#165)
Fix #164
1 parent 5ffcb36 commit b1623e9

File tree

3 files changed

+290
-219
lines changed

3 files changed

+290
-219
lines changed

.github/workflows/ci.yml

+63-8
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,42 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
name: 'Build on Node v${{ matrix.node }} ${{ matrix.os }} ${{ matrix.arch }}'
8-
runs-on: ${{ matrix.os }}-latest
7+
name: 'Build on Node v${{ matrix.node }} ${{ matrix.os.name }} ${{ matrix.arch }}'
8+
runs-on: ${{ matrix.os.name }}-${{ matrix.os.version }}
99

1010
strategy:
1111
matrix:
12-
os: [Ubuntu, Windows, macOS]
12+
os:
13+
- name: Ubuntu
14+
version: latest
15+
- name: macOS
16+
version: latest
17+
- name: Windows
18+
# Using the `windows-2019` runner instead of latest(`windows-2022`)
19+
# because the build was last known working on that version of runner and
20+
# `prebuild` fails to find the 2022 Visual Studio install because
21+
# it's internally using an old version of `node-gyp`, see
22+
# https://github.com/prebuild/prebuild/issues/286
23+
#
24+
# Also some more context around this problem in this internal issue,
25+
# https://github.com/MadLittleMods/node-usb-detection/issues/164
26+
version: 2019
1327
arch: [x64]
1428
node: ['12', '14', '16']
1529
include:
16-
- os: Windows
30+
- os:
31+
name: Windows
32+
version: 2019
1733
arch: x86
1834
node: '12'
19-
- os: Windows
35+
- os:
36+
name: Windows
37+
version: 2019
2038
arch: x86
2139
node: '14'
22-
- os: Windows
40+
- os:
41+
name: Windows
42+
version: 2019
2343
arch: x86
2444
node: '16'
2545

@@ -33,15 +53,50 @@ jobs:
3353
node-version: ${{ matrix.node }}
3454
architecture: ${{ matrix.arch }}
3555

56+
# FIXME: Install `npm@^8` (latest v8) once
57+
# https://github.com/actions/setup-node/issues/411#issuecomment-1025543081
58+
# is fixed.
59+
#
60+
# Even though we install a new version of node-gyp locally in
61+
# the project, the CI always seems to use the npm bundled version of
62+
# node-gyp. Even following the instructions from the docs, I could get it working
63+
# on all other platforms except for Windows and npm@6, see
64+
# - https://github.com/nodejs/node-gyp/blob/245cd5bbe4441d4f05e88f2fa20a86425419b6af/docs/Updating-npm-bundled-node-gyp.md
65+
# - https://github.com/nodejs/node-gyp/blob/245cd5bbe4441d4f05e88f2fa20a86425419b6af/docs/Force-npm-to-use-global-node-gyp.md
66+
- name: 'Install npm@^8 to get a more up to date bundled node-gyp'
67+
run: npm install --global [email protected]
68+
69+
# Fix `Error: Could not find any Visual Studio installation to use`
70+
# See https://github.com/nodejs/node-gyp/tree/245cd5bbe4441d4f05e88f2fa20a86425419b6af/docs#issues-finding-the-installed-visual-studio
71+
#
72+
# This is commented out because we're using `windows-2019` runners atm
73+
# - name: 'Set msvs_version so node-gyp can find the Visual Studio install'
74+
# if: ${{ matrix.os.name == 'Windows' }}
75+
# run: npm config set msvs_version 2022
76+
3677
- name: 'Install Linux dependencies'
37-
if: ${{ matrix.os == 'Ubuntu' }}
78+
if: ${{ matrix.os.name == 'Ubuntu' }}
3879
run: |
3980
sudo apt-get update
4081
sudo apt-get install libudev-dev
4182
83+
- name: 'Node.js version'
84+
run: node --version
85+
86+
- name: 'npm version'
87+
run: npm --version
88+
89+
- name: 'node-gyp version'
90+
run: npm run node-gyp -- --version
91+
4292
- name: 'Install dependencies and build from source'
4393
run: npm ci --build-from-source
4494

95+
# We run this after `npm ci` so that `nan` is installed probably
96+
- name: 'node-gyp configuration (for debugging)'
97+
if: ${{ always() }}
98+
run: npm run node-gyp -- configure --verbose
99+
45100
# TODO: Tests are disabled until we have tests which are
46101
# suitable for CI and don't require manual interaction.
47102
- name: 'Test'
@@ -57,7 +112,7 @@ jobs:
57112
if: ${{ matrix.node == '14' }}
58113
uses: actions/upload-artifact@v2
59114
with:
60-
name: prebuilds-${{ matrix.os }}-${{ matrix.arch }}
115+
name: prebuilds-${{ matrix.os.name }}-${{ matrix.arch }}
61116
path: prebuilds
62117

63118
check:

0 commit comments

Comments
 (0)