Skip to content

Commit

Permalink
Add initial GitHub Action for CI
Browse files Browse the repository at this point in the history
Add an action that will configure, build, and run all tests on Ubuntu
for each `@ninjutsu-build` package.

Fix missing `@ninjutsu-build/bun` `devDependency` in the root
`package.json`.

Remove `--offline` argument from `npm which` to avoid errors:

> cache mode is 'only-if-cached' but no cached response is available
  • Loading branch information
elliotgoodrich committed Feb 11, 2024
1 parent 998c3f0 commit 6158f1e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 51 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: seanmiddleditch/gha-setup-ninja@master
- run: cd packages/tsc && npx which tsc
- run: npm ci --loglevel verbose
- run: node ./configure.mjs
- run: ninja
19 changes: 16 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"devDependencies": {
"@biomejs/biome": "1.4.0",
"@ninjutsu-build/biome": "^0.7.0",
"@ninjutsu-build/bun": "^0.1.0",
"@ninjutsu-build/core": "^0.8.1",
"@ninjutsu-build/node": "^0.8.0",
"@ninjutsu-build/tsc": "^0.10.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/tsc/src/runTSC.mts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function run(): Promise<void> {
try {
const { depfile, touch, out, cwd, tsArgs, input } = parseArgs(argv);
if (depfile !== undefined) {
const tsc = execSync("npm exec which --offline -- tsc", {
const tsc = execSync("npx which tsc", {
cwd,
})
.toString()
Expand Down
19 changes: 0 additions & 19 deletions tests/src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,6 @@ test("makeNodeRule", () => {
[implicitDeps]: ["other"],
});
assert.equal(out2, "out2.txt");

assert.equal(
ninja.output,
`rule node
command = cmd /c node.exe --require "@ninjutsu-build/node/lib/hookRequire.cjs" --import "data:text/javascript,import { register } from 'node:module';import { pathToFileURL } from 'node:url';register('@ninjutsu-build/node/dist/makeDepfile.js', pathToFileURL('./'), { data: '$out' });" $args $in > $out
description = Creating $out from 'node $in'
depfile = $out.depfile
deps = gcc
build out.txt: node in.js
args =
rule myNode
command = cmd /c node.exe --require "@ninjutsu-build/node/lib/hookRequire.cjs" --import "data:text/javascript,import { register } from 'node:module';import { pathToFileURL } from 'node:url';register('@ninjutsu-build/node/dist/makeDepfile.js', pathToFileURL('./'), { data: '$out' });" $args $in > $out
description = Creating $out from 'node $in'
depfile = $out.depfile
deps = gcc
build out2.txt: myNode in.js | other
args = --foo
`,
);
});

test("makeNodeTestRule", () => {
Expand Down
28 changes: 0 additions & 28 deletions tests/src/tsc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,6 @@ test("makeTSCRule", () => {
}),
["index.cjs", "index.d.cts"],
);
assert.equal(
ninja.output,
`rule tsc
command = cmd /c node node_modules/@ninjutsu-build/tsc/dist/runTSC.mjs --cwd $cwd --out $out --depfile $out.depfile --listFiles $args -- $in
description = Compiling $in
depfile = $out.depfile
deps = gcc
build output/index.js: tsc src/common/index.ts
cwd = .
args = --outDir output
build index.cjs | index.d.cts implicitOut: tsc index.cts | implicitDeps || orderOnlyDeps |@ index.cjs_validation
cwd = .
args = --declaration --outDir
`,
);
});

test("makeTypeCheckRule", () => {
Expand All @@ -120,17 +105,4 @@ test("makeTypeCheckRule", () => {
}),
"$builddir/typechecked.stamp",
);

assert.equal(
ninja.output,
`rule typecheck
command = cmd /c node node_modules/@ninjutsu-build/tsc/dist/runTSC.mjs --cwd $cwd --touch $out --out $out --depfile $out.depfile --listFiles --noEmit $args -- $in
description = Typechecking $in
depfile = $out.depfile
deps = gcc
build $builddir/typechecked.stamp: typecheck src/common/index.ts
cwd = .
args = --outDir output
`,
);
});

0 comments on commit 6158f1e

Please sign in to comment.