-
Notifications
You must be signed in to change notification settings - Fork 19
Add npm run test:build script #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
camillobruni
merged 34 commits into
WebKit:main
from
camillobruni:2025-09-22_test_npm_run_build
Oct 23, 2025
Merged
Changes from 7 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
cf4cd4f
wip
camillobruni 50644f8
wip
camillobruni c646d71
wip
camillobruni c22b0b6
fix
camillobruni c648ba9
add missing package
camillobruni 7f6b7f1
fixes
camillobruni a18962c
format
camillobruni fb4dce9
cleanup
camillobruni 05bd3f6
Merge branch 'main' into 2025-09-22_test_npm_run_build
camillobruni 62f80a8
update add build job
camillobruni ba1b2bd
update config
camillobruni e52a531
fix var names
camillobruni fe9ccc7
more logging
camillobruni 97cf3a2
fix conditions
camillobruni b297335
more logging
camillobruni bd9f549
wip
camillobruni 9e6e4f5
fix
camillobruni cf94d79
cleanup
camillobruni f21d054
quotli
camillobruni 76dbbcc
i can't type, thanks
camillobruni 40134cb
fix
camillobruni 04e0029
prin
camillobruni c88a8b8
fix
camillobruni 0af263b
fix
camillobruni fc5b76a
fix
camillobruni ad22ba0
fix stdot
camillobruni a6a0774
cleanup
camillobruni 876b4e3
better-message
camillobruni 2c70f04
fix
camillobruni 3bb88e3
cleanup
camillobruni 951429a
fix workflow
camillobruni 524bffa
partial revert
camillobruni b3628d2
Merge branch 'main' into 2025-09-22_test_npm_run_build
camillobruni e97cc5a
fix double import
camillobruni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #! /usr/bin/env node | ||
|
|
||
| import commandLineArgs from "command-line-args"; | ||
| import fs from "fs"; | ||
| import { fileURLToPath } from "url"; | ||
| import path from "path"; | ||
|
|
||
| import { logError, logCommand, printHelp, runTest, sh } from "./helper.mjs"; | ||
|
|
||
| const optionDefinitions = [ | ||
| { name: "help", alias: "h", description: "Print this help text." }, | ||
| ]; | ||
|
|
||
| const options = commandLineArgs(optionDefinitions); | ||
|
|
||
| if ("help" in options) | ||
| printHelp(optionDefinitions); | ||
|
|
||
| const FILE_PATH = fileURLToPath(import.meta.url); | ||
| const SRC_DIR = path.dirname(path.dirname(FILE_PATH)); | ||
|
|
||
| async function findPackageJsonFiles(dir, accumulator=[]) { | ||
| const dirEntries = fs.readdirSync(dir, { withFileTypes: true }); | ||
| for (const dirent of dirEntries) { | ||
| if (dirent.name === "node_modules" || dirent.name === ".git") | ||
| continue; | ||
| const fullPath = path.join(dir, dirent.name); | ||
| if (dirent.isDirectory()) | ||
| findPackageJsonFiles(fullPath, accumulator); | ||
| else if (dirent.name === "package.json") | ||
| accumulator.push(fullPath) | ||
| } | ||
| return accumulator; | ||
| } | ||
|
|
||
| async function runBuilds() { | ||
| const packageJsonFiles = await findPackageJsonFiles(SRC_DIR); | ||
| let success = true; | ||
|
|
||
| for (const file of packageJsonFiles) { | ||
| const content = fs.readFileSync(file, "utf-8"); | ||
| const packageJson = JSON.parse(content); | ||
| if (!packageJson.scripts?.build) { | ||
| continue; | ||
| } | ||
|
|
||
| const dir = path.dirname(file); | ||
| const relativeDir = path.relative(SRC_DIR, dir); | ||
| const testName = `Building ${relativeDir}`; | ||
|
|
||
| const buildTask = async () => { | ||
| const oldCWD = process.cwd(); | ||
| try { | ||
| logCommand("cd", dir); | ||
| process.chdir(dir); | ||
| await sh("npm", "ci"); | ||
| await sh("npm", "run", "build"); | ||
| } finally { | ||
| process.chdir(oldCWD); | ||
| // await sh("git", "reset", "--hard"); | ||
camillobruni marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }; | ||
|
|
||
| success &&= await runTest(testName, buildTask); | ||
| } | ||
|
|
||
| if (!success) { | ||
| logError("One or more builds failed."); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| setImmediate(runBuilds); | ||
camillobruni marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.