@intentius/chant-lexicon-gitlab 0.46.0 → 0.50.0

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.
Files changed (50) hide show
  1. package/dist/components/generate-op-pipeline.d.ts +37 -0
  2. package/dist/components/generate-op-pipeline.d.ts.map +1 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/integrity.json +8 -5
  6. package/dist/lint/audit-catalog.d.ts.map +1 -1
  7. package/dist/lint/post-synth/index.d.ts.map +1 -1
  8. package/dist/lint/post-synth/wgl019.d.ts.map +1 -1
  9. package/dist/lint/post-synth/wgl049.d.ts +14 -0
  10. package/dist/lint/post-synth/wgl049.d.ts.map +1 -0
  11. package/dist/lint/post-synth/wgl050.d.ts +13 -0
  12. package/dist/lint/post-synth/wgl050.d.ts.map +1 -0
  13. package/dist/lint/rules/import-source.d.ts +28 -0
  14. package/dist/lint/rules/import-source.d.ts.map +1 -0
  15. package/dist/lint/rules/missing-script.d.ts.map +1 -1
  16. package/dist/lint/rules/missing-stage.d.ts.map +1 -1
  17. package/dist/manifest.json +1 -1
  18. package/dist/okf/index.md +2 -0
  19. package/dist/okf/rules/WGL049.md +15 -0
  20. package/dist/okf/rules/WGL050.md +15 -0
  21. package/dist/okf/types/Job.md +2 -0
  22. package/dist/op/builders.d.ts +29 -0
  23. package/dist/op/builders.d.ts.map +1 -0
  24. package/dist/plugin.d.ts.map +1 -1
  25. package/dist/rules/import-source.ts +58 -0
  26. package/dist/rules/missing-script.ts +13 -0
  27. package/dist/rules/missing-stage.ts +8 -0
  28. package/dist/rules/wgl019.ts +6 -1
  29. package/dist/rules/wgl049.ts +57 -0
  30. package/dist/rules/wgl050.ts +49 -0
  31. package/package.json +3 -3
  32. package/src/components/generate-op-pipeline.test.ts +94 -0
  33. package/src/components/generate-op-pipeline.ts +111 -0
  34. package/src/index.ts +8 -0
  35. package/src/lint/audit-catalog.ts +5 -0
  36. package/src/lint/post-synth/index.ts +4 -0
  37. package/src/lint/post-synth/wgl019.test.ts +8 -0
  38. package/src/lint/post-synth/wgl019.ts +6 -1
  39. package/src/lint/post-synth/wgl049.test.ts +71 -0
  40. package/src/lint/post-synth/wgl049.ts +57 -0
  41. package/src/lint/post-synth/wgl050.test.ts +57 -0
  42. package/src/lint/post-synth/wgl050.ts +49 -0
  43. package/src/lint/rules/import-source.ts +58 -0
  44. package/src/lint/rules/missing-script.ts +13 -0
  45. package/src/lint/rules/missing-stage.ts +8 -0
  46. package/src/lint/rules/rules.test.ts +60 -0
  47. package/src/op/builders.test.ts +43 -0
  48. package/src/op/builders.ts +39 -0
  49. package/src/plugin.test.ts +1 -1
  50. package/src/plugin.ts +3 -0
@@ -88,6 +88,49 @@ describe("WGL002: missing-script", () => {
88
88
  const diags = missingScriptRule.check(ctx);
89
89
  expect(diags).toHaveLength(0);
90
90
  });
