@intentius/chant-lexicon-gitlab 0.124.29 → 0.124.31

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,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "0af87c8b86a1431e32c66adf51bf75e14c571af75f6761294acef0962764e4c6",
4
+ "manifest.json": "63c7379cd49d05603a54529fa139575f02ceb7e3241a931bb15b9e35c8ffecb7",
5
5
  "meta.json": "db082fbf90c5941c498b2bee0f106103449c1a4c257716ca2220f0dd490450b2",
6
6
  "types/index.d.ts": "a048a66ebe20da0cb5fc889054cac69044d9bf882e2c56b5c5bf113d1f3ba57c",
7
7
  "rules/artifact-no-expiry.ts": "0ca5bb972d4a542126e8a0229d43b55658394cb7dd9b9923b2c590bec1c2ad7d",
@@ -55,5 +55,5 @@
55
55
  "skills/chant-gitlab-migrate.md": "4853d04980560b379e5b0f7267dcb0a1e5d5879cb9e9931681ce76b2a5fe69d8",
56
56
  "skills/chant-gitlab-patterns.md": "6d9a44e9e8de4c3820be9d65381b0d2ede4cb3626aaaf0011e21838a9fbf556e"
57
57
  },
58
- "composite": "0bb737bc06a94be6ceecfbe6eb7814ae11ce8b1f137fa0a33df7ae2998c61733"
58
+ "composite": "fa8097c773e5d6b8d94a7ab984b8e02f66fd29ec7bc817974632acf927b7103f"
59
59
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab",
3
- "version": "0.124.29",
3
+ "version": "0.124.31",
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.124.29",
3
+ "version": "0.124.31",
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.124.29",
71
- "@intentius/chant-lexicon-github": "^0.124.29"
70
+ "@intentius/chant": "^0.124.31",
71
+ "@intentius/chant-lexicon-github": "^0.124.31"
72
72
  },
