@7n/rules-ci-github 2.2.1 → 2.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.3.1] - 2026-08-19
4
+
5
+ ### Changed
6
+
7
+ - дозволено preinstalled ci-tools у lint-ga policy
8
+
9
+ ## [2.3.0] - 2026-08-01
10
+
11
+ ### Added
12
+
13
+ - `ga/workflow_common`: маркер `n-rules:allow-<pattern>` у тілі кроку знімає заборону конкретного підрядка саме для цього кроку — потрібно там, де composite `setup-bun-deps` принципово не підходить (він робить `--frozen-lockfile`, а крок навмисно перегенеровує lock)
14
+
3
15
  ## [2.2.1] - 2026-07-30
4
16
 
5
17
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7n/rules-ci-github",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "description": "Плагін @7n/rules: канон GitHub Actions (.github/workflows) — обов'язкові workflow, zizmor, VS Code",
5
5
  "keywords": [
6
6
  "github-actions",
@@ -19,4 +19,12 @@ Rego-пакет: `ga.lint_ga`
19
19
  - `steps[*].run` (сукупно) — містить `open-policy-agent/conftest` (Install conftest)
20
20
  - `steps[*].run` (сукупно) — містить `n-rules lint ga --no-fix`
21
21
 
22
+ ### Preinstalled `ci-tools`
23
+
24
+ Forgejo runner може мапити сумісну мітку `ubuntu-latest` на власний образ, де вже
25
+ встановлені `uv` і `conftest`. Для цього workflow декларативно встановлює
26
+ `jobs.lint-ga.env.NITRA_CI_TOOLS: 'true'`. За цієї явної opt-in policy не вимагає
27
+ `astral-sh/setup-uv` і крок завантаження Conftest; `checkout`, локальний
28
+ `setup-bun-deps` і `n-rules lint ga --no-fix` лишаються обов'язковими.
29
+
22
30
  Канон: [lint-ga.yml.snippet.yml](./template/lint-ga.yml.snippet.yml)
@@ -43,6 +43,24 @@ expected_uses_set contains u if {
43
43
  u != ""
44
44
  }
45
45
 
46
+ # Opt-in для runner-образу, у якому вже є uv та conftest. Мітка runner
47
+ # залишається `ubuntu-latest` для сумісності, але workflow явно декларує
48
+ # джерело tooling, щоб policy не приховувала залежність від custom image.
49
+ preinstalled_ci_tools if object.get(object.get(job, "env", {}), "NITRA_CI_TOOLS", false) == true
50
+
51
+ preinstalled_ci_tools if object.get(object.get(job, "env", {}), "NITRA_CI_TOOLS", "false") == "true"
52
+
53
+ required_uses_set contains u if {
54
+ not preinstalled_ci_tools
55
+ some u in expected_uses_set
56
+ }
57
+
58
+ required_uses_set contains u if {
59
+ preinstalled_ci_tools
60
+ some u in expected_uses_set
61
+ not startswith(u, "astral-sh/setup-uv@")
62
+ }
63
+
46
64
  # Required `run:` substrings — collected from steps with `run`.
47
65
  expected_run_blob := concat("\n", [r |
48
66
  some step in data.template.snippet.jobs["lint-ga"].steps
@@ -98,12 +116,13 @@ deny contains msg if {
98
116
  }
99
117
 
100
118
  deny contains msg if {
101
- some required_use in expected_uses_set
119
+ some required_use in required_uses_set
102
120
  not job_has_use_satisfying(required_use)
103
121
  msg := sprintf("lint-ga.yml: має бути uses: %s (ga.mdc)", [required_use])
104
122
  }
105
123
 
106
124
  deny contains msg if {
125
+ not preinstalled_ci_tools
107
126
  expected_run_blob != ""
108
127
  not contains(job_run_blob, "open-policy-agent/conftest")
109
128
  msg := "lint-ga.yml: має бути крок Install conftest (ga.mdc)"
@@ -93,12 +93,23 @@ all_flat_steps contains entry if {
93
93
  }
94
94
 
95
95
  # ── deny: заборонені setup-bun/cache/install у будь-якому кроці ────────────
96
+ #
97
+ # Санкціонований виняток — маркер `n-rules:allow-<pattern>` у самому кроці
98
+ # (`bun install` → `n-rules:allow-bun-install`). Потрібен там, де composite
99
+ # `setup-bun-deps` принципово не підходить: він робить `--frozen-lockfile`, а
100
+ # крок навмисно ПЕРЕгенеровує lock (реліз-синк платформних пінів). Маркер
101
+ # живе в тілі кроку, тож виняток вузький (лише цей крок), видимий у diff-і й
102
+ # вимагає свідомого рішення автора — на відміну від синоніма команди, який
103
+ # обходив би правило нишком.
104
+ allow_marker(pattern) := sprintf("n-rules:allow-%s", [replace(pattern, " ", "-")])
96
105
 
97
106
  deny contains msg if {
98
107
  some entry in all_flat_steps
99
108
  some pattern, hint in forbidden_step_substrings
100
- step_uses_or_run_blob(entry.step) != ""
101
- contains(step_uses_or_run_blob(entry.step), pattern)
109
+ blob := step_uses_or_run_blob(entry.step)
110
+ blob != ""
111
+ contains(blob, pattern)
112
+ not contains(blob, allow_marker(pattern))
102
113
  msg := sprintf("jobs.%s.steps[%d]: %s (ga.mdc)", [entry.job_id, entry.step_index, hint])
103
114
  }
104
115