@tahminator/pipeline 1.0.92 → 1.0.93-beta.g8cbdf33f

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,56 @@ 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 and lint your CI scripts 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
+
54
+ Both tools resolve from the CI scripts package, not from the action's dependencies.
55
+ Add them as devDependencies in that package and commit the updated `package.json`
56
+ and `bun.lock`:
57
+
58
+ ```sh
59
+ bun add --cwd .github/scripts -d typescript oxlint
60
+ ```
61
+
62
+ Provide `tsconfig.json` and `oxlint.config.ts` in that directory. For example:
63
+
64
+ ```ts
65
+ // .github/scripts/oxlint.config.ts
66
+ export default {
67
+ ignorePatterns: ["node_modules/**"],
68
+ rules: {
69
+ "no-debugger": "error",
70
+ "no-unused-vars": "error",
71
+ },
72
+ };
73
+ ```
74
+
75
+ Missing tools, launchers, or configs produce actionable errors. Type errors or
76
+ lint errors fail the step; a failed typecheck stops before linting. No tools are
77
+ downloaded by these scripts, no files are emitted or autofixed, and no tests run.
78
+ `LINT_CI` remains disabled by default.
79
+
80
+ Previously, `LINT_CI` invoked the consumer's `test` script. It now runs only these
81
+ two checks; a `test` script is neither required nor invoked.
82
+
33
83
  ## Slash commands action
34
84
 
35
85
  Use [`actions/commands`](./actions/commands/README.md) to run your repository's workflows from PR comments such as `/merge` or `/ai`.
@@ -333,6 +383,8 @@ The diff is split per Kubernetes object (matched by API group, kind, namespace a
333
383
 
334
384
  Interface with Docker to build & deploy images
335
385
 
386
+ `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`.
387
+
336
388
  ```ts
337
389
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management
338
390
  await using client = await DockerClient.create(
@@ -423,6 +475,18 @@ View the [action file](./actions/setup/action.yaml) for all available inputs.
423
475
  cargo-nextest@0.9.100
424
476
  ```
425
477
 
478
+ Language toolchains are installed and cached by the setup action, so jobs don't need separate `setup-go` / `setup-java` / `rust-toolchain` steps:
479
+
480
+ ```yaml
481
+ - uses: tahminator/pipeline/actions/setup@<version>
482
+ with:
483
+ INSTALL_GO: "true" # version read from GO_VERSION_FILE (default go.mod) unless GO_VERSION is set
484
+ INSTALL_JAVA: "true" # JAVA_VERSION "21", JAVA_DISTRIBUTION "temurin", JAVA_CACHE "maven" by default
485
+ INSTALL_RUST: "true" # also caches the Cargo registry and target dir
486
+ RUST_TOOLCHAIN: "1.93.0"
487
+ RUST_COMPONENTS: "clippy, rustfmt"
488
+ ```
489
+
426
490
  ### `NPMClient`
427
491
 
428
492
  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,31 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ let launcher;
4
+ try {
5
+ const manifest = Bun.resolveSync("oxlint/package.json", process.cwd());
6
+ launcher = join(dirname(manifest), "bin/oxlint");
7
+ }
8
+ catch (error) {
9
+ if (!(error instanceof Error) ||
10
+ !("code" in error) ||
11
+ (error.code !== "MODULE_NOT_FOUND" && error.code !== "ERR_MODULE_NOT_FOUND")) {
12
+ throw error;
13
+ }
14
+ }
15
+ if (!launcher || !existsSync(launcher)) {
16
+ console.error("pipeline: Oxlint is missing. Add oxlint as a devDependency to your CI scripts package.json by running `bun add -d oxlint` in that directory.");
17
+ process.exit(1);
18
+ }
19
+ if (!existsSync("oxlint.config.ts")) {
20
+ console.error("pipeline: Missing oxlint.config.ts. Add it to your CI scripts package directory.");
21
+ process.exit(1);
22
+ }
23
+ const result = Bun.spawnSync([process.execPath, launcher], {
24
+ stdin: "inherit",
25
+ stdout: "inherit",
26
+ stderr: "inherit",
27
+ });
28
+ if (result.signalCode)
29
+ process.kill(process.pid, result.signalCode);
30
+ else
31
+ process.exitCode = result.exitCode;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ let launcher;
4
+ try {
5
+ const manifest = Bun.resolveSync("typescript/package.json", process.cwd());
6
+ launcher = join(dirname(manifest), "bin/tsc");
7
+ }
8
+ catch (error) {
9
+ if (!(error instanceof Error) ||
10
+ !("code" in error) ||
11
+ (error.code !== "MODULE_NOT_FOUND" && error.code !== "ERR_MODULE_NOT_FOUND")) {
12
+ throw error;
13
+ }
14
+ }
15
+ if (!launcher || !existsSync(launcher)) {
16
+ 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.");
17
+ process.exit(1);
18
+ }
19
+ if (!existsSync("tsconfig.json")) {
20
+ console.error("pipeline: Missing tsconfig.json. Add it to your CI scripts package directory.");
21
+ process.exit(1);
22
+ }
23
+ const result = Bun.spawnSync([process.execPath, launcher, "--noEmit", "--project", "tsconfig.json"], {
24
+ stdin: "inherit",
25
+ stdout: "inherit",
26
+ stderr: "inherit",
27
+ });
28
+ if (result.signalCode)
29
+ process.kill(process.pid, result.signalCode);
30
+ else
31
+ process.exitCode = result.exitCode;
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.g8cbdf33f",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },