Skip to content

Commit 81cf832

Browse files
committed
fix(ci): resolve provenance workflow setup-script argument parsing
The provenance workflow was incorrectly passing shell operators (&&) and subsequent commands as literal string arguments, causing argument parsing issues similar to socket-sdk-js. Changes: - Add scripts/ci-validate.mjs to orchestrate test, check, and build steps - Add ci:validate script to package.json calling the new validation script - Update provenance workflow setup-script from inline shell commands to 'pnpm run ci:validate' This follows the Socket project pattern where setup-script calls a package.json script that invokes a .mjs file, avoiding shell operators in YAML and preventing argument parsing issues.
1 parent 663256e commit 81cf832

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

.github/workflows/provenance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ jobs:
3232
dist-tag: ${{ inputs.dist-tag }}
3333
package-name: '@socketregistry/packageurl-js'
3434
publish-script: 'publish:ci'
35-
setup-script: 'pnpm test && pnpm check && pnpm build'
35+
setup-script: 'pnpm run ci:validate'
3636
use-trusted-publishing: true

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"build": "node scripts/build.mjs",
4343
"bump": "node scripts/bump.mjs",
4444
"check": "node scripts/check.mjs",
45+
"ci:validate": "node scripts/ci-validate.mjs",
4546
"clean": "node scripts/clean.mjs",
4647
"cover": "node scripts/cover.mjs",
4748
"fix": "node scripts/fix.mjs",

scripts/ci-validate.mjs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* @fileoverview CI validation script for publishing workflow.
3+
* Runs test, check, and build steps in sequence.
4+
*/
5+
6+
import path from 'node:path'
7+
import { fileURLToPath } from 'node:url'
8+
9+
import { getDefaultLogger } from '@socketsecurity/lib/logger'
10+
import { spawn } from '@socketsecurity/lib/spawn'
11+
import { printHeader } from '@socketsecurity/lib/stdio/header'
12+
13+
const logger = getDefaultLogger()
14+
15+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
16+
const rootPath = path.resolve(__dirname, '..')
17+
18+
async function runCommand(command, args = []) {
19+
return new Promise((resolve, reject) => {
20+
const spawnPromise = spawn(command, args, {
21+
cwd: rootPath,
22+
stdio: 'inherit',
23+
})
24+
25+
const child = spawnPromise.process
26+
27+
child.on('exit', code => {
28+
resolve(code || 0)
29+
})
30+
31+
child.on('error', error => {
32+
reject(error)
33+
})
34+
})
35+
}
36+
37+
async function main() {
38+
try {
39+
printHeader('CI Validation')
40+
41+
// Run tests
42+
logger.step('Running tests')
43+
let exitCode = await runCommand('pnpm', ['test', '--all'])
44+
if (exitCode !== 0) {
45+
logger.error('Tests failed')
46+
process.exitCode = exitCode
47+
return
48+
}
49+
logger.success('Tests passed')
50+
51+
// Run checks
52+
logger.step('Running checks')
53+
exitCode = await runCommand('pnpm', ['check', '--all'])
54+
if (exitCode !== 0) {
55+
logger.error('Checks failed')
56+
process.exitCode = exitCode
57+
return
58+
}
59+
logger.success('Checks passed')
60+
61+
// Run build
62+
logger.step('Building project')
63+
exitCode = await runCommand('pnpm', ['build'])
64+
if (exitCode !== 0) {
65+
logger.error('Build failed')
66+
process.exitCode = exitCode
67+
return
68+
}
69+
logger.success('Build completed')
70+
71+
logger.success('CI validation completed successfully!')
72+
} catch (error) {
73+
logger.error(`CI validation failed: ${error.message}`)
74+
process.exitCode = 1
75+
}
76+
}
77+
78+
main()

0 commit comments

Comments
 (0)