@intentius/chant-lexicon-gitlab 0.53.1 → 0.54.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.
@@ -1 +1 @@
1
- {"version":3,"file":"generate-pipeline.d.ts","sourceRoot":"","sources":["../../src/components/generate-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,KAAK,EACV,oBAAoB,IAAI,YAAY,EACpC,wBAAwB,IAAI,qBAAqB,EACjD,uBAAuB,IAAI,oBAAoB,EAChD,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;AAS1E;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CA+EtB"}
1
+ {"version":3,"file":"generate-pipeline.d.ts","sourceRoot":"","sources":["../../src/components/generate-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,KAAK,EACV,oBAAoB,IAAI,YAAY,EACpC,wBAAwB,IAAI,qBAAqB,EACjD,uBAAuB,IAAI,oBAAoB,EAChD,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;AAS1E;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAqFtB"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "ca204e316f0225bf3ebc1336e5e0cb32daf98e8e958f16cc6565def3dc1c17d8",
4
+ "manifest.json": "806f8315836161b6b23f6f175528bb58ec17f6448e241bdd04f56726b1d1d3d5",
5
5
  "meta.json": "931fc3246a55645b1493080bbeb160e5d205e42349e8bdca96ca243adb5f0da3",
6
6
  "types/index.d.ts": "5cd2e99f135a929b72bdd822d00d780d39b1cd407ba0cfb3d511c7ac9d667b58",
7
7
  "rules/artifact-no-expiry.ts": "3f3cabf9792cbf8207e53a25f506715466b19ec25e9c3b4d0d77fed6b2eb4542",
@@ -55,5 +55,5 @@
55
55
  "skills/chant-gitlab-migrate.md": "4853d04980560b379e5b0f7267dcb0a1e5d5879cb9e9931681ce76b2a5fe69d8",
56
56
  "skills/chant-gitlab-patterns.md": "6d9a44e9e8de4c3820be9d65381b0d2ede4cb3626aaaf0011e21838a9fbf556e"
57
57
  },
58
- "composite": "c89df7e7ca6b30838a49a3def44be2be408ab6cd7c737f2239f6796ddad8b0ef"
58
+ "composite": "05b06811191671c96703ccd8387152231daa54b5048fe07747a08a3ed09a7837"
59
59
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab",
3
- "version": "0.53.1",
3
+ "version": "0.54.0",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "GitLab",
6
6
  "intrinsics": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-gitlab",
3
- "version": "0.53.1",
3
+ "version": "0.54.0",
4
4
  "description": "GitLab CI lexicon for chant — declarative IaC in TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -67,8 +67,8 @@
67
67
  "typescript": "^5.9.3"
68
68
  },
69
69
  "peerDependencies": {
70
- "@intentius/chant": "^0.53.1",
71
- "@intentius/chant-lexicon-github": "^0.53.1",
70
+ "@intentius/chant": "^0.54.0",
71
+ "@intentius/chant-lexicon-github": "^0.54.0",
72
72
  "typescript": "^5.9.3"
73
73
  },
74
74
  "peerDependenciesMeta": {
@@ -213,12 +213,33 @@ describe("generateGitlabPipeline: a cross-cutting change is one generator edit,
213
213
  });
214
214
 
215
215
  describe("generateGitlabPipeline: options", () => {
216
- test("emits a variables: block when provided", () => {
216
+ test("merges caller variables into the variables: block alongside CHANT_ENV", () => {
217
217
  const result = generateGitlabPipeline(pilotComponents(), {
218
- variables: { CHANT_ENV: "staging" },
218
+ env: "staging",
219
+ variables: { AWS_REGION: "eu-west-1" },
219
220
  });
220
221
  const parsed = parseYAML(result.yaml);
221
- expect(parsed.variables).toEqual({ CHANT_ENV: "staging" });
222
+ expect(parsed.variables).toEqual({ AWS_REGION: "eu-west-1", CHANT_ENV: "staging" });
223
+ });
224
+
225
+ test("the document carries its environment identity: workflow name + CHANT_ENV (#2046)", () => {
226
+ const staging = generateGitlabPipeline(pilotComponents(), { env: "staging" });
227
+ const prod = generateGitlabPipeline(pilotComponents());
228
+
229
+ expect(parseYAML(staging.yaml).workflow).toEqual({ name: "chant-components-staging" });
230
+ expect(parseYAML(prod.yaml).workflow).toEqual({ name: "chant-components-production" });
231
+ expect(parseYAML(staging.yaml).variables).toEqual({ CHANT_ENV: "staging" });
232
+
233
+ expect(staging.env).toBe("staging");
234
+ expect(prod.env).toBe("production");
235
+ });
236
+
237
+ test("CHANT_ENV always reflects the environment baked into the script lines — a caller variable cannot override it", () => {
238
+ const result = generateGitlabPipeline(pilotComponents(), {
239
+ env: "staging",
240
+ variables: { CHANT_ENV: "prod" },
241
+ });
242
+ expect((parseYAML(result.yaml).variables as Record<string, unknown>).CHANT_ENV).toBe("staging");
222
243
  });
223
244
 
224
245
  test("uses a custom image for every job when provided", () => {
@@ -90,10 +90,15 @@ export function generateGitlabPipeline(
90
90
  }
91
91
 
92
92
  const doc: Record<string, unknown> = {};
93
+ // `workflow:name` + a CHANT_ENV variable give the document a recoverable
94
+ // environment identity (#2046): two pipelines generated for two
95
+ // environments were previously identical except for one shell argument in
96
+ // each job's `script:`. CHANT_ENV always reflects the environment baked
97
+ // into the run lines, so a caller-supplied variable of the same name cannot
98
+ // make the document lie about what its jobs deploy.
99
+ doc.workflow = { name: `chant-components-${env}` };
93
100
  doc.stages = stages;
94
- if (options.variables && Object.keys(options.variables).length > 0) {
95
- doc.variables = options.variables;
96
- }
101
+ doc.variables = { ...options.variables, CHANT_ENV: env };
97
102
 
98
103
  waves.forEach((wave, waveIndex) => {
99
104
  const stage = stages[waveIndex];
@@ -131,6 +136,7 @@ export function generateGitlabPipeline(
131
136
  // `stages:[]` is the plain scalar "stages:[]" — a colon opens a mapping only
132
137
  // when whitespace or the line's end follows it — which is how GitLab's own
133
138
  // reader takes it, and now how `parseYAML` does too (chant #2013).
139
+ sections.push("workflow:" + emitYAML(doc.workflow, 1));
134
140
  sections.push(stages.length > 0 ? "stages:" + emitYAML(stages, 1) : "stages: []");
135
141
  if (doc.variables) sections.push("variables:" + emitYAML(doc.variables, 1));
136
142
  for (const job of jobs) {
@@ -138,5 +144,5 @@ export function generateGitlabPipeline(
138
144
  sections.push(`${job.jobName}:` + emitYAML(props, 1));
139
145
  }
140
146
 
141
- return { yaml: sections.join("\n\n") + "\n", stages, jobs };
147
+ return { yaml: sections.join("\n\n") + "\n", stages, jobs, env };
142
148
  }