@tahminator/pipeline 1.0.92 → 1.0.93-beta.g7ecf8573

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,6 +30,72 @@ bun run src/index.ts
30
30
  > [!WARNING]
31
31
  > This repository is iterating quickly & as such may have rough edges. I will always be happy to respond to & fix any issues anyone may have :)
32
32
 
33
+ ## CI script checks
34
+
35
+ Enable `LINT_CI` to typecheck, lint, and check formatting without a `test` script:
36
+
37
+ ```yaml
38
+ - uses: tahminator/pipeline/actions/setup@<published-commit-sha>
39
+ with:
40
+ GITHUB_SCRIPTS_DIR: ./.github/scripts
41
+ LINT_CI: true
42
+ ```
43
+
44
+ The setup action installs the CI package's dependencies with
45
+ `bun install --frozen-lockfile`, then runs these internal Bun scripts from
46
+ `GITHUB_SCRIPTS_DIR`:
47
+
48
+ 1. `src/internal/tsc.ts`: runs the package's TypeScript compiler with
49
+ `--noEmit --project tsconfig.json`.
50
+ 2. `src/internal/lint.ts`: runs the package's Oxlint with its
51
+ `oxlint.config.ts`, using
52
+ [native configuration loading](https://oxc.rs/docs/guide/usage/linter/config.html),
53
+ then runs `oxfmt --check`. Both run even if Oxlint reports errors.
54
+
55
+ All three tools resolve from the CI scripts package, not from the action's dependencies.
56
+ Add them as devDependencies in that package and commit the updated `package.json`
57
+ and `bun.lock`:
58
+
59
+ ```sh
60
+ bun add --cwd .github/scripts -d typescript oxlint oxfmt
61
+ ```
62
+
63
+ Provide `tsconfig.json` and `oxlint.config.ts` in that directory. For example:
64
+
65
+ ```ts
66
+ // .github/scripts/oxlint.config.ts
67
+ export default {
68
+ ignorePatterns: ["node_modules/**"],
69
+ rules: {
70
+ "no-debugger": "error",
71
+ "no-unused-vars": "error",
72
+ },
73
+ };
74
+ ```
75
+
76
+ Oxfmt uses its native configuration discovery, or its defaults when no formatter
77
+ config exists. To create a formatter config, run `bun run oxfmt --init` from the CI
78
+ scripts package directory.
79
+
80
+ Missing tools, launchers, or required configs produce actionable errors. Type,
81
+ lint, or formatting errors fail the step; a failed typecheck stops before linting
82
+ and formatting. No tools are downloaded by these scripts, no files are emitted or
83
+ autofixed, and no tests run. `LINT_CI` remains disabled by default.
84
+
85
+ Lint and formatting failures print the relevant local fix command. Run these from
86
+ your CI scripts package directory, then review the changes:
87
+
88
+ ```sh
89
+ bun run oxlint --fix
90
+ bun run oxfmt --write
91
+ ```
92
+
93
+ Oxlint can only autofix supported rules; other lint issues and TypeScript errors
94
+ require manual fixes.
95
+
96
+ Previously, `LINT_CI` invoked the consumer's `test` script. It now runs only these
97
+ internal scripts; a `test` script is neither required nor invoked.
98
+
33
99
  ## Slash commands action
34
100
 
35
101
  Use [`actions/commands`](./actions/commands/README.md) to run your repository's workflows from PR comments such as `/merge` or `/ai`.
@@ -333,6 +399,8 @@ The diff is split per Kubernetes object (matched by API group, kind, namespace a
333
399
 
334
400
  Interface with Docker to build & deploy images
335
401
 
402
+ `buildImage` runs BuildKit on the runner's network with `--network host`, so every `RUN` instruction can reach whatever the runner can, including hosts on the Headscale VPN connected by the setup action. Dockerfiles don't need `RUN --network=host`.
403
+
336
404
  ```ts
337
405
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management
338
406
  await using client = await DockerClient.create(
@@ -423,6 +491,18 @@ View the [action file](./actions/setup/action.yaml) for all available inputs.
423
491
  cargo-nextest@0.9.100
424
492
  ```
425
493
 
494
+ Language toolchains are installed and cached by the setup action, so jobs don't need separate `setup-go` / `setup-java` / `rust-toolchain` steps:
495
+
496
+ ```yaml
497
+ - uses: tahminator/pipeline/actions/setup@<version>
498
+ with:
499
+ INSTALL_GO: "true" # version read from GO_VERSION_FILE (default go.mod) unless GO_VERSION is set
500
+ INSTALL_JAVA: "true" # JAVA_VERSION "21", JAVA_DISTRIBUTION "temurin", JAVA_CACHE "maven" by default
501
+ INSTALL_RUST: "true" # also caches the Cargo registry and target dir
502
+ RUST_TOOLCHAIN: "1.93.0"
503
+ RUST_COMPONENTS: "clippy, rustfmt"
504
+ ```
505
+
426
506
  ### `NPMClient`
427
507
 
428
508
  Interface with NPM registry in order to publish packages to `npmjs.com`
@@ -48,7 +48,10 @@ export class DockerClient {
48
48
  console.log("Building image with following tags:");
49
49
  tags.forEach((tag) => console.log(Utils.Colors.cyan(tag)));
50
50
  try {
51
- await $ `docker buildx create --use --name ${dockerRepository}-builder`;
51
+ await $ `docker buildx create --use --name ${dockerRepository}-builder \
52
+ --driver docker-container \
53
+ --driver-opt network=host \
54
+ --buildkitd-flags ${"--allow-insecure-entitlement network.host"}`;
52
55
  }
53
56
  catch {
54
57
  await $ `docker buildx use ${dockerRepository}-builder`;
@@ -68,6 +71,8 @@ export class DockerClient {
68
71
  --cache-from=type=gha \
69
72
  --cache-to=type=gha,mode=max \
70
73
  ${buildArgFlags} \
74
+ --network host \
75
+ --allow network.host \
71
76
  ${tagFlags} \
72
77
  .`;
73
78
  console.log(shouldUpload ?
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ async function main() {
4
+ const tools = [
5
+ {
6
+ name: "oxlint",
7
+ args: [],
8
+ fix: "For lint issues that support autofix, run `bun run oxlint --fix` from your CI scripts package directory. Other issues require manual fixes.",
9
+ },
10
+ {
11
+ name: "oxfmt",
12
+ args: ["--check"],
13
+ fix: "To fix formatting, run `bun run oxfmt --write` from your CI scripts package directory.",
14
+ },
15
+ ];
16
+ for (const tool of tools) {
17
+ let launcher;
18
+ try {
19
+ const manifest = Bun.resolveSync(`${tool.name}/package.json`, process.cwd());
20
+ launcher = join(dirname(manifest), "bin", tool.name);
21
+ }
22
+ catch (error) {
23
+ if (!(error instanceof Error) ||
24
+ !("code" in error) ||
25
+ (error.code !== "MODULE_NOT_FOUND" &&
26
+ error.code !== "ERR_MODULE_NOT_FOUND")) {
27
+ throw error;
28
+ }
29
+ }
30
+ if (!launcher || !existsSync(launcher)) {
31
+ console.error(`pipeline: ${tool.name} is missing. Add ${tool.name} as a devDependency to your CI scripts package.json by running \`bun add -d ${tool.name}\` in that directory.`);
32
+ process.exitCode = 1;
33
+ continue;
34
+ }
35
+ if (tool.name === "oxlint" && !existsSync("oxlint.config.ts")) {
36
+ console.error("pipeline: Missing oxlint.config.ts. Add it to your CI scripts package directory.");
37
+ process.exitCode = 1;
38
+ continue;
39
+ }
40
+ const child = Bun.spawn([process.execPath, launcher, ...tool.args], {
41
+ stdin: "inherit",
42
+ stdout: "inherit",
43
+ stderr: "inherit",
44
+ });
45
+ const exitCode = await child.exited;
46
+ if (child.signalCode) {
47
+ process.kill(process.pid, child.signalCode);
48
+ return;
49
+ }
50
+ if (exitCode !== 0) {
51
+ process.exitCode = exitCode;
52
+ console.error(`pipeline: ${tool.fix}`);
53
+ }
54
+ }
55
+ }
56
+ await main();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ async function main() {
4
+ let launcher;
5
+ try {
6
+ const manifest = Bun.resolveSync("typescript/package.json", process.cwd());
7
+ launcher = join(dirname(manifest), "bin/tsc");
8
+ }
9
+ catch (error) {
10
+ if (!(error instanceof Error) ||
11
+ !("code" in error) ||
12
+ (error.code !== "MODULE_NOT_FOUND" &&
13
+ error.code !== "ERR_MODULE_NOT_FOUND")) {
14
+ throw error;
15
+ }
16
+ }
17
+ if (!launcher || !existsSync(launcher)) {
18
+ console.error("pipeline: TypeScript is missing. Add typescript as a devDependency to your CI scripts package.json by running `bun add -d typescript` in that directory.");
19
+ process.exitCode = 1;
20
+ return;
21
+ }
22
+ if (!existsSync("tsconfig.json")) {
23
+ console.error("pipeline: Missing tsconfig.json. Add it to your CI scripts package directory.");
24
+ process.exitCode = 1;
25
+ return;
26
+ }
27
+ const child = Bun.spawn([process.execPath, launcher, "--noEmit", "--project", "tsconfig.json"], {
28
+ stdin: "inherit",
29
+ stdout: "inherit",
30
+ stderr: "inherit",
31
+ });
32
+ const exitCode = await child.exited;
33
+ if (child.signalCode)
34
+ process.kill(process.pid, child.signalCode);
35
+ else
36
+ process.exitCode = exitCode;
37
+ }
38
+ await main();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "author": "Tahmid Ahmed",
5
5
  "description": "A collection of Bun shell scripts that can be re-used in various CICD pipelines.",
6
- "version": "1.0.92",
6
+ "version": "1.0.93-beta.g7ecf8573",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },