Skip to content

Commit cee11de

Browse files
fix(release): rebadge scripts bundle as ado-script
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/eb18237a-9266-4098-bb63-db9816eb03fd Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
1 parent 59c0302 commit cee11de

11 files changed

Lines changed: 55 additions & 72 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,13 @@ jobs:
6868
run: |
6969
npm ci
7070
npm run build
71-
# `npm run build` runs codegen + ncc + copies dist/gate/index.js
72-
# to ../gate.js (i.e. scripts/gate.js), which is then included in
73-
# scripts.zip by the next step.
71+
# `npm run build` runs codegen + ncc and outputs dist/gate/index.js.
7472

75-
- name: Package scripts bundle
73+
- name: Package ado-script bundle
7674
run: |
7775
set -euo pipefail
7876
cd scripts
79-
# Only ship the bundled artefacts that pipelines actually
80-
# download and execute (currently: gate.js). The TS source,
81-
# tests, and tooling under ado-script/ are excluded — they
82-
# live in the repo for development and CI, not in the release.
83-
zip -r ../scripts.zip . \
84-
-x "ado-script/node_modules/*" \
85-
-x "ado-script/dist/*" \
86-
-x "ado-script/schema/*" \
87-
-x "ado-script/src/*" \
88-
-x "ado-script/test/*" \
89-
-x "ado-script/package*.json" \
90-
-x "ado-script/tsconfig.json" \
91-
-x "ado-script/vitest.config*.ts" \
92-
-x "ado-script/README.md" \
93-
-x "ado-script/.gitignore"
77+
zip -r ../ado-script.zip ado-script/dist
9478
9579
- name: Upload release assets
9680
env:
@@ -99,7 +83,7 @@ jobs:
9983
TAG="${{ needs.release-please.outputs.tag_name || github.event.inputs.tag_name }}"
10084
gh release upload "$TAG" \
10185
target/release/ado-aw-linux-x64 \
102-
scripts.zip \
86+
ado-script.zip \
10387
--clobber
10488
10589
build-windows:
@@ -189,13 +173,13 @@ jobs:
189173
TAG="${{ needs.release-please.outputs.tag_name || github.event.inputs.tag_name }}"
190174
gh release download "$TAG" \
191175
--pattern "ado-aw-*" \
192-
--pattern "scripts.zip" \
176+
--pattern "ado-script.zip" \
193177
--repo "${{ github.repository }}"
194178
test -f ado-aw-linux-x64 || { echo "Missing ado-aw-linux-x64"; exit 1; }
195179
test -f ado-aw-windows-x64.exe || { echo "Missing ado-aw-windows-x64.exe"; exit 1; }
196180
test -f ado-aw-darwin-arm64 || { echo "Missing ado-aw-darwin-arm64"; exit 1; }
197-
test -f scripts.zip || { echo "Missing scripts.zip"; exit 1; }
198-
sha256sum ado-aw-linux-x64 ado-aw-windows-x64.exe ado-aw-darwin-arm64 scripts.zip > checksums.txt
181+
test -f ado-script.zip || { echo "Missing ado-script.zip"; exit 1; }
182+
sha256sum ado-aw-linux-x64 ado-aw-windows-x64.exe ado-aw-darwin-arm64 ado-script.zip > checksums.txt
199183
200184
- name: Upload checksums
201185
env:

docs/ado-script.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ scripts/ado-script/ # TS workspace
6363
```
6464

6565
The release workflow (`.github/workflows/release.yml`) runs `npm ci &&
66-
npm run build` and copies `dist/gate/index.js` to `scripts/gate.js`,
67-
which is then included in the `scripts.zip` release asset that pipelines
68-
download at runtime.
66+
npm run build`, then packages `scripts/ado-script/dist/` as the
67+
`ado-script.zip` release asset that pipelines download at runtime.
6968

7069
## Schema codegen — preventing drift
7170

@@ -111,10 +110,11 @@ steps when any `filters:` block is active:
111110

