Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ jobs:
fail-fast: false
matrix:
node-version: ['lts/-1', 'lts/*', 'latest']
os: [macos-latest, ubuntu-latest, ubuntu-24.04-arm, windows-latest]
os: [macos-latest, ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- name: Upgrade node-gyp if it cannot detect the installed Visual Studio
if: runner.os == 'Windows'
run: npm run upgrade-node-gyp
- run: npm audit || true
- run: npm run lint
# - run: npm run update-crosswalk # To support newer versions of Node.js
- run: npm run build --if-present
- name: DEBUG which node-gyp the tests will use
if: runner.os == 'Windows'
run: |
node -p "'npm_config_node_gyp=' + process.env.npm_config_node_gyp"
node -p "require('fs').existsSync(process.env.npm_config_node_gyp || '')"
node -p "require('./lib/util/compile.js').which_node_gyp()"
- run: npm test
12 changes: 8 additions & 4 deletions .github/workflows/s3-bucket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,31 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest, windows-2022]
node-version: ['lts/-1', 'lts/*', 'latest']
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}

name: Test S3 Bucket - Node ${{ matrix.node }} on ${{ matrix.os }}
name: Test S3 Bucket - Node ${{ matrix.node-version }} on ${{ matrix.os }}

steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v7

- name: Setup node ${{ matrix.node }}
- name: Setup node ${{ matrix.node-version }}
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node-version }}

- name: NPM Install
run: npm install

- name: Upgrade node-gyp if it cannot detect the installed Visual Studio
if: runner.os == 'Windows'
run: npm run upgrade-node-gyp

- name: Show Environment Info
run: |
printenv
Expand Down
2 changes: 2 additions & 0 deletions lib/util/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function which_node_gyp() {
}
}

module.exports.which_node_gyp = which_node_gyp;

module.exports.run_gyp = function(args, opts, callback) {
let shell_cmd = '';
const cmd_args = [];
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"lint": "eslint bin/node-pre-gyp lib/*js lib/util/*js test/*js scripts/*js",
"fix": "npm run lint -- --fix",
"update-crosswalk": "node scripts/abi_crosswalk.js",
"upgrade-node-gyp": "node scripts/upgrade-node-gyp.js",
"test": "tape test/*test.js",
"test:s3": "tape test/s3.test.js",
"bucket": "node scripts/set-bucket.js"
Expand Down
41 changes: 41 additions & 0 deletions scripts/upgrade-node-gyp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

// script upgrades node-gyp when the bundled copy is too old to detect the installed Visual Studio. node-gyp
// recognises Visual Studio 2026 (major version 18) only from v12 onwards, so older copies fail to configure on runner
// images shipping it.

const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const compile = require('../lib/util/compile.js');

const MINIMUM_MAJOR = 12;
const INSTALL_VERSION = '13.0.2';

const node_gyp_bin = compile.which_node_gyp();
if (!node_gyp_bin) {
console.log('could not locate node-gyp; leaving it alone');
process.exit(0);
}

const { version } = require(path.join(node_gyp_bin, '../../package.json'));
console.log(`found node-gyp@${version} at ${node_gyp_bin}`);

if (parseInt(version, 10) >= MINIMUM_MAJOR) {
console.log(`node-gyp@${version} detects Visual Studio 2026; nothing to do`);
process.exit(0);
}

console.log(`node-gyp@${version} predates v${MINIMUM_MAJOR}; installing node-gyp@${INSTALL_VERSION}`);
cp.execFileSync('npm', ['install', '--no-save', `node-gyp@${INSTALL_VERSION}`], { stdio: 'inherit', shell: true });

const upgraded = path.join(__dirname, '../node_modules/node-gyp/bin/node-gyp.js');
if (!fs.existsSync(upgraded)) {
throw new Error(`expected the upgraded node-gyp at ${upgraded}, but it is not there`);
}
console.log(`using node-gyp at ${upgraded}`);

// export for later GitHub workflow steps, which npm would otherwise point back at its own bundled copy
if (process.env.GITHUB_ENV) {
fs.appendFileSync(process.env.GITHUB_ENV, `npm_config_node_gyp=${upgraded}\n`);
}
5 changes: 0 additions & 5 deletions test/run.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ function run(prog, command, args, app, opts, cb) {
opts.cwd = path.join(__dirname, app.name);
}

// Test building with msvs 2022
if (process.platform === 'win32') {
final_cmd += ' --msvs_version=2022 ';
}

// finish appending all arguments
final_cmd += ' ' + app.args;
final_cmd += ' ' + args;
Expand Down