Skip to content

Commit 536820a

Browse files
committed
Correctly delete binary for CI tests
1 parent 767a7ab commit 536820a

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,12 @@ jobs:
412412
name: Test (recompile from source) (v${{ matrix.node }}) ${{ matrix.os }}
413413
needs: [job_build]
414414
runs-on: ${{ matrix.os }}
415+
env:
416+
DELETE_BINARIES: true
415417
strategy:
416418
fail-fast: false
417419
matrix:
418-
os: [ubuntu-late4st, macos-latest, windows-latest]
420+
os: [ubuntu-latest, macos-latest, windows-latest]
419421
node: [18, 26]
420422
steps:
421423
- name: Check out current commit
@@ -430,8 +432,6 @@ jobs:
430432
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
431433
with:
432434
name: ${{ github.sha }}
433-
- name: Clear binaries
434-
run: yarn clean:binaries
435435
- name: Run tests
436436
run: yarn test
437437

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"build:bindings:arm64": "yarn build:lib && node-gyp build --arch=arm64 && yarn build:copy-binary",
3333
"build:tarball": "npm pack",
3434
"clean": "node-gyp clean && rm -rf lib && rm -rf build && rm -f *.tgz",
35-
"clean:binaries": "node -e \"require('fs').readdirSync('lib').filter(f=>f.endsWith('.node')).forEach(f=>require('fs').rmSync('lib/'+f))\"",
3635
"test": "node ./test/prepare.mjs && vitest run --poolOptions.forks.singleFork --silent=false --disable-console-intercept"
3736
},
3837
"gypfile": false,

test/e2e.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const __dirname = import.meta.dirname || new URL('.', import.meta.url).pathname;
77
const NODE_MAJOR_VERSION = parseInt(process.versions.node.split('.')[0], 10);
88

99
// macOS emulated x64 in CI is very slow!
10-
const timeout = process.env.CI && process.platform === 'darwin' ? 60000 : 20000;
10+
const timeout = (process.env.CI && process.platform === 'darwin') || process.env.DELETE_BINARIES ? 60000 : 20000;
1111

1212
async function runTest(...paths) {
1313
console.time('Test Run');

test/prepare.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { execSync, spawnSync } from 'node:child_process';
2-
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2+
import { existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
33
import { createRequire } from 'node:module';
44
import { dirname, join, relative } from 'node:path';
55
import { fileURLToPath } from 'node:url';
@@ -40,6 +40,16 @@ function installTarballAsDependency(root) {
4040

4141
console.log('Installing dependencies...');
4242
execSync('yarn install', { cwd: root, stdio: 'inherit' });
43+
44+
// For recompile from source tests, we need to ensure the pre-built binaries are removed
45+
if (process.env.DELETE_BINARIES) {
46+
const unpackedDir = join(root, 'node_modules', '@sentry/node-native-stacktrace', 'lib');
47+
readdirSync(unpackedDir).forEach(file => {
48+
if (file.endsWith('.node')) {
49+
rmSync(join(unpackedDir, file));
50+
}
51+
});
52+
}
4353
}
4454

4555
installTarballAsDependency(__dirname);

0 commit comments

Comments
 (0)