112111
1. **`NodeTool@0`** — installs Node 20.x LTS (preinstalled on
113112
Microsoft-hosted images; pinned for reproducibility on others).
114-
2. **`curl` download** — fetches `scripts.zip` from the
113+
2. **`curl` download** — fetches `ado-script.zip` from the
115114
`githubnext/ado-aw` release matching the compiler's version and
116-
extracts `gate.js` to `/tmp/ado-aw-scripts/gate.js`.
117-
3. **`bash: node '/tmp/ado-aw-scripts/gate.js'`** — runs the gate with
115+
extracts `ado-script/dist/gate/index.js` to
116+
`/tmp/ado-aw-scripts/ado-script/dist/gate/index.js`.
117+
3. **`bash: node '/tmp/ado-aw-scripts/ado-script/dist/gate/index.js'`** — runs the gate with
118118
`GATE_SPEC` (base64 JSON) plus required pipeline env vars.
119119

120120
The IR-to-bash codegen lives in `compile_gate_step_external`

docs/filter-ir.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ require heuristic analysis and could produce false positives.
235235

236236
Produces a complete ADO pipeline step (`- bash: |`) with a **data-driven
237237
architecture**: bash is a thin ADO-macro shim, all filter logic lives in
238-
the bundled Node.js gate evaluator (`scripts/gate.js`) that reads a JSON
238+
the bundled Node.js gate evaluator (`scripts/ado-script/dist/gate/index.js`) that reads a JSON
239239
gate spec.
240240

241241
#### Generated Step Structure
@@ -257,7 +257,7 @@ gate spec.
257257
export ADO_SYSTEM_ACCESS_TOKEN="$SYSTEM_ACCESSTOKEN"
258258
259259
# 4. Run the bundled Node evaluator (downloaded by the Setup job)
260-
node '/tmp/ado-aw-scripts/gate.js'
260+
node '/tmp/ado-aw-scripts/ado-script/dist/gate/index.js'
261261
name: prGate
262262
displayName: "Evaluate PR filters"
263263
env:
@@ -304,8 +304,8 @@ acquisition logic.
304304
#### Bundled Gate Evaluator (`scripts/ado-script/src/gate/`)
305305

306306
The evaluator is a TypeScript program ncc-bundled to a single
307-
self-contained `scripts/gate.js` (~1.1 MB) that ships as part of the
308-
`scripts.zip` release asset. See [`ado-script.md`](ado-script.md) for the
307+
self-contained `scripts/ado-script/dist/gate/index.js` (~1.1 MB) that ships as part of the
308+
`ado-script.zip` release asset. See [`ado-script.md`](ado-script.md) for the
309309
full design and codegen pipeline. It handles:
310310

311311
1. **Bypass logic** — reads `ADO_BUILD_REASON` and exits early for non-matching
@@ -358,10 +358,10 @@ When Tier 2/3 filters are configured, the `TriggerFiltersExtension`
358358

359359
1. **Node install step** — emits a `NodeTool@0` step pinned to Node 20.x
360360
LTS so `gate.js` has a runtime
361-
2. **Download step** — fetches `scripts.zip` from the ado-aw release
362-
artifacts and extracts `gate.js` to `/tmp/ado-aw-scripts/gate.js`
361+
2. **Download step** — fetches `ado-script.zip` from the ado-aw release
362+
artifacts and extracts `gate.js` to `/tmp/ado-aw-scripts/ado-script/dist/gate/index.js`
363363
3. **Gate step** — calls `compile_gate_step_external()` to generate a step
364-
that runs `node /tmp/ado-aw-scripts/gate.js` (no inline heredoc)
364+
that runs `node /tmp/ado-aw-scripts/ado-script/dist/gate/index.js` (no inline heredoc)
365365
4. **Validation** — runs `validate_pr_filters()` / `validate_pipeline_filters()`
366366
during compilation via the `validate()` trait method
367367

@@ -408,15 +408,15 @@ The `expression` escape hatch is also ANDed if present.
408408
### Scripts Distribution
409409

410410
The `gate.js` bundle is built from the TypeScript workspace at
411-
`scripts/ado-script/` (see [`ado-script.md`](ado-script.md)) and copied to
412-
`scripts/gate.js` by the release workflow's build step. It ships inside
413-
the `scripts.zip` release asset, alongside any future bundled helpers
411+
`scripts/ado-script/` (see [`ado-script.md`](ado-script.md)) and emitted to
412+
`scripts/ado-script/dist/gate/index.js` by the release workflow's build step. It ships inside
413+
the `ado-script.zip` release asset, alongside any future bundled helpers
414414
(e.g. `poll.js`, `stats.js`). The download URL is deterministic based on
415415
the ado-aw version:
416-
`https://github.com/githubnext/ado-aw/releases/download/v{VERSION}/scripts.zip`
416+
`https://github.com/githubnext/ado-aw/releases/download/v{VERSION}/ado-script.zip`
417417

418-
The Setup-job download step pulls the zip, extracts `gate.js`, and
419-
discards the rest. New per-use-site bundles follow the same pattern
418+
The Setup-job download step pulls the zip, extracts `ado-script/dist/gate/index.js`,
419+
and discards the rest. New per-use-site bundles follow the same pattern
420420
(per-bundle ncc entry + per-bundle download step).
421421

422422
## Adding New Filter Types
@@ -435,4 +435,3 @@ step-by-step guide. In summary:
435435
`lower_pipeline_filters`)
436436
6. Add validation rules if the new filter can conflict with existing ones
437437
7. Write tests: lowering, validation, spec serialization, and evaluator
438-

scripts/ado-script/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @ado-aw/scripts
22

3-
Bundled TypeScript scripts shipped in `scripts.zip` alongside the ado-aw release.
3+
Bundled TypeScript scripts shipped in `ado-script.zip` alongside the ado-aw release.
44

55
## Bundles
66

@@ -20,7 +20,7 @@ This invokes `cargo run -- export-gate-schema` to write the JSON Schema, then ru
2020

2121
- `src/shared/` — modules shared across all bundles (auth, ado-client, vso-logger, env-facts, policy state machine)
2222
- `src/gate/` — gate evaluator entry point and per-concern modules
23-
- `dist/` — ncc bundle output (gitignored); `npm run build` copies the gate bundle to `../gate.js` for inclusion in `scripts.zip`
23+
- `dist/` — ncc bundle output (gitignored); `npm run build` writes `dist/gate/index.js`, which ships in `ado-script.zip`
2424

2525
## See also
2626