91
+
92
+ // chant #1544 — cross-lexicon rule bleed: a github/forgejo `Job` imported
93
+ // from its own lexicon package must not be judged by gitlab's `script`/
94
+ // `trigger`/`run` requirement.
95
+ test("does not flag a Job imported from the github lexicon", () => {
96
+ const ctx = createContext(
97
+ `import { Job } from "@intentius/chant-lexicon-github";\nconst j = new Job({ "runs-on": "ubuntu-latest", steps: [] });`,
98
+ );
99
+ const diags = missingScriptRule.check(ctx);
100
+ expect(diags).toHaveLength(0);
101
+ });
102
+
103
+ test("does not flag a Job imported from the forgejo lexicon", () => {
104
+ const ctx = createContext(
105
+ `import { Job } from "@intentius/chant-lexicon-forgejo";\nconst j = new Job({ "runs-on": "ubuntu-latest", steps: [] });`,
106
+ );
107
+ const diags = missingScriptRule.check(ctx);
108
+ expect(diags).toHaveLength(0);
109
+ });
110
+
111
+ test("still flags a Job imported from the gitlab lexicon", () => {
112
+ const ctx = createContext(
113
+ `import { Job } from "@intentius/chant-lexicon-gitlab";\nconst j = new Job({ stage: "test" });`,
114
+ );
115
+ const diags = missingScriptRule.check(ctx);
116
+ expect(diags).toHaveLength(1);
117
+ });
118
+
119
+ test("still flags a namespace-imported gl.Job() from the gitlab lexicon", () => {
120
+ const ctx = createContext(
121
+ `import * as gl from "@intentius/chant-lexicon-gitlab";\nconst j = new gl.Job({ stage: "build" });`,
122
+ );
123
+ const diags = missingScriptRule.check(ctx);
124
+ expect(diags).toHaveLength(1);
125
+ });
126
+
127
+ test("does not flag a namespace-imported Job from another lexicon", () => {
128
+ const ctx = createContext(
129
+ `import * as gh from "@intentius/chant-lexicon-github";\nconst j = new gh.Job({ "runs-on": "ubuntu-latest", steps: [] });`,
130
+ );
131
+ const diags = missingScriptRule.check(ctx);
132
+ expect(diags).toHaveLength(0);
133
+ });
91
134
  });
92
135
 
93
136
  // ── WGL003: missing stage ───────────────────────────────────────────
@@ -107,6 +150,23 @@ describe("WGL003: missing-stage", () => {
107
150
  const diags = missingStageRule.check(ctx);
108
151
  expect(diags).toHaveLength(0);
109
152
  });
153
+
154
+ // chant #1544 — same cross-lexicon rule bleed as WGL002.
155
+ test("does not flag a Job imported from the github lexicon", () => {
156
+ const ctx = createContext(
157
+ `import { Job } from "@intentius/chant-lexicon-github";\nconst j = new Job({ "runs-on": "ubuntu-latest", steps: [] });`,
158
+ );
159
+ const diags = missingStageRule.check(ctx);
160
+ expect(diags).toHaveLength(0);
161
+ });
162
+
163
+ test("still flags a Job imported from the gitlab lexicon", () => {
164
+ const ctx = createContext(
165
+ `import { Job } from "@intentius/chant-lexicon-gitlab";\nconst j = new Job({ script: ["test"] });`,
166
+ );
167
+ const diags = missingStageRule.check(ctx);
168
+ expect(diags).toHaveLength(1);
169
+ });
110
170
  });
111
171
 
112
172
  // ── WGL004: artifact no expiry ──────────────────────────────────────
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Typed step-builder wrapper (chant #1288 Stage 2) — see
3
+ * `lexicons/k8s/src/op/builders.test.ts`'s module doc for what's asserted
4
+ * and why.
5
+ */
6
+
7
+ import { describe, test, expect } from "vitest";
8
+ import { gitlabPipeline as gitlabPipelineOld, stepOutput, type StepOutputRef } from "@intentius/chant/op";
9
+ import { gitlabPipeline } from "./builders";
10
+
11
+ describe("gitlab typed step builder (#1288 Stage 2)", () => {
12
+ test("gitlabPipeline: identical ActivityStep to core's original for a minimal call", () => {
13
+ expect(gitlabPipeline("alb-api")).toEqual(gitlabPipelineOld("alb-api"));
14
+ });
15
+
16
+ test("gitlabPipeline: identical ActivityStep with opts", () => {
17
+ const opts = { ref: "main", intervalMs: 15000, profile: "fastIdempotent" as const };
18
+ expect(gitlabPipeline("alb-api", opts)).toEqual(gitlabPipelineOld("alb-api", opts));
19
+ });
20
+
21
+ test("gitlabPipeline: accepts a StepOutputRef in a typed slot", () => {
22
+ const ref = stepOutput("resolve-ref", "sha");
23
+ const step = gitlabPipeline("alb-api", { ref });
24
+ expect(step.args?.ref).toBe(ref);
25
+ });
26
+
27
+ test("gitlabPipeline: .out is reachable when an id is given", () => {
28
+ const step = gitlabPipeline("alb-api", { id: "pipeline" });
29
+ const ref: StepOutputRef = step.out.name;
30
+ expect(ref.step).toBe("pipeline");
31
+ });
32
+ });
33
+
34
+ // ── Compile-time-only: authoring-time type errors (never executed) ──────────
35
+ function _typeChecksOnly(): void {
36
+ // @ts-expect-error — "project" is not a key of GitlabPipelineArgs (the
37
+ // field is `name`, and it's positional here besides).
38
+ gitlabPipeline("alb-api", { project: "group/other" });
39
+
40
+ // @ts-expect-error — intervalMs must be a number.
41
+ gitlabPipeline("alb-api", { intervalMs: "15000" });
42
+ }
43
+ void _typeChecksOnly;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Typed step-builder wrapper for this lexicon's `gitlabPipeline` activity
3
+ * (chant #1288 Stage 2 — "regenerate the step builders as fully typed
4
+ * wrappers"). Core cannot import a lexicon's `*Args` types (lexicons depend
5
+ * on core, not the other way around), so a fully typed `gitlabPipeline` has
6
+ * to live beside {@link GitlabPipelineArgs} — here, next to
7
+ * `./activities/gitlab.ts`. `opts`'s type below IS `GitlabPipelineArgs`
8
+ * itself (via `Omit`/`WithStepRefs`) — never a hand-restated mirror.
9
+ *
10
+ * `core`'s own `gitlabPipeline` (in `@intentius/chant/op`, re-exported from
11
+ * `@intentius/chant-lexicon-temporal`) is UNCHANGED and produces a
12
+ * byte-identical `ActivityStep` for the same inputs — purely additive, and
13
+ * deliberately not swapped into the temporal barrel (see
14
+ * `lexicons/k8s/src/op/builders.ts`'s module doc for why: that would make
15
+ * temporal depend on this package at runtime). An author who wants the typed
16
+ * surface imports it from here — `@intentius/chant-lexicon-gitlab`.
17
+ */
18
+
19
+ import {
20
+ activity,
21
+ takeProfileAndId,
22
+ type ActivityStep,
23
+ type NamedActivityStep,
24
+ type WithStepRefs,
25
+ } from "@intentius/chant/op";
26
+ import type { GitlabPipelineArgs } from "./activities/gitlab";
27
+
28
+ /**
29
+ * Trigger and wait for a GitLab CI pipeline to complete — the fully typed
30
+ * twin of core's `gitlabPipeline`. `opts` is {@link GitlabPipelineArgs}
31
+ * itself, minus the positional `name`. Defaults to the `longInfra` profile.
32
+ */
33
+ export const gitlabPipeline = (
34
+ name: string,
35
+ opts?: WithStepRefs<Omit<GitlabPipelineArgs, "name">> & { profile?: ActivityStep["profile"]; id?: string },
36
+ ): NamedActivityStep => {
37
+ const { args, profile, id } = takeProfileAndId(opts as Record<string, unknown> | undefined);
38
+ return activity("gitlabPipeline", { name, ...args }, { profile: profile ?? "longInfra", ...(id ? { id } : {}) });
39
+ };
@@ -87,7 +87,7 @@ describe("gitlabPlugin", () => {
87
87
 
88
88
  test("returns post-synth checks", () => {
89
89
  const checks = gitlabPlugin.postSynthChecks!();
90
- expect(checks).toHaveLength(39);
90
+ expect(checks).toHaveLength(41);
91
91
  const ids = checks.map((c) => c.id);
92
92
  expect(ids).toContain("WGL010");
93
93
  expect(ids).toContain("WGL011");
package/src/plugin.ts CHANGED
@@ -23,12 +23,15 @@ import { gitlabHover } from "./lsp/hover";
23
23
  import { GitLabParser } from "./import/parser";
24
24
  import { GitLabGenerator } from "./import/generator";
25
25
  import { generateGitlabPipeline } from "./components/generate-pipeline";
26
+ import { generateGitlabOpPipeline } from "./components/generate-op-pipeline";
26
27
 
27
28
  export const gitlabPlugin: LexiconPlugin = {
28
29
  name: "gitlab",
29
30
  auditCatalog: () => gitlabAuditCatalog,
30
31
  // Generate mode (#688): synthesize a .gitlab-ci.yml from the component graph.
31
32
  generateComponentPipeline: (components, options) => generateGitlabPipeline(components, options),
33
+ // Generate mode, Op counterpart (#927): scheduled Op → GitLab CI job.
34
+ generateOpPipeline: (ops, options) => generateGitlabOpPipeline(ops, options),
32
35
  // Self-upgrade: where the pinned GitLab schema version lives + its upstream (#685).
33
36
  upstreamPin: {
34
37
  file: "src/codegen/fetch.ts",