@intentius/chant 0.124.44 → 0.124.46
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/dist/capabilities/aws.paths +148 -0
- package/dist/capabilities/base-mappings.json +122 -0
- package/dist/capabilities/catalog.d.ts +89 -0
- package/dist/capabilities/catalog.d.ts.map +1 -0
- package/dist/capabilities/catalog.js +204 -0
- package/dist/capabilities/language.d.ts +103 -0
- package/dist/capabilities/language.d.ts.map +1 -0
- package/dist/capabilities/language.js +335 -0
- package/dist/capabilities/matcher.d.ts +65 -0
- package/dist/capabilities/matcher.d.ts.map +1 -0
- package/dist/capabilities/matcher.js +299 -0
- package/dist/capabilities/view.d.ts +207 -0
- package/dist/capabilities/view.d.ts.map +1 -0
- package/dist/capabilities/view.js +484 -0
- package/dist/ci-identity.d.ts +183 -12
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +362 -53
- package/dist/cli/commands/lint.d.ts.map +1 -1
- package/dist/cli/commands/lint.js +1 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +17 -1
- package/dist/cli/handlers/declared-graph.d.ts +44 -0
- package/dist/cli/handlers/declared-graph.d.ts.map +1 -0
- package/dist/cli/handlers/declared-graph.js +87 -0
- package/dist/cli/handlers/graph.d.ts +25 -0
- package/dist/cli/handlers/graph.d.ts.map +1 -1
- package/dist/cli/handlers/graph.js +93 -87
- package/dist/cli/handlers/pr-env.d.ts +8 -2
- package/dist/cli/handlers/pr-env.d.ts.map +1 -1
- package/dist/cli/handlers/pr-env.js +127 -225
- package/dist/cli/handlers/pr.d.ts +3 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +1 -0
- package/dist/cli/handlers/search-count.d.ts +89 -0
- package/dist/cli/handlers/search-count.d.ts.map +1 -0
- package/dist/cli/handlers/search-count.js +132 -0
- package/dist/cli/handlers/search.d.ts +358 -6
- package/dist/cli/handlers/search.d.ts.map +1 -1
- package/dist/cli/handlers/search.js +1065 -155
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +23 -3
- package/dist/cli/mcp/server.d.ts.map +1 -1
- package/dist/cli/mcp/server.js +3 -0
- package/dist/cli/mcp/tools/capabilities.d.ts +7 -0
- package/dist/cli/mcp/tools/capabilities.d.ts.map +1 -0
- package/dist/cli/mcp/tools/capabilities.js +27 -0
- package/dist/cli/mcp/workspace-tools.d.ts +3 -1
- package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
- package/dist/cli/mcp/workspace-tools.js +47 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +64 -17
- package/dist/cli/registry.d.ts +22 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/cli-support.d.ts +2 -0
- package/dist/components/cli-support.d.ts.map +1 -1
- package/dist/components/cli-support.js +4 -2
- package/dist/components/fan-out-support.d.ts +3 -0
- package/dist/components/fan-out-support.d.ts.map +1 -1
- package/dist/components/fan-out-support.js +1 -1
- package/dist/components/pr-env-ports.d.ts +29 -0
- package/dist/components/pr-env-ports.d.ts.map +1 -0
- package/dist/components/pr-env-ports.js +77 -0
- package/dist/components/pr-env-run.d.ts +254 -0
- package/dist/components/pr-env-run.d.ts.map +1 -0
- package/dist/components/pr-env-run.js +376 -0
- package/dist/components/pr-environment.d.ts +91 -15
- package/dist/components/pr-environment.d.ts.map +1 -1
- package/dist/components/pr-environment.js +95 -9
- package/dist/components/pr-pipeline.d.ts +10 -1
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/config-environments.d.ts +92 -0
- package/dist/config-environments.d.ts.map +1 -0
- package/dist/config-environments.js +102 -0
- package/dist/config.d.ts +24 -84
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -96
- package/dist/graph-detail.d.ts.map +1 -1
- package/dist/graph-detail.js +15 -3
- package/dist/graph-effective.d.ts +33 -2
- package/dist/graph-effective.d.ts.map +1 -1
- package/dist/graph-effective.js +215 -68
- package/dist/graph-ir.d.ts +23 -0
- package/dist/graph-ir.d.ts.map +1 -1
- package/dist/graph-ir.js +130 -0
- package/dist/graph-sub-template.d.ts +11 -0
- package/dist/graph-sub-template.d.ts.map +1 -0
- package/dist/graph-sub-template.js +19 -0
- package/dist/lexicon.d.ts +9 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/observe.d.ts +28 -0
- package/dist/lifecycle/observe.d.ts.map +1 -1
- package/dist/lifecycle/observe.js +23 -1
- package/dist/lint/rule.d.ts +6 -0
- package/dist/lint/rule.d.ts.map +1 -1
- package/dist/live-endpoint.d.ts +1 -1
- package/dist/live-endpoint.d.ts.map +1 -1
- package/dist/live-endpoint.js +1 -1
- package/dist/observation.d.ts +48 -1
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +21 -5
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/op/op-waves.d.ts +17 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +23 -1
- package/dist/pr-forge.d.ts +15 -1
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +28 -16
- package/dist/pr-requires.d.ts +5 -1
- package/dist/pr-requires.d.ts.map +1 -1
- package/dist/wave-runtime.mjs +251 -250
- package/dist/workspace/capabilities-contract.d.ts +66 -0
- package/dist/workspace/capabilities-contract.d.ts.map +1 -0
- package/dist/workspace/capabilities-contract.js +107 -0
- package/dist/workspace/capabilities.schema.json +229 -0
- package/dist/workspace/ci-cloud-identity.d.ts +3 -1
- package/dist/workspace/ci-cloud-identity.d.ts.map +1 -1
- package/dist/workspace/ci-cloud-identity.js +16 -1
- package/dist/workspace/ci-run.d.ts +35 -8
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +95 -21
- package/dist/workspace/ci-secrets.d.ts.map +1 -1
- package/dist/workspace/ci-secrets.js +4 -3
- package/dist/workspace/compose-graph.d.ts +9 -0
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/compose-graph.js +3 -1
- package/dist/workspace/conformance/index.d.ts +1 -1
- package/dist/workspace/conformance/index.d.ts.map +1 -1
- package/dist/workspace/conformance/index.js +39 -2
- package/dist/workspace/declaration.d.ts +10 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +17 -1
- package/dist/workspace/declaration.schema.json +36 -1
- package/dist/workspace/graph-cache.d.ts +8 -0
- package/dist/workspace/graph-cache.d.ts.map +1 -1
- package/dist/workspace/graph-cache.js +27 -3
- package/dist/workspace/graph-cli.d.ts +39 -2
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +66 -24
- package/dist/workspace/graph.schema.json +148 -0
- package/dist/workspace/kind-readers.d.ts +3 -0
- package/dist/workspace/kind-readers.d.ts.map +1 -1
- package/dist/workspace/kind-readers.js +7 -1
- package/dist/workspace/member-commands.d.ts +10 -1
- package/dist/workspace/member-commands.d.ts.map +1 -1
- package/dist/workspace/member-commands.js +17 -1
- package/dist/workspace/nested-graph.d.ts +2 -0
- package/dist/workspace/nested-graph.d.ts.map +1 -1
- package/dist/workspace/nested-graph.js +32 -1
- package/dist/workspace/reason-codes.d.ts +10 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +12 -0
- package/dist/workspace/search-cli.d.ts +204 -0
- package/dist/workspace/search-cli.d.ts.map +1 -0
- package/dist/workspace/search-cli.js +466 -0
- package/dist/workspace/search-contract.d.ts +56 -0
- package/dist/workspace/search-contract.d.ts.map +1 -0
- package/dist/workspace/search-contract.js +70 -0
- package/dist/workspace/search.schema.json +822 -0
- package/package.json +1 -1
- package/src/__snapshots__/okf.test.ts.snap +10 -0
- package/src/capabilities/aws.paths +148 -0
- package/src/capabilities/base-mappings.json +122 -0
- package/src/capabilities/catalog.ts +230 -0
- package/src/capabilities/language.test.ts +191 -0
- package/src/capabilities/language.ts +373 -0
- package/src/capabilities/matcher.ts +315 -0
- package/src/capabilities/view-compose.test.ts +76 -0
- package/src/capabilities/view.ts +631 -0
- package/src/ci-identity-targets.test.ts +275 -0
- package/src/ci-identity.ts +394 -61
- package/src/cli/commands/lint.ts +1 -0
- package/src/cli/handlers/build.ts +15 -1
- package/src/cli/handlers/declared-graph.ts +99 -0
- package/src/cli/handlers/graph.test.ts +94 -3
- package/src/cli/handlers/graph.ts +123 -96
- package/src/cli/handlers/pr-env.ts +135 -227
- package/src/cli/handlers/pr.ts +4 -0
- package/src/cli/handlers/search-build-roots.test.ts +144 -0
- package/src/cli/handlers/search-count.test.ts +191 -0
- package/src/cli/handlers/search-count.ts +165 -0
- package/src/cli/handlers/search-json.test.ts +333 -0
- package/src/cli/handlers/search-live.test.ts +387 -0
- package/src/cli/handlers/search-paths.test.ts +235 -0
- package/src/cli/handlers/search.ts +1312 -166
- package/src/cli/main.test.ts +28 -3
- package/src/cli/main.ts +23 -3
- package/src/cli/mcp/server.test.ts +3 -3
- package/src/cli/mcp/server.ts +3 -0
- package/src/cli/mcp/tools/capabilities.ts +32 -0
- package/src/cli/mcp/workspace-tools.e2e.test.ts +21 -1
- package/src/cli/mcp/workspace-tools.ts +47 -2
- package/src/cli/parse-args.ts +52 -13
- package/src/cli/registry.ts +22 -0
- package/src/components/cli-support.ts +6 -1
- package/src/components/fan-out-support.ts +4 -1
- package/src/components/pr-env-ports.ts +89 -0
- package/src/components/pr-env-run-bundle.test.ts +54 -0
- package/src/components/pr-env-run.test.ts +290 -0
- package/src/components/pr-env-run.ts +563 -0
- package/src/components/pr-environment.ts +161 -13
- package/src/components/pr-pipeline.ts +10 -1
- package/src/config-environments.ts +133 -0
- package/src/config.ts +37 -124
- package/src/graph-detail.ts +15 -3
- package/src/graph-effective.ts +226 -75
- package/src/graph-ir.test.ts +163 -0
- package/src/graph-ir.ts +147 -0
- package/src/graph-sub-template.ts +22 -0
- package/src/lexicon.ts +10 -0
- package/src/lifecycle/observe.test.ts +27 -1
- package/src/lifecycle/observe.ts +43 -1
- package/src/lint/rule.ts +6 -0
- package/src/live-endpoint.ts +1 -1
- package/src/observation.test.ts +25 -0
- package/src/observation.ts +69 -5
- package/src/op/op-waves.ts +38 -1
- package/src/pr-forge-bundle.test.ts +1 -1
- package/src/pr-forge.ts +44 -17
- package/src/pr-requires.test.ts +43 -6
- package/src/pr-requires.ts +5 -1
- package/src/workspace/capabilities-contract.test.ts +88 -0
- package/src/workspace/capabilities-contract.ts +132 -0
- package/src/workspace/capabilities.schema.json +229 -0
- package/src/workspace/ci-cloud-identity.test.ts +20 -0
- package/src/workspace/ci-cloud-identity.ts +14 -1
- package/src/workspace/ci-run.test.ts +74 -1
- package/src/workspace/ci-run.ts +122 -29
- package/src/workspace/ci-secrets.test.ts +1 -1
- package/src/workspace/ci-secrets.ts +4 -3
- package/src/workspace/compose-graph.ts +10 -1
- package/src/workspace/conformance/conformance.e2e.test.ts +14 -1
- package/src/workspace/conformance/index.ts +31 -2
- package/src/workspace/declaration.schema.json +36 -1
- package/src/workspace/declaration.test.ts +7 -0
- package/src/workspace/declaration.ts +24 -2
- package/src/workspace/graph-cache.ts +27 -3
- package/src/workspace/graph-cli.ts +96 -24
- package/src/workspace/graph.schema.json +148 -0
- package/src/workspace/kind-readers.e2e.test.ts +28 -0
- package/src/workspace/kind-readers.test.ts +1 -1
- package/src/workspace/kind-readers.ts +7 -1
- package/src/workspace/member-commands.ts +22 -1
- package/src/workspace/nested-graph.ts +32 -1
- package/src/workspace/reason-codes.test.ts +7 -0
- package/src/workspace/reason-codes.ts +12 -0
- package/src/workspace/search-cli.e2e.test.ts +305 -0
- package/src/workspace/search-cli.ts +591 -0
- package/src/workspace/search-contract.ts +95 -0
- package/src/workspace/search.schema.json +822 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://intentius.io/chant/schemas/workspace/capabilities/v1/capabilities.schema.json",
|
|
4
|
+
"title": "chant capabilities catalog",
|
|
5
|
+
"description": "What `chant search --capabilities --json` prints (#4375): the capability catalog `chant search` answers `cap:` terms and `->[cap=...]` edges with, each capability's rule, and whether each lexicon the project loads can supply it. chant's MCP `capabilities` tool returns the same document. Version 1 of the read contract. Readers ignore fields they do not know; a field is only ever added within a version. The codes are a closed list, each in the one closed list of `reason-codes.ts`. Contract version 1 of this document is written by chant 0.124.46 and newer; the read contract as a whole by chant 0.81.0 and newer.",
|
|
6
|
+
"oneOf": [
|
|
7
|
+
{
|
|
8
|
+
"$ref": "#/$defs/result"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"$ref": "#/$defs/failure"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"$defs": {
|
|
15
|
+
"result": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"description": "Exit code 0.",
|
|
18
|
+
"required": [
|
|
19
|
+
"$schema",
|
|
20
|
+
"contract",
|
|
21
|
+
"chant",
|
|
22
|
+
"capabilities",
|
|
23
|
+
"helpers"
|
|
24
|
+
],
|
|
25
|
+
"properties": {
|
|
26
|
+
"$schema": {
|
|
27
|
+
"const": "https://intentius.io/chant/schemas/workspace/capabilities/v1/capabilities.schema.json"
|
|
28
|
+
},
|
|
29
|
+
"contract": {
|
|
30
|
+
"const": 1
|
|
31
|
+
},
|
|
32
|
+
"chant": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"error": false,
|
|
36
|
+
"capabilities": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"description": "Every capability the catalog lists, in the order the rule file defines them.",
|
|
39
|
+
"items": {
|
|
40
|
+
"$ref": "#/$defs/capability"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"helpers": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"description": "Rules the capabilities use that the catalog does not list as capabilities of their own.",
|
|
46
|
+
"items": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"required": [
|
|
49
|
+
"name",
|
|
50
|
+
"rule"
|
|
51
|
+
],
|
|
52
|
+
"properties": {
|
|
53
|
+
"name": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"rule": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"capability": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"required": [
|
|
67
|
+
"name",
|
|
68
|
+
"meaning",
|
|
69
|
+
"shape",
|
|
70
|
+
"params",
|
|
71
|
+
"search",
|
|
72
|
+
"answers",
|
|
73
|
+
"depth",
|
|
74
|
+
"lexicons",
|
|
75
|
+
"notEvaluated",
|
|
76
|
+
"uses",
|
|
77
|
+
"rule"
|
|
78
|
+
],
|
|
79
|
+
"properties": {
|
|
80
|
+
"name": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"pattern": "^[a-z][a-z0-9-]*$"
|
|
83
|
+
},
|
|
84
|
+
"meaning": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "What the capability says, in one line."
|
|
87
|
+
},
|
|
88
|
+
"shape": {
|
|
89
|
+
"enum": [
|
|
90
|
+
"set",
|
|
91
|
+
"edge"
|
|
92
|
+
],
|
|
93
|
+
"description": "set: a set of nodes, tested with cap:<name>. edge: pairs of nodes, walked with ->[cap=<name>] or <-[cap=<name>]."
|
|
94
|
+
},
|
|
95
|
+
"params": {
|
|
96
|
+
"type": "array",
|
|
97
|
+
"description": "Arguments, in order: cap:<name>(<a>, <b>). An optional one left out drops the test that reads it.",
|
|
98
|
+
"items": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"required": [
|
|
101
|
+
"name",
|
|
102
|
+
"optional",
|
|
103
|
+
"meaning"
|
|
104
|
+
],
|
|
105
|
+
"properties": {
|
|
106
|
+
"name": {
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
"optional": {
|
|
110
|
+
"type": "boolean"
|
|
111
|
+
},
|
|
112
|
+
"meaning": {
|
|
113
|
+
"type": "string"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"search": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"description": "The search term that asks for it: cap:<name> for a set, ->[cap=<name>] for an edge."
|
|
121
|
+
},
|
|
122
|
+
"answers": {
|
|
123
|
+
"type": "array",
|
|
124
|
+
"description": "Questions it serves, in people's words.",
|
|
125
|
+
"items": {
|
|
126
|
+
"type": "string"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"depth": {
|
|
130
|
+
"enum": [
|
|
131
|
+
"declared",
|
|
132
|
+
"live",
|
|
133
|
+
"either"
|
|
134
|
+
],
|
|
135
|
+
"description": "Which observation can supply its facts: declared source, a live read or snapshot, or either."
|
|
136
|
+
},
|
|
137
|
+
"lexicons": {
|
|
138
|
+
"type": "object",
|
|
139
|
+
"description": "Each lexicon the project loads: supported, or why it can't supply the capability.",
|
|
140
|
+
"additionalProperties": {
|
|
141
|
+
"oneOf": [
|
|
142
|
+
{
|
|
143
|
+
"const": "supported"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "object",
|
|
147
|
+
"required": [
|
|
148
|
+
"code",
|
|
149
|
+
"message"
|
|
150
|
+
],
|
|
151
|
+
"properties": {
|
|
152
|
+
"code": {
|
|
153
|
+
"enum": [
|
|
154
|
+
"lexicon-has-no-mapping",
|
|
155
|
+
"capability-not-derivable",
|
|
156
|
+
"lexicon-not-loaded"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"message": {
|
|
160
|
+
"type": "string"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"notEvaluated": {
|
|
168
|
+
"type": "array",
|
|
169
|
+
"description": "What the rule leaves out. chant search prints this under every answer that uses the capability.",
|
|
170
|
+
"items": {
|
|
171
|
+
"type": "string"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"uses": {
|
|
175
|
+
"type": "array",
|
|
176
|
+
"description": "The capabilities and helpers its rule refers to.",
|
|
177
|
+
"items": {
|
|
178
|
+
"type": "string"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"rule": {
|
|
182
|
+
"type": "string",
|
|
183
|
+
"description": "The rule as written, one alternative per line."
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"failure": {
|
|
188
|
+
"type": "object",
|
|
189
|
+
"description": "Exit code 1.",
|
|
190
|
+
"required": [
|
|
191
|
+
"$schema",
|
|
192
|
+
"contract",
|
|
193
|
+
"chant",
|
|
194
|
+
"error"
|
|
195
|
+
],
|
|
196
|
+
"properties": {
|
|
197
|
+
"$schema": {
|
|
198
|
+
"const": "https://intentius.io/chant/schemas/workspace/capabilities/v1/capabilities.schema.json"
|
|
199
|
+
},
|
|
200
|
+
"contract": {
|
|
201
|
+
"const": 1
|
|
202
|
+
},
|
|
203
|
+
"chant": {
|
|
204
|
+
"type": "string"
|
|
205
|
+
},
|
|
206
|
+
"error": {
|
|
207
|
+
"type": "object",
|
|
208
|
+
"required": [
|
|
209
|
+
"code",
|
|
210
|
+
"message"
|
|
211
|
+
],
|
|
212
|
+
"properties": {
|
|
213
|
+
"code": {
|
|
214
|
+
"enum": [
|
|
215
|
+
"usage-invalid"
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
"message": {
|
|
219
|
+
"type": "string"
|
|
220
|
+
},
|
|
221
|
+
"hint": {
|
|
222
|
+
"type": "string"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -50,4 +50,24 @@ describe("declaredCloudIdentity (#4296)", () => {
|
|
|
50
50
|
const root = workspace({ identity: { cloud: { aws: { rules: [{ plan: "r", apply: "r" }] } } } });
|
|
51
51
|
await expect(declaredCloudIdentity(root, "production")).rejects.toThrow(/plans and applies as r.*\[declaration-invalid\]/);
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
test("rules with targets and a name read from the declaration, and a target glob list may not be empty (#4332)", async () => {
|
|
55
|
+
const root = workspace({
|
|
56
|
+
identity: {
|
|
57
|
+
cloud: {
|
|
58
|
+
aws: {
|
|
59
|
+
rules: [
|
|
60
|
+
{ members: ["net"], targets: ["envs/prod/**"], name: "prod", plan: "arn:aws:iam::1:role/prod-plan", apply: "arn:aws:iam::1:role/prod-apply" },
|
|
61
|
+
{ plan: "arn:aws:iam::1:role/plan", apply: "arn:aws:iam::1:role/apply" },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const net = (await declaredCloudIdentity(join(root, "net"), "production", "net"))!;
|
|
68
|
+
expect(net.plan.aws).toMatchObject({ role: "arn:aws:iam::1:role/plan", targets: [{ targets: ["envs/prod/**"], role: "arn:aws:iam::1:role/prod-plan" }] });
|
|
69
|
+
expect((await declaredCloudIdentity(join(root, "app"), "production", "app"))!.plan.aws!.targets).toBeUndefined();
|
|
70
|
+
const empty = workspace({ identity: { cloud: { aws: { rules: [{ targets: [], plan: "p", apply: "a" }] } } } });
|
|
71
|
+
await expect(declaredCloudIdentity(empty, "production")).rejects.toThrow(/\[declaration-invalid\]/);
|
|
72
|
+
});
|
|
53
73
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { findWorkspaceRoot } from "../project-root";
|
|
10
|
-
import { resolveCloudIdentity, type PipelineCloudIdentity } from "../ci-identity";
|
|
10
|
+
import { resolveCloudIdentity, resolvePrEnvCloudIdentity, type CloudTradeSpec, type PipelineCloudIdentity } from "../ci-identity";
|
|
11
11
|
|
|
12
12
|
/** The plan and apply identities of the pipeline for `env` and `member`, or undefined. */
|
|
13
13
|
export async function declaredCloudIdentity(cwd: string, env: string, member?: string): Promise<PipelineCloudIdentity | undefined> {
|
|
@@ -21,3 +21,16 @@ export async function declaredCloudIdentity(cwd: string, env: string, member?: s
|
|
|
21
21
|
throw Object.assign(new Error(`${err.describe()} [${err.code}]`), { code: err.code });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
/** The trade a pull request environment's jobs take for `member` (#4330, `resolvePrEnvCloudIdentity`), or undefined. */
|
|
26
|
+
export async function declaredPrEnvCloudIdentity(cwd: string, member?: string): Promise<CloudTradeSpec | undefined> {
|
|
27
|
+
const found = findWorkspaceRoot(cwd);
|
|
28
|
+
if (!found) return undefined;
|
|
29
|
+
const [{ readDeclaration, WorkspaceReadError }, { workingTree }] = await Promise.all([import("./declaration"), import("./tree")]);
|
|
30
|
+
try {
|
|
31
|
+
return resolvePrEnvCloudIdentity(readDeclaration(workingTree(found.dir)).ci?.identity?.cloud, member);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (!(err instanceof WorkspaceReadError)) throw err;
|
|
34
|
+
throw Object.assign(new Error(`${err.describe()} [${err.code}]`), { code: err.code });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -26,7 +26,7 @@ import { sshFromEd25519 } from "./trust/dsse";
|
|
|
26
26
|
import { verifyOpRunStatement } from "./trust/op-run-statement";
|
|
27
27
|
import { readRunLedger } from "../lifecycle/run-ledger";
|
|
28
28
|
import { resolveRunId } from "../lifecycle/release-ledger";
|
|
29
|
-
import { prLoopJobs, PR_LOOP_SETUP } from "../components/pr-pipeline";
|
|
29
|
+
import { prEnvJobs, prLoopJobs, PR_LOOP_SETUP } from "../components/pr-pipeline";
|
|
30
30
|
import { parseArgs } from "../cli/parse-args";
|
|
31
31
|
import { ciSecretsFor, readCiSecrets } from "./ci-secrets";
|
|
32
32
|
import { runEventFileName, runEventsDir } from "../run-event-store";
|
|
@@ -1039,3 +1039,76 @@ describe("the plan's steps hold no forge token (#4295)", () => {
|
|
|
1039
1039
|
expect(plan!.command.endsWith(" --no-status")).toBe(true);
|
|
1040
1040
|
});
|
|
1041
1041
|
});
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* #4330: a pull request environment's jobs run through `ci run` too. The
|
|
1045
|
+
* stand-in chant keeps each action's arguments, environment, directory and
|
|
1046
|
+
* commit under `.chant/pr-env`, and `up` writes a report and a record there.
|
|
1047
|
+
*/
|
|
1048
|
+
function fakeEnvChant(): string {
|
|
1049
|
+
const file = join(scratchDir("chant-ci-run-env-bin-"), "chant");
|
|
1050
|
+
writeFileSync(
|
|
1051
|
+
file,
|
|
1052
|
+
[
|
|
1053
|
+
"#!/bin/sh",
|
|
1054
|
+
'action="$3"',
|
|
1055
|
+
"mkdir -p .chant/pr-env",
|
|
1056
|
+
'printf "%s\\n" "$@" > ".chant/pr-env/$action.args"',
|
|
1057
|
+
'env | sort > ".chant/pr-env/$action.env"',
|
|
1058
|
+
'git rev-parse HEAD > ".chant/pr-env/$action.commit"',
|
|
1059
|
+
'ls .chant/pr-env > ".chant/pr-env/$action.found"',
|
|
1060
|
+
'if [ "$action" = up ]; then echo "{\\"stage\\": \\"up\\"}" > .chant/pr-env/pr-env-up.json; echo "{}" > .chant/pr-env/pr-env-record.json; fi',
|
|
1061
|
+
'exit "${FAKE_EXIT:-0}"',
|
|
1062
|
+
"",
|
|
1063
|
+
].join("\n"),
|
|
1064
|
+
);
|
|
1065
|
+
chmodSync(file, 0o755);
|
|
1066
|
+
return file;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
describe("a pull request environment's jobs (#4330)", () => {
|
|
1070
|
+
test("env-up runs with no forge token, then env-post runs at the base commit with it and the report env-up handed on", async () => {
|
|
1071
|
+
const { app, base, sha } = workspace();
|
|
1072
|
+
const out = join(scratchDir("chant-ci-run-env-out-"), "pr-env");
|
|
1073
|
+
const r = await ciRun({ image: JOB_IMAGE, cwd: app, job: "env-up", env: "pr-7", forge: "github", base, pr: 7, chant: fakeEnvChant(), hostEnv: HOST, output: out, push: false });
|
|
1074
|
+
expect(r.op).toBe("pr-env-up");
|
|
1075
|
+
expect(r.status).toBe("ok");
|
|
1076
|
+
const upEnv = envFile(out, "up");
|
|
1077
|
+
for (const name of FORGE_TOKEN_VARS) expect(upEnv[name]).toBeUndefined();
|
|
1078
|
+
expect(upEnv.CHANT_ENV).toBe("pr-7");
|
|
1079
|
+
expect(upEnv.PR_NUMBER).toBe("7");
|
|
1080
|
+
expect(readFileSync(join(out, "up.commit"), "utf-8").trim()).toBe(sha);
|
|
1081
|
+
expect(readFileSync(join(out, "up.args"), "utf-8")).not.toContain("--forge");
|
|
1082
|
+
|
|
1083
|
+
expect(r.post?.op).toBe("pr-env-post");
|
|
1084
|
+
const postEnv = envFile(out, "post");
|
|
1085
|
+
// The token reached env-post, and its copied report is redacted.
|
|
1086
|
+
expect(postEnv.GITHUB_TOKEN).toBe("***");
|
|
1087
|
+
expect(postEnv.HEAD_SHA).toBe(sha);
|
|
1088
|
+
expect(postEnv.UP_RESULT).toBe("success");
|
|
1089
|
+
expect(readFileSync(join(out, "post.commit"), "utf-8").trim()).toBe(base);
|
|
1090
|
+
expect(readFileSync(join(out, "post.found"), "utf-8")).toContain("pr-env-record.json");
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
test("env-down runs with the token and writes its report under .chant/pr-env, and a local env-up posts nothing", async () => {
|
|
1094
|
+
const { app, base } = workspace();
|
|
1095
|
+
const out = join(scratchDir("chant-ci-run-env-out-"), "pr-env");
|
|
1096
|
+
const down = await ciRun({ image: JOB_IMAGE, cwd: app, job: "env-down", env: "pr-7", forge: "github", base, pr: 7, chant: fakeEnvChant(), hostEnv: HOST, output: out, push: false });
|
|
1097
|
+
expect(down.op).toBe("pr-env-down");
|
|
1098
|
+
expect(envFile(out, "down").GITHUB_TOKEN).toBe("***");
|
|
1099
|
+
expect(readFileSync(join(out, "down.args"), "utf-8")).toContain("closed");
|
|
1100
|
+
|
|
1101
|
+
const local = await ciRun({ image: JOB_IMAGE, cwd: app, job: "env-up", env: "pr-7", forge: "github", base, pr: 7, chant: fakeEnvChant(), hostEnv: HOST, output: join(scratchDir("chant-ci-run-env-out-"), "pr-env"), local: true });
|
|
1102
|
+
expect(local.post).toBeUndefined();
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
test("env-post reads the head and the up job's result from flags", () => {
|
|
1106
|
+
expect(() => ciRunEnvJobEnv({})).toThrow(/pass --head <sha>/);
|
|
1107
|
+
expect(ciRunEnvJobEnv({ head: "h".repeat(40), upResult: "failure" })).toMatchObject({ HEAD_SHA: "h".repeat(40), UP_RESULT: "failure", PR_NUMBER: "7" });
|
|
1108
|
+
});
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
function ciRunEnvJobEnv(values: { head?: string; upResult?: string }): Record<string, string> {
|
|
1112
|
+
const post = prEnvJobs("github", {}, "app").find((j) => j.jobName === "env-post")!;
|
|
1113
|
+
return ciJobEnv(post, { forge: "github", env: "pr-7", values: { pr: 7, base: "b".repeat(40), commit: "b".repeat(40), ...values }, hostEnv: HOST });
|
|
1114
|
+
}
|