@tahminator/pipeline 1.0.93 → 1.0.94
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 +66 -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,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`.
|
|
@@ -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",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|