Skip to content

Commit

Permalink
Update Node test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Dec 14, 2024
1 parent d1e22d3 commit 0c4152f
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 125 deletions.
4 changes: 2 additions & 2 deletions .config/rollup.base.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ function ${SOCKET_INTEROP}(e) {
).map(o => ({
...o,
chunkFileNames: '[name].js',
manualChunks: id =>
id.includes(SLASH_NODE_MODULES_SLASH) ? 'vendor' : null
manualChunks: id_ =>
normalizeId(id_).includes(SLASH_NODE_MODULES_SLASH) ? 'vendor' : null
}))

// Replace hard-coded absolute paths in source with hard-coded relative paths.
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ jobs:
with:
no-lockfile: true
npm-test-script: 'test-ci'
node-versions: '20'
# We currently have some issues on Windows that will have to wait to be fixed
# os: 'ubuntu-latest,windows-latest'
os: 'ubuntu-latest'
node-versions: '20,22'
os: 'ubuntu-latest,windows-latest'
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
"lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
"lint:fix:fast": "prettier --cache --log-level warn --write .",
"prepare": "husky && custompatch",
"test": "run-s check build:* test:*",
"test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
"test": "run-s check build:* test:* test:coverage:*",
"test-ci": "run-s build:* test:*",
"test:unit": "tap-run",
"test:coverage": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report"
"test:coverage:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
"test:coverage:merge": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report"
},
"dependencies": {
"@apideck/better-ajv-errors": "^0.3.6",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import constants from '../constants'

import type { CliSubcommand } from '../utils/meow-with-subcommands'

const { distPath } = constants
const { distPath, execPath } = constants

const description = 'npm wrapper functionality'

Expand All @@ -16,7 +16,7 @@ export const npm: CliSubcommand = {
const wrapperPath = path.join(distPath, 'npm-cli.js')
process.exitCode = 1
const spawnPromise = spawn(
process.execPath,
execPath,
[
// Lazily access constants.nodeNoWarningsFlags.
...constants.nodeNoWarningsFlags,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/npx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import constants from '../constants'

import type { CliSubcommand } from '../utils/meow-with-subcommands'

const { distPath } = constants
const { distPath, execPath } = constants

const description = 'npx wrapper functionality'

Expand All @@ -16,7 +16,7 @@ export const npx: CliSubcommand = {
const wrapperPath = path.join(distPath, 'npx-cli.js')
process.exitCode = 1
const spawnPromise = spawn(
process.execPath,
execPath,
[
// Lazily access constants.nodeNoWarningsFlags.
...constants.nodeNoWarningsFlags,
Expand Down
7 changes: 4 additions & 3 deletions src/commands/optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import type { Spinner } from '@socketregistry/yocto-spinner'

type PackageJson = Awaited<ReturnType<typeof readPackageJson>>

const { UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE, distPath } = constants
const { UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE, distPath, execPath } =
constants

const COMMAND_TITLE = 'Socket Optimize'
const OVERRIDES_FIELD_NAME = 'overrides'
Expand Down Expand Up @@ -902,15 +903,15 @@ export const optimize: CliSubcommand = {
}
}
await spawn(
process.execPath,
execPath,
[wrapperPath, 'install', '--silent'],
npmSpawnOptions
)
// TODO: This is a temporary workaround for a `npm ci` bug where it
// will error out after Socket Optimize generates a lock file. More
// investigation is needed.
await spawn(
process.execPath,
execPath,
[
wrapperPath,
'install',
Expand Down
4 changes: 2 additions & 2 deletions src/shadow/npm-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import constants from '../constants'
import { installLinks } from './link'
import { findRoot } from '../utils/path-resolve'

const { distPath, shadowBinPath } = constants
const { distPath, execPath, shadowBinPath } = constants

const npmPath = installLinks(shadowBinPath, 'npm')
const injectionPath = path.join(distPath, 'npm-injection.js')
Expand Down Expand Up @@ -40,7 +40,7 @@ if (

process.exitCode = 1
const spawnPromise = spawn(
process.execPath,
execPath,
[
// Lazily access constants.nodeNoWarningsFlags.
...constants.nodeNoWarningsFlags,
Expand Down
4 changes: 2 additions & 2 deletions src/shadow/npx-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import spawn from '@npmcli/promise-spawn'
import constants from '../constants'
import { installLinks } from './link'

const { distPath, shadowBinPath } = constants
const { distPath, execPath, shadowBinPath } = constants

const npxPath = installLinks(shadowBinPath, 'npx')
const injectionPath = path.join(distPath, 'npm-injection.js')

process.exitCode = 1
const spawnPromise = spawn(
process.execPath,
execPath,
[
// Lazily access constants.nodeNoWarningsFlags.
...constants.nodeNoWarningsFlags,
Expand Down
Loading

0 comments on commit 0c4152f

Please sign in to comment.