@tahminator/pipeline 1.0.93 → 1.0.94-beta.g1c0747b4
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 +70 -0
- package/dist/internal/lintfmt.d.ts +1 -0
- package/dist/internal/lintfmt.js +51 -0
- package/dist/internal/tsc.d.ts +1 -0
- package/dist/internal/tsc.js +33 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,76 @@ 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`, using TypeScript's normal config discovery.
|
|
50
|
+
2. `src/internal/lintfmt.ts`: runs the package's Oxlint, then `oxfmt --check`.
|
|
51
|
+
Both run even if Oxlint reports errors.
|
|
52
|
+
|
|
53
|
+
The scripts do not require specific config filenames or pass config paths.
|
|
54
|
+
Each tool handles its own supported formats, discovery, defaults, and config errors.
|
|
55
|
+
For example, Oxlint supports
|
|
56
|
+
[JSON, JSONC, and TypeScript configs](https://oxc.rs/docs/guide/usage/linter/config.html),
|
|
57
|
+
and TypeScript searches for `tsconfig.json` in the current directory and its ancestors.
|
|
58
|
+
|
|
59
|
+
All three tools resolve from the CI scripts package, not from the action's dependencies.
|
|
60
|
+
Add them as devDependencies in that package and commit the updated `package.json`
|
|
61
|
+
and `bun.lock`:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
bun add --cwd .github/scripts -d typescript oxlint oxfmt
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
An optional Oxlint configuration could look like this:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// .github/scripts/oxlint.config.ts
|
|
71
|
+
export default {
|
|
72
|
+
ignorePatterns: ["node_modules/**"],
|
|
73
|
+
rules: {
|
|
74
|
+
"no-debugger": "error",
|
|
75
|
+
"no-unused-vars": "error",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Oxfmt uses its native configuration discovery, or its defaults when no formatter
|
|
81
|
+
config exists. To create a formatter config, run `bun run oxfmt --init` from the CI
|
|
82
|
+
scripts package directory.
|
|
83
|
+
|
|
84
|
+
Missing tools or launchers produce actionable errors. Config, type, lint, or
|
|
85
|
+
formatting errors fail the step; a failed typecheck stops before linting
|
|
86
|
+
and formatting. No tools are downloaded by these scripts, no files are emitted or
|
|
87
|
+
autofixed, and no tests run. `LINT_CI` remains disabled by default.
|
|
88
|
+
|
|
89
|
+
Lint and formatting failures print the relevant local fix command. Run these from
|
|
90
|
+
your CI scripts package directory, then review the changes:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
bun run oxlint --fix
|
|
94
|
+
bun run oxfmt --write
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Oxlint can only autofix supported rules; other lint issues and TypeScript errors
|
|
98
|
+
require manual fixes.
|
|
99
|
+
|
|
100
|
+
Previously, `LINT_CI` invoked the consumer's `test` script. It now runs only these
|
|
101
|
+
internal scripts; a `test` script is neither required nor invoked.
|
|
102
|
+
|
|
33
103
|
## Slash commands action
|
|
34
104
|
|
|
35
105
|
Use [`actions/commands`](./actions/commands/README.md) to run your repository's workflows from PR comments such as `/merge` or `/ai`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
const child = Bun.spawn([process.execPath, launcher, ...tool.args], {
|
|
36
|
+
stdin: "inherit",
|
|
37
|
+
stdout: "inherit",
|
|
38
|
+
stderr: "inherit",
|
|
39
|
+
});
|
|
40
|
+
const exitCode = await child.exited;
|
|
41
|
+
if (child.signalCode) {
|
|
42
|
+
process.kill(process.pid, child.signalCode);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (exitCode !== 0) {
|
|
46
|
+
process.exitCode = exitCode;
|
|
47
|
+
console.error(`pipeline: ${tool.fix}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
await main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
const child = Bun.spawn([process.execPath, launcher, "--noEmit"], {
|
|
23
|
+
stdin: "inherit",
|
|
24
|
+
stdout: "inherit",
|
|
25
|
+
stderr: "inherit",
|
|
26
|
+
});
|
|
27
|
+
const exitCode = await child.exited;
|
|
28
|
+
if (child.signalCode)
|
|
29
|
+
process.kill(process.pid, child.signalCode);
|
|
30
|
+
else
|
|
31
|
+
process.exitCode = exitCode;
|
|
32
|
+
}
|
|
33
|
+
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.
|
|
6
|
+
"version": "1.0.94-beta.g1c0747b4",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|