@zgeoff/chex 0.8.6 → 0.8.8
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 +3 -2
- package/lefthook.yml +13 -0
- package/package.json +5 -2
- package/src/ci-plan/build-ci-plan-output.ts +36 -0
- package/src/ci-plan/collect-shared-checks.ts +62 -0
- package/src/ci-plan/find-chex-args.ts +40 -0
- package/src/ci-plan/parse-ci-plan.ts +299 -0
- package/src/ci-plan/parse-docs-checks.ts +1 -0
- package/src/ci-plan/parse-package-scripts.ts +36 -0
- package/src/ci-plan/write-ci-plan-json.ts +21 -0
- package/src/cli/parse-chex-args.ts +7 -2
- package/src/cli/run-chex.ts +2 -0
- package/src/cli.ts +9 -0
- package/src/workflows/collect-allowances.ts +101 -0
- package/src/workflows/collect-concurrency-findings.ts +1 -1
- package/src/workflows/collect-hook-findings.ts +13 -0
- package/src/workflows/collect-moved-repo-findings.ts +34 -0
- package/src/workflows/collect-run-commands.ts +18 -0
- package/src/workflows/collect-runner-labels.ts +8 -0
- package/src/workflows/collect-steps.ts +9 -0
- package/src/workflows/constants.ts +4 -0
- package/src/workflows/find-heavy-runner.ts +20 -0
- package/src/workflows/is-list.ts +4 -0
- package/src/workflows/parse-repo-slug.ts +7 -0
- package/src/workflows/pick-checked-paths.ts +33 -0
- package/src/workflows/pick-repo-move.ts +28 -0
- package/src/workflows/read-repo-slug.ts +12 -0
- package/src/workflows/read-repo-state.ts +57 -0
- package/src/workflows/rules/build-rule-finding.ts +10 -0
- package/src/workflows/rules/collect-condition-terms.ts +116 -0
- package/src/workflows/rules/collect-hook-check-findings.ts +84 -0
- package/src/workflows/rules/collect-main-only-job-findings.ts +123 -0
- package/src/workflows/rules/collect-main-run-concurrency-findings.ts +77 -0
- package/src/workflows/rules/collect-main-run-shape-findings.ts +161 -0
- package/src/workflows/rules/collect-needs.ts +13 -0
- package/src/workflows/rules/collect-path-filter-findings.ts +56 -0
- package/src/workflows/rules/collect-pr-gate-findings.ts +72 -0
- package/src/workflows/rules/collect-publish-findings.ts +83 -0
- package/src/workflows/rules/collect-release-jobs.ts +55 -0
- package/src/workflows/rules/collect-release-shape-findings.ts +67 -0
- package/src/workflows/rules/find-file-filter.ts +91 -0
- package/src/workflows/rules/find-image-build.ts +59 -0
- package/src/workflows/rules/find-job-environment.ts +9 -0
- package/src/workflows/rules/find-matrix-runner.ts +38 -0
- package/src/workflows/rules/find-shipped-build.ts +36 -0
- package/src/workflows/rules/is-arm-label.ts +5 -0
- package/src/workflows/rules/is-release-condition.ts +19 -0
- package/src/workflows/rules/is-shared-check-script.ts +22 -0
- package/src/workflows/rules/is-shared-release-workflow.ts +14 -0
- package/src/workflows/rules/is-workflow-call.ts +12 -0
- package/src/workflows/rules/types.ts +31 -0
- package/src/workflows/run-workflows-check.ts +60 -55
- package/src/workflows/to-unwrapped-command.ts +28 -0
- package/src/workflows/to-workflow-findings.ts +24 -0
- package/src/workflows/types.ts +68 -0
- package/src/workflows/workflow-context.ts +0 -24
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RuleFinding } from './rules/types.ts';
|
|
2
|
+
import type { Allowances, WorkflowFinding } from './types.ts';
|
|
3
|
+
|
|
4
|
+
// The findings of a file less those that a chex-allow comment turns off, plus the faults of the
|
|
5
|
+
// file's comments.
|
|
6
|
+
export function toWorkflowFindings(
|
|
7
|
+
findings: readonly RuleFinding[],
|
|
8
|
+
path: string,
|
|
9
|
+
allowances: Allowances,
|
|
10
|
+
): WorkflowFinding[] {
|
|
11
|
+
return [
|
|
12
|
+
...allowances.faults.map((fault) => ({ path, ...fault })),
|
|
13
|
+
...findings
|
|
14
|
+
.filter(
|
|
15
|
+
(finding) =>
|
|
16
|
+
!finding.allowAt.some((line) => allowances.covered.has(`${finding.rule}:${line}`)),
|
|
17
|
+
)
|
|
18
|
+
.map((finding) => ({
|
|
19
|
+
path: finding.path ?? path,
|
|
20
|
+
line: finding.line,
|
|
21
|
+
message: finding.message,
|
|
22
|
+
})),
|
|
23
|
+
];
|
|
24
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { CIPlanOutcome } from '../ci-plan/parse-ci-plan.ts';
|
|
2
|
+
import type { ChecksProfile } from './read-checks-profile.ts';
|
|
3
|
+
|
|
4
|
+
// A repo that calls the shared checks.yml of zgeoff/tools has moved to the two-workflow CI. tools
|
|
5
|
+
// itself has moved once it calls its own copy by local path.
|
|
6
|
+
export type RepoMove = 'none' | 'shared' | 'tools';
|
|
7
|
+
|
|
8
|
+
export interface Allowances {
|
|
9
|
+
// The rule and the 1-based line of the key that the comment covers, as `rule:line`.
|
|
10
|
+
readonly covered: ReadonlySet<string>;
|
|
11
|
+
|
|
12
|
+
// The lines of comments that name an unknown rule or give no reason, each with its message.
|
|
13
|
+
readonly faults: readonly Omit<WorkflowFinding, 'path'>[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface HookFile {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly lines: readonly string[];
|
|
19
|
+
readonly document: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MovedRepo {
|
|
23
|
+
readonly move: Exclude<RepoMove, 'none'>;
|
|
24
|
+
|
|
25
|
+
// What `.github/ci.yml` and package.json make of the repo's plan.
|
|
26
|
+
readonly plan: CIPlanOutcome;
|
|
27
|
+
|
|
28
|
+
readonly packageScripts: Readonly<Record<string, string>> | undefined;
|
|
29
|
+
|
|
30
|
+
// The lines of `.github/ci.yml`, empty when the repo has none.
|
|
31
|
+
readonly planLines: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface RepoState {
|
|
35
|
+
readonly move: RepoMove;
|
|
36
|
+
|
|
37
|
+
// Set when the repo has moved.
|
|
38
|
+
readonly repo: MovedRepo | undefined;
|
|
39
|
+
|
|
40
|
+
readonly hooks: readonly HookFile[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface WorkflowContext {
|
|
44
|
+
readonly path: string;
|
|
45
|
+
readonly profile: ChecksProfile | undefined;
|
|
46
|
+
|
|
47
|
+
// Whether the repo has moved to the two-workflow CI, which swaps the profile rule for the lint
|
|
48
|
+
// rules of a moved repo.
|
|
49
|
+
readonly repoMove: RepoMove;
|
|
50
|
+
readonly workflow: unknown;
|
|
51
|
+
readonly lines: readonly string[];
|
|
52
|
+
readonly jobs: readonly Job[];
|
|
53
|
+
readonly triggers: ReadonlySet<string>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface Job {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly definition: unknown;
|
|
59
|
+
readonly line: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface WorkflowFinding {
|
|
63
|
+
// Relative to the repo root.
|
|
64
|
+
readonly path: string;
|
|
65
|
+
|
|
66
|
+
readonly line: number;
|
|
67
|
+
readonly message: string;
|
|
68
|
+
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ChecksProfile } from './read-checks-profile.ts';
|
|
2
|
-
|
|
3
|
-
export interface WorkflowContext {
|
|
4
|
-
readonly path: string;
|
|
5
|
-
readonly profile: ChecksProfile | undefined;
|
|
6
|
-
readonly workflow: unknown;
|
|
7
|
-
readonly lines: readonly string[];
|
|
8
|
-
readonly jobs: readonly Job[];
|
|
9
|
-
readonly triggers: ReadonlySet<string>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface Job {
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly definition: unknown;
|
|
15
|
-
readonly line: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface WorkflowFinding {
|
|
19
|
-
// Relative to the repo root.
|
|
20
|
-
readonly path: string;
|
|
21
|
-
|
|
22
|
-
readonly line: number;
|
|
23
|
-
readonly message: string;
|
|
24
|
-
}
|