scripts/ado-script/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"node": ">=20.0.0"
88
},
99
"scripts": {
10-
"build": "npm run codegen && npm run build:gate && cp dist/gate/index.js ../gate.js",
10+
"build": "npm run codegen && npm run build:gate",
1111
"build:gate": "ncc build src/gate/index.ts -o dist/gate -m -t",
12-
"build:check": "ls -lh ../gate.js && wc -c ../gate.js",
12+
"build:check": "ls -lh dist/gate/index.js && wc -c dist/gate/index.js",
1313
"codegen": "mkdir -p schema && cargo run --quiet --manifest-path ../../Cargo.toml -- export-gate-schema --output schema/gate-spec.schema.json && npx json2ts schema/gate-spec.schema.json -o src/shared/types.gen.ts --bannerComment \"// AUTO-GENERATED from Rust IR via cargo run -- export-gate-schema. Do not edit; run npm run codegen.\"",
1414
"test": "vitest run",
1515
"test:smoke": "npm run build && vitest run -c vitest.config.smoke.ts",

scripts/ado-script/src/gate/predicates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function evaluatePredicate(p: PredicateSpec, facts: Map<string, unknown>)
149149
const unknownType = (p as { type?: unknown }).type;
150150
logWarning(
151151
`Unknown predicate type '${String(unknownType)}'; failing closed. ` +
152-
"Update scripts/gate.js (or the bundled scripts.zip) to a " +
152+
"Update scripts/ado-script/dist/gate/index.js (or the bundled ado-script.zip) to a " +
153153
"release that supports this predicate.",
154154
);
155155
return false;

scripts/ado-script/src/shared/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export type PredicateSpec =
7676

7777
/**
7878
* Serializable gate specification — the JSON document consumed by the
79-
* Node gate evaluator (`scripts/gate.js`) at pipeline runtime.
79+
* Node gate evaluator (`scripts/ado-script/dist/gate/index.js`) at pipeline runtime.
8080
*/
8181
export interface GateSpec {
8282
checks: CheckSpec[];

src/compile/extensions/trigger_filters.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::compile::filter_ir::{
1818
use crate::compile::types::{PipelineFilters, PrFilters};
1919

2020
/// The path where the gate evaluator is downloaded at pipeline runtime.
21-
const GATE_EVAL_PATH: &str = "/tmp/ado-aw-scripts/gate.js";
21+
const GATE_EVAL_PATH: &str = "/tmp/ado-aw-scripts/ado-script/dist/gate/index.js";
2222

2323
/// Base URL for ado-aw release artifacts.
2424
const RELEASE_BASE_URL: &str = "https://github.com/githubnext/ado-aw/releases/download";
@@ -113,8 +113,8 @@ impl CompilerExtension for TriggerFiltersExtension {
113113
steps.push(format!(
114114
r#"- bash: |
115115
mkdir -p /tmp/ado-aw-scripts
116-
curl -fsSL "{RELEASE_BASE_URL}/v{version}/scripts.zip" -o /tmp/ado-aw-scripts/scripts.zip
117-
cd /tmp/ado-aw-scripts && unzip -o scripts.zip
116+
curl -fsSL "{RELEASE_BASE_URL}/v{version}/ado-script.zip" -o /tmp/ado-aw-scripts/ado-script.zip
117+
cd /tmp/ado-aw-scripts && unzip -o ado-script.zip
118118
displayName: "Download ado-aw scripts (v{version})"
119119
condition: succeeded()"#,
120120
));
@@ -238,12 +238,12 @@ mod tests {
238238
assert!(steps[0].contains("20.x"), "should install Node 20.x");
239239
assert!(steps[1].contains("curl"), "second step should download");
240240
assert!(
241-
steps[1].contains("scripts.zip"),
242-
"should download scripts.zip"
241+
steps[1].contains("ado-script.zip"),
242+
"should download ado-script.zip"
243243
);
244244
assert!(steps[2].contains("prGate"), "third step should be PR gate");
245245
assert!(
246-
steps[2].contains("node '/tmp/ado-aw-scripts/gate.js'"),
246+
steps[2].contains("node '/tmp/ado-aw-scripts/ado-script/dist/gate/index.js'"),
247247
"gate step should reference external script"
248248
);
249249
}

src/compile/filter_ir.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ use schemars::JsonSchema;
814814
use serde::Serialize;
815815

816816
/// Serializable gate specification — the JSON document consumed by the
817-
/// Node gate evaluator (`scripts/gate.js`) at pipeline runtime.
817+
/// Node gate evaluator (`scripts/ado-script/dist/gate/index.js`) at pipeline runtime.
818818
#[derive(Debug, Clone, Serialize, JsonSchema)]
819819
pub struct GateSpec {
820820
pub context: GateContextSpec,
@@ -1519,7 +1519,7 @@ mod tests {
15191519
let result = compile_gate_step_external(
15201520
GateContext::PullRequest,
15211521
&[],
1522-
"/tmp/ado-aw-scripts/gate.js",
1522+
"/tmp/ado-aw-scripts/ado-script/dist/gate/index.js",
15231523
)
15241524
.unwrap();
15251525
assert!(result.is_empty());
@@ -1538,7 +1538,7 @@ mod tests {
15381538
let result = compile_gate_step_external(
15391539
GateContext::PullRequest,
15401540
&checks,
1541-
"/tmp/ado-aw-scripts/gate.js",
1541+
"/tmp/ado-aw-scripts/ado-script/dist/gate/index.js",
15421542
)
15431543
.unwrap();
15441544
assert!(result.contains("- bash:"), "should be a bash step");
@@ -1547,7 +1547,7 @@ mod tests {
15471547
"should include base64 spec in env"
15481548
);
15491549
assert!(
1550-
result.contains("node '/tmp/ado-aw-scripts/gate.js'"),
1550+
result.contains("node '/tmp/ado-aw-scripts/ado-script/dist/gate/index.js'"),
15511551
"should reference external evaluator script"
15521552
);
15531553
assert!(result.contains("name: prGate"), "should set step name");
@@ -1570,7 +1570,7 @@ mod tests {
15701570
let result = compile_gate_step_external(
15711571
GateContext::PullRequest,
15721572
&checks,
1573-
"/tmp/ado-aw-scripts/gate.js",
1573+
"/tmp/ado-aw-scripts/ado-script/dist/gate/index.js",
15741574
)
15751575
.unwrap();
15761576
assert!(
@@ -1597,7 +1597,7 @@ mod tests {
15971597
let result = compile_gate_step_external(
15981598
GateContext::PipelineCompletion,
15991599
&checks,
1600-
"/tmp/ado-aw-scripts/gate.js",
1600+
"/tmp/ado-aw-scripts/ado-script/dist/gate/index.js",
16011601
)
16021602
.unwrap();
16031603
assert!(
@@ -1627,7 +1627,7 @@ mod tests {
16271627
let result = compile_gate_step_external(
16281628
GateContext::PullRequest,
16291629
&checks,
1630-
"/tmp/ado-aw-scripts/gate.js",
1630+
"/tmp/ado-aw-scripts/ado-script/dist/gate/index.js",
16311631
)
16321632
.unwrap();
16331633
assert!(
@@ -1653,7 +1653,7 @@ mod tests {
16531653
let result = compile_gate_step_external(
16541654
GateContext::PullRequest,
16551655
&checks,
1656-
"/tmp/ado-aw-scripts/gate.js",
1656+
"/tmp/ado-aw-scripts/ado-script/dist/gate/index.js",
16571657
)
16581658
.unwrap();
16591659
// Check export lines only (evaluator script always contains these strings)
@@ -1746,7 +1746,7 @@ mod tests {
17461746
let step = compile_gate_step_external(
17471747
GateContext::PullRequest,
17481748
&checks,
1749-
"/tmp/ado-aw-scripts/gate.js",
1749+
"/tmp/ado-aw-scripts/ado-script/dist/gate/index.js",
17501750
)
17511751
.unwrap();
17521752
// Step structure

tests/compiler_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3491,7 +3491,7 @@ fn test_pr_filter_tier1_compiled_output_is_valid_yaml() {
34913491
assert_valid_yaml(&compiled, "pr-filter-tier1-agent.md");
34923492
}
34933493

3494-
/// Tier 1 PR filters now also use the Python evaluator via extension.
3494+
/// Tier 1 PR filters use the bundled Node evaluator via extension.
34953495
#[test]
34963496
fn test_pr_filter_tier1_has_evaluator_gate() {
34973497
let compiled = compile_fixture("pr-filter-tier1-agent.md");
@@ -3509,11 +3509,11 @@ fn test_pr_filter_tier1_has_evaluator_gate() {
35093509
"Should include base64-encoded spec"
35103510
);
35113511
assert!(
3512-
compiled.contains("node '/tmp/ado-aw-scripts/gate.js'"),
3512+
compiled.contains("node '/tmp/ado-aw-scripts/ado-script/dist/gate/index.js'"),
35133513
"Should invoke node gate evaluator"
35143514
);
35153515
assert!(
3516-
compiled.contains("scripts.zip"),
3516+
compiled.contains("ado-script.zip"),
35173517
"Should download scripts bundle"
35183518
);
35193519
assert!(
@@ -3539,15 +3539,15 @@ fn test_pr_filter_tier2_has_extension_gate() {
35393539
"Should create Setup job for PR filters"
35403540
);
35413541
assert!(
3542-
compiled.contains("scripts.zip"),
3542+
compiled.contains("ado-script.zip"),
35433543
"Tier 2 should download scripts bundle"
35443544
);
35453545
assert!(
35463546
compiled.contains("GATE_SPEC"),
35473547
"Tier 2 should include base64-encoded spec"
35483548
);
35493549
assert!(
3550-
compiled.contains("node '/tmp/ado-aw-scripts/gate.js'"),
3550+
compiled.contains("node '/tmp/ado-aw-scripts/ado-script/dist/gate/index.js'"),
35513551
"Tier 2 should invoke node gate evaluator"
35523552
);
35533553
assert!(compiled.contains("name: prGate"), "Should have prGate step");

0 commit comments

Comments
 (0)