73
73
  "peerDependenciesMeta": {
74
74
  "@intentius/chant-lexicon-github": {
@@ -0,0 +1,55 @@
1
+ workflow:
2
+ name: chant-pr-prod
3
+ rules:
4
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
5
+ - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
6
+
7
+ stages:
8
+ - plan
9
+ - apply
10
+
11
+ variables:
12
+ CHANT_ENV: prod
13
+ GIT_DEPTH: '0'
14
+
15
+ plan:
16
+ stage: plan
17
+ image: node:22
18
+ rules:
19
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
20
+ variables:
21
+ BASE_SHA: '$CI_MERGE_REQUEST_DIFF_BASE_SHA'
22
+ PR_NUMBER: '$CI_MERGE_REQUEST_IID'
23
+ script:
24
+ - command -v tofu >/dev/null 2>&1 || (curl -fsSL https://get.opentofu.org/install-opentofu.sh -o /tmp/install-opentofu.sh && sh /tmp/install-opentofu.sh --install-method standalone)
25
+ - chant build --env prod
26
+ - chant lint
27
+ - chant components pr-plan --base "$BASE_SHA" --pr "$PR_NUMBER" --env prod --gate pr-apply --output .chant/pr --forge gitlab
28
+ artifacts:
29
+ when: always
30
+ paths:
31
+ - .chant/pr
32
+
33
+ apply:
34
+ stage: apply
35
+ image: node:22
36
+ resource_group: chant-apply-prod
37
+ rules:
38
+ - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
39
+ variables:
40
+ BASE_SHA: '$CI_COMMIT_BEFORE_SHA'
41
+ script:
42
+ - command -v tofu >/dev/null 2>&1 || (curl -fsSL https://get.opentofu.org/install-opentofu.sh -o /tmp/install-opentofu.sh && sh /tmp/install-opentofu.sh --install-method standalone)
43
+ - if [ -z "$BASE_SHA" ] || [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then BASE_SHA="${CI_MERGE_REQUEST_DIFF_BASE_SHA:-}"; if [ -z "$BASE_SHA" ]; then git fetch origin $CI_DEFAULT_BRANCH && BASE_SHA="$(git merge-base FETCH_HEAD "$CI_COMMIT_SHA")"; if [ "$BASE_SHA" = "$CI_COMMIT_SHA" ]; then BASE_SHA="$(git rev-parse "$CI_COMMIT_SHA^")"; fi; fi; fi; export BASE_SHA
44
+ - chant build --env prod
45
+ - chant lint
46
+ - chant components pr-apply --base "$BASE_SHA" --env prod --gate pr-apply --output .chant/pr --forge gitlab --require-review --resume .chant/pr-resume/pr-apply.json
47
+ cache:
48
+ key: chant-apply-prod-$CI_COMMIT_SHA
49
+ paths:
50
+ - .chant/pr-resume/pr-apply.json
51
+ when: always
52
+ artifacts:
53
+ when: always
54
+ paths:
55
+ - .chant/pr
@@ -302,7 +302,7 @@ function prLoopGitlabPipeline(
302
302
  const onMerge = gitlabPushRule(loop.branch ? JSON.stringify(loop.branch) : "$CI_DEFAULT_BRANCH");
303
303
  // A member's jobs start in its directory, after the image's install lines.
304
304
  const enter = rooted ? [] : [`cd ${memberShellDir(member!)}`];
305
- const script = (job: typeof plan): string[] => [...prLoopSetup(image), ...enter, ...beforeScript, ...(job.setup ?? []), job.command, ...extraScript];
305
+ const script = (job: typeof plan): string[] => [...prLoopSetup(image), ...enter, ...beforeScript, ...(job.setup ?? []), ...(job.build ?? []), job.command, ...extraScript];
306
306
  const stages = ["plan", "apply"];
307
307
  const doc: Record<string, unknown> = {
308
308
  // Included files merge their top-level keys, so a member's file carries
@@ -135,3 +135,35 @@ describe("the merge-request pipeline's branch (#3765)", () => {
135
135
  expect(() => generateGitlabPipeline(ESTATE, { env: "prod", prLoop: { branch: "re$lease" } })).toThrow(/filters on branch "re\$lease"/);
136
136
  });
137
137
  });
138
+
139
+ describe("the gitlab pull-request pipeline with build (#4088)", () => {
140
+ const result = generateGitlabPipeline(ESTATE, { env: "prod", prLoop: { build: true } });
141
+ const doc = parseYAML(result.yaml) as Record<string, any>;
142
+ const golden = join(import.meta.dirname, "__fixtures__", "pr-loop-build.gitlab.golden.yml");
143
+
144
+ test("matches its golden", () => {
145
+ if (process.env.UPDATE_GOLDEN) writeFileSync(golden, result.yaml);
146
+ expect(result.yaml).toBe(readFileSync(golden, "utf-8"));
147
+ });
148
+
149
+ test("builds, then lints, before pr-plan and pr-apply", () => {
150
+ const script = (job: string) => (doc[job] as { script: string[] }).script;
151
+ for (const job of ["plan", "apply"]) {
152
+ const lines = script(job);
153
+ const i = lines.findIndex((l) => l.startsWith("chant components pr-"));
154
+ expect(lines.slice(i - 2, i)).toEqual(["chant build --env prod", "chant lint"]);
155
+ }
156
+ });
157
+
158
+ test("buildCommand replaces the build line and turns the option on", () => {
159
+ const yaml = generateGitlabPipeline(ESTATE, { env: "prod", prLoop: { buildCommand: "npm run build" } }).yaml;
160
+ expect(yaml).toContain("npm run build");
161
+ expect(yaml).not.toContain("chant build --env");
162
+ expect(yaml).toContain("chant lint");
163
+ });
164
+
165
+ test("the default output carries neither line", () => {
166
+ const plain = generateGitlabPipeline(ESTATE, { env: "prod", prLoop: {} }).yaml;
167
+ expect(plain).not.toContain("chant lint");
168
+ });
169
+ });