Skip to content

Commit ff8f525

Browse files
committed
ci: explicitly installing node headers and static libraries into ./tmp/node-gyp and caching it
1 parent df7bf85 commit ff8f525

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.gitlab-ci.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ variables:
1313
GH_PROJECT_URL: "https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git"
1414
GIT_SUBMODULE_STRATEGY: recursive
1515
# Cache .npm
16-
NPM_CONFIG_CACHE: "${CI_PROJECT_DIR}/tmp/npm"
16+
npm_config_cache: "${CI_PROJECT_DIR}/tmp/npm"
1717
# Prefer offline node module installation
18-
NPM_CONFIG_PREFER_OFFLINE: "true"
18+
npm_config_prefer_offline: "true"
1919
# `ts-node` has its own cache
2020
TS_CACHED_TRANSPILE_CACHE: "${CI_PROJECT_DIR}/tmp/ts-node-cache"
2121
TS_CACHED_TRANSPILE_PORTABLE: "true"
@@ -32,6 +32,8 @@ cache:
3232
- ./tmp/Homebrew
3333
# `jest` cache is configured in jest.config.js
3434
- ./tmp/jest/
35+
# `node-gyp` cache used by windows and macos
36+
- ./tmp/node-gyp
3537

3638
stages:
3739
- check # Linting, unit tests
@@ -144,14 +146,21 @@ build:windows:
144146
needs: []
145147
tags:
146148
- windows
149+
variables:
150+
# Target node version must match nixpkgs `pkgs.nodejs.version`
151+
npm_config_target: '16.14.2'
152+
# Location node-gyp installed headers and static libraries
153+
npm_config_devdir: "${CI_PROJECT_DIR}/tmp/node-gyp"
154+
npm_config_nodedir: "${CI_PROJECT_DIR}/tmp/node-gyp/$npm_config_target"
147155
before_script:
148-
- choco install nodejs --version=16.14.2 -y
156+
- choco install nodejs --version="$npm_config_target" -y
149157
- choco install python --version=3.9.12 -y
150158
- refreshenv
151159
script:
152160
- npm config set msvs_version 2019 --location project
153161
- npm install --ignore-scripts
154162
- $env:Path = "$(npm bin);" + $env:Path
163+
- node-gyp install --ensure
155164
- npm run build --verbose
156165
- npm test -- --ci
157166
artifacts:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"prepare": "tsc -p ./tsconfig.build.json",
1616
"install": "node-gyp-build",
17-
"prebuild": "prebuildify --napi --strip --target=16.14.2",
17+
"prebuild": "prebuildify --napi --strip",
1818
"build": "rimraf ./dist && tsc -p ./tsconfig.build.json",
1919
"postversion": "npm install --package-lock-only --ignore-scripts --silent",
2020
"ts-node": "ts-node -r tsconfig-paths/register",

0 commit comments

Comments
 (0)