-
Notifications
You must be signed in to change notification settings - Fork 0
2127 lines (1858 loc) · 91.7 KB
/
Copy pathrelease.yml
File metadata and controls
2127 lines (1858 loc) · 91.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
publish_chrome:
description: "Publish Chrome extension to Web Store"
type: boolean
default: false
required: false
env:
CARGO_TERM_COLOR: always
# Workflow-level default: every job gets read-only access unless it explicitly
# declares broader permissions. Jobs that publish or attest override below.
permissions:
contents: read
jobs:
# ── Smoke tests ─────────────────────────────────────────────────────────────
# All publish / release jobs declare `needs: smoke-test` so no artefact ever
# leaves the repo unless every module passes validation.
#
# Covers:
# 1. vastlint-core + vastlint-ffi — cargo test --all (unit + integration)
# 2. vastlint-cli — build release binary; valid fixture
# exits 0; invalid fixture exits non-0;
# specific error/warning/info rule IDs
# asserted via --format json; --vast-version
# override (up and down); --ignore-pattern
# macro suppression; fix subcommand;
# daemon OTP protocol (Python struct.pack)
# 3. vastlint-mcp — build release binary, drive initialize +
# tools/list via stdin, assert 7 tools
# returned with correct names; actual
# tools/call for validate_vast (valid +
# invalid), fix_vast, list_rules,
# explain_rule, inspect_vast
# 4. vastlint-wasm — wasm-pack build (nodejs target) then
# a Node.js script that imports the
# package and validates the same fixtures;
# specific rule IDs asserted; warning
# fixture checked for valid=true
smoke-test:
name: Smoke test all modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # v (pinned SHA)
with:
toolchain: stable
targets: wasm32-unknown-unknown
components: clippy
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
# ── 1. Unit + integration tests (core, ffi, cli) ──────────────────────
- name: cargo test --all
run: cargo test --all
# ── 2. CLI smoke test ─────────────────────────────────────────────────
- name: Build CLI (release)
run: cargo build --release -p vastlint-cli
- name: CLI smoke — valid fixture exits 0
run: |
./target/release/vastlint check \
crates/vastlint-core/tests/fixtures/valid_4.2.xml
echo "Exit code: $?"
- name: CLI smoke — invalid fixture exits 1
run: |
set +e
./target/release/vastlint check \
crates/vastlint-core/tests/fixtures/err_no_ad.xml
CODE=$?
set -e
if [ "$CODE" -eq 0 ]; then
echo "ERROR: vastlint exited 0 on an invalid fixture — expected non-zero"
exit 1
fi
echo "Exit code $CODE (expected non-zero) ✓"
# ── 3. MCP smoke test ─────────────────────────────────────────────────
- name: Build MCP server (release)
run: cargo build --release -p vastlint-mcp
- name: MCP smoke — initialize + tools/list returns 5 tools
run: |
RESPONSE=$(
(
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"ci","version":"1.0"}}}'
sleep 0.2
echo '{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}'
sleep 0.2
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
sleep 1
) | ./target/release/vastlint-mcp 2>/dev/null
)
echo "$RESPONSE" | grep -q '"tools"' || {
echo "FAIL: initialize response missing tools capability"
echo "$RESPONSE"
exit 1
}
echo "capabilities.tools present ✓"
TOOL_COUNT=$(echo "$RESPONSE" | grep '"tools":\[' | grep -o '"name":"' | wc -l | tr -d ' ')
if [ "$TOOL_COUNT" -ne 7 ]; then
echo "FAIL: expected 7 tools, got $TOOL_COUNT"
echo "$RESPONSE"
exit 1
fi
echo "tools/list returned $TOOL_COUNT tools ✓"
for TOOL in validate_vast validate_vast_url fix_vast list_rules explain_rule inspect_vast; do
echo "$RESPONSE" | grep -q "\"$TOOL\"" || {
echo "FAIL: tool '$TOOL' missing from tools/list"
echo "$RESPONSE"
exit 1
}
echo " $TOOL ✓"
done
# ── 4. WASM smoke test ────────────────────────────────────────────────
- name: Install wasm-pack
run: cargo install wasm-pack --locked
- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '20'
- name: Build WASM (nodejs target)
run: wasm-pack build crates/vastlint-wasm --target nodejs --out-dir ../../npm/pkg-node
- name: Build WASM (bundler target)
run: wasm-pack build crates/vastlint-wasm --target bundler --out-dir ../../npm/pkg
- name: Assemble npm package
run: node npm/scripts/assemble.js
- name: WASM smoke — valid fixture returns no errors
run: |
node - <<'EOF'
const { validate } = require('./npm');
const fs = require('fs');
const validXml = fs.readFileSync(
'crates/vastlint-core/tests/fixtures/valid_4.2.xml', 'utf8'
);
const result = validate(validXml);
if (result.summary.errors !== 0) {
console.error('WASM smoke FAILED: expected 0 errors on valid fixture, got', result.summary.errors);
process.exit(1);
}
if (!result.summary.valid) {
console.error('WASM smoke FAILED: expected valid=true on valid fixture');
process.exit(1);
}
console.log('WASM valid fixture ✓ (errors=0, valid=true)');
EOF
- name: WASM smoke — invalid fixture returns errors
run: |
node - <<'EOF'
const { validate } = require('./npm');
const fs = require('fs');
const invalidXml = fs.readFileSync(
'crates/vastlint-core/tests/fixtures/err_no_ad.xml', 'utf8'
);
const result = validate(invalidXml);
if (result.summary.errors === 0) {
console.error('WASM smoke FAILED: expected errors > 0 on invalid fixture');
process.exit(1);
}
if (result.summary.valid) {
console.error('WASM smoke FAILED: expected valid=false on invalid fixture');
process.exit(1);
}
console.log('WASM invalid fixture ✓ (errors=' + result.summary.errors + ', valid=false)');
EOF
# ── 2b. CLI smoke — specific rule IDs ────────────────────────────────
# Pick a representative spread across rule families and VAST versions to
# catch regressions in the core rule engine that cargo test would not catch
# at the binary level (e.g. a broken --format json serialisation).
- name: CLI smoke — error rule IDs (JSON output)
run: |
FIXTURES=(
"err_inline_missing_impression.xml:VAST-2.0-inline-impression"
"err_missing_adsystem.xml:VAST-2.0-inline-adsystem"
"err_no_version.xml:VAST-2.0-root-version"
"err_missing_duration.xml:VAST-2.0-linear-duration"
"err_mediafile_missing_attrs.xml:VAST-2.0-mediafile-delivery"
"err_wrapper_missing_vasttag.xml:VAST-2.0-wrapper-vastadtaguri"
"err_adservingid_missing.xml:VAST-4.1-adservingid-present"
"err_universaladid_missing.xml:VAST-4.0-universaladid-present"
"err_verification_vendor.xml:VAST-4.1-verification-vendor"
"err_companion_clicktracking_no_id.xml:VAST-4.0-companion-clicktracking-id"
"err_icon_missing_resource.xml:VAST-3.0-icon-resource"
"err_progress_no_offset.xml:VAST-3.0-progress-offset"
)
PASS=0; FAIL=0
for ENTRY in "${FIXTURES[@]}"; do
FILE="${ENTRY%%:*}"
RULE="${ENTRY##*:}"
FIXTURE="crates/vastlint-core/tests/fixtures/$FILE"
OUTPUT=$(./target/release/vastlint check "$FIXTURE" --format json 2>/dev/null || true)
if echo "$OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(0 if any(i['id']=='$RULE' for i in d['issues']) else 1)"; then
echo "PASS [$FILE → $RULE]"
PASS=$((PASS+1))
else
echo "FAIL [$FILE → $RULE not found in issues]"
echo " Output: $OUTPUT" | head -5
FAIL=$((FAIL+1))
fi
done
echo "Results: $PASS passed, $FAIL failed"
[ "$FAIL" -eq 0 ] || exit 1
- name: CLI smoke — warning and info rule IDs (JSON output)
run: |
FIXTURES=(
"warn_vpaid.xml:VAST-4.1-vpaid-apiframework"
"warn_duplicate_impression.xml:VAST-2.0-duplicate-impression"
"warn_version_mismatch.xml:VAST-2.0-version-mismatch"
"warn_flash_mediafile.xml:VAST-2.0-flash-mediafile"
"warn_survey_deprecated.xml:VAST-4.1-survey-deprecated"
"warn_url_invalid.xml:VAST-2.0-url-invalid"
"warn_bitrate_conflict.xml:VAST-3.0-bitrate-conflict"
"warn_companion_renderingmode.xml:VAST-4.1-companion-renderingmode-value"
"warn_tracking_event_unknown.xml:VAST-4.1-tracking-event-value"
"warn_adtype_invalid.xml:VAST-4.1-adtype-value"
"warn_blockedadcategories_no_authority.xml:VAST-4.1-blockedadcategories-no-authority"
"warn_universaladid_idvalue_removed.xml:VAST-4.1-universaladid-idvalue-removed"
"info_http_tracking.xml:VAST-2.0-tracking-https"
)
PASS=0; FAIL=0
for ENTRY in "${FIXTURES[@]}"; do
FILE="${ENTRY%%:*}"
RULE="${ENTRY##*:}"
FIXTURE="crates/vastlint-core/tests/fixtures/$FILE"
OUTPUT=$(./target/release/vastlint check "$FIXTURE" --format json 2>/dev/null || true)
if echo "$OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(0 if any(i['id']=='$RULE' for i in d['issues']) else 1)"; then
echo "PASS [$FILE → $RULE]"
PASS=$((PASS+1))
else
echo "FAIL [$FILE → $RULE not found in issues]"
FAIL=$((FAIL+1))
fi
done
echo "Results: $PASS passed, $FAIL failed"
[ "$FAIL" -eq 0 ] || exit 1
# ── 2c. CLI smoke — --vast-version override ───────────────────────────
- name: CLI smoke — --vast-version upgrade fires 4.1 rules on 2.0 doc
run: |
# A plain VAST 2.0 document forced to 4.1 must:
# • report version "4.1" in JSON
# • fire VAST-4.1-adservingid-present (missing on 2.0 doc)
cat > /tmp/v2_simple.xml <<'XMLEOF'
<VAST version="2.0"><Ad id="1"><InLine>
<AdSystem>Test</AdSystem><AdTitle>Test Ad</AdTitle>
<Impression><![CDATA[https://t.example.com/imp]]></Impression>
<Creatives><Creative><Linear>
<Duration>00:00:30</Duration>
<MediaFiles><MediaFile type="video/mp4" width="640" height="480" bitrate="500" delivery="progressive">
<![CDATA[https://cdn.example.com/ad.mp4]]>
</MediaFile></MediaFiles>
</Linear></Creative></Creatives>
</InLine></Ad></VAST>
XMLEOF
OUTPUT=$(./target/release/vastlint check /tmp/v2_simple.xml --vast-version 4.1 --format json 2>/dev/null || true)
VERSION=$(echo "$OUTPUT" | python3 -c "import sys,json; print(json.load(sys.stdin)['version'])")
if [ "$VERSION" != "4.1" ]; then
echo "FAIL: expected version=4.1 in JSON, got '$VERSION'"
exit 1
fi
echo "PASS: version field is 4.1 ✓"
echo "$OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(0 if any(i['id']=='VAST-4.1-adservingid-present' for i in d['issues']) else 1)" || {
echo "FAIL: VAST-4.1-adservingid-present did not fire after --vast-version 4.1 override"
exit 1
}
echo "PASS: VAST-4.1-adservingid-present fires on forced 4.1 ✓"
- name: CLI smoke — --vast-version downgrade suppresses 4.x rules
run: |
# A VAST 4.1 document forced to 2.0 must NOT fire any 4.x-only rules.
OUTPUT=$(./target/release/vastlint check \
crates/vastlint-core/tests/fixtures/valid_4.1.xml \
--vast-version 2.0 --format json 2>/dev/null || true)
HITS=$(echo "$OUTPUT" | python3 -c "
import sys, json
d = json.load(sys.stdin)
bad = [i['id'] for i in d['issues'] if i['id'].startswith('VAST-4.')]
print(len(bad), bad)
")
COUNT=$(echo "$HITS" | awk '{print $1}')
if [ "$COUNT" -ne 0 ]; then
echo "FAIL: 4.x rules fired after --vast-version 2.0 downgrade: $HITS"
exit 1
fi
echo "PASS: no 4.x rules fired after downgrade ✓"
- name: CLI smoke — --vast-version invalid value exits non-zero
run: |
set +e
./target/release/vastlint check \
crates/vastlint-core/tests/fixtures/valid_4.2.xml \
--vast-version 9.9 >/dev/null 2>&1
CODE=$?
set -e
if [ "$CODE" -eq 0 ]; then
echo "FAIL: invalid --vast-version 9.9 should exit non-zero, got 0"
exit 1
fi
echo "PASS: --vast-version 9.9 exits $CODE (non-zero) ✓"
# ── 2d. CLI smoke — --ignore-pattern ─────────────────────────────────
- name: CLI smoke — --ignore-pattern suppresses macro URL errors
run: |
# A VAST with macro placeholders in URL fields fires url-empty/url-invalid
# without the flag. With --ignore-pattern the macros are replaced before
# validation and no URL errors should appear.
cat > /tmp/vmacro.xml <<'XMLEOF'
<VAST version="4.2"><Ad id="1"><InLine>
<AdSystem>Acme DSP</AdSystem>
<AdServingId>srv-macro-01</AdServingId>
<AdTitle>Macro Test Ad</AdTitle>
<Impression><![CDATA[${IMP_URL}]]></Impression>
<Creatives><Creative>
<UniversalAdId idRegistry="Ad-ID">mac01</UniversalAdId>
<Linear>
<Duration>00:00:30</Duration>
<TrackingEvents>
<Tracking event="start"><![CDATA[%%TRACKER_START%%]]></Tracking>
<Tracking event="firstQuartile"><![CDATA[${Q1_URL}]]></Tracking>
<Tracking event="midpoint"><![CDATA[${MID_URL}]]></Tracking>
<Tracking event="thirdQuartile"><![CDATA[${Q3_URL}]]></Tracking>
<Tracking event="complete"><![CDATA[${COMP_URL}]]></Tracking>
</TrackingEvents>
<MediaFiles><MediaFile type="video/mp4" width="1920" height="1080" bitrate="2000" delivery="progressive">
<![CDATA[https://cdn.example.com/hd.mp4]]>
</MediaFile></MediaFiles>
</Linear>
</Creative></Creatives>
</InLine></Ad></VAST>
XMLEOF
# Without flag: url-empty must fire
URL_ISSUES=$(./target/release/vastlint check /tmp/vmacro.xml --format json 2>/dev/null \
| python3 -c "import sys,json; d=json.load(sys.stdin); print([i['id'] for i in d['issues'] if 'url' in i['id'].lower()])" || true)
if [ "$URL_ISSUES" = "[]" ]; then
echo "FAIL: expected URL errors without --ignore-pattern, got none"
exit 1
fi
echo "PASS: URL errors present without flag: $URL_ISSUES ✓"
# With flag: no URL errors
OUTPUT=$(./target/release/vastlint check /tmp/vmacro.xml \
--ignore-pattern '\$\{[^}]+\}|%%[^%]+%%' \
--format json 2>/dev/null || true)
URL_ISSUES=$(echo "$OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); print([i['id'] for i in d['issues'] if 'url' in i['id'].lower()])" || true)
if [ "$URL_ISSUES" != "[]" ]; then
echo "FAIL: expected no URL errors with --ignore-pattern, got: $URL_ISSUES"
exit 1
fi
echo "PASS: no URL errors after --ignore-pattern replacement ✓"
- name: CLI smoke — --ignore-pattern invalid regex exits non-zero
run: |
set +e
./target/release/vastlint check \
crates/vastlint-core/tests/fixtures/valid_4.2.xml \
--ignore-pattern '[invalid' >/dev/null 2>&1
CODE=$?
set -e
if [ "$CODE" -eq 0 ]; then
echo "FAIL: invalid --ignore-pattern should exit non-zero, got 0"
exit 1
fi
echo "PASS: invalid --ignore-pattern exits $CODE (non-zero) ✓"
# ── 2e. CLI smoke — fix subcommand ────────────────────────────────────
- name: CLI smoke — fix subcommand upgrades HTTP to HTTPS
run: |
# A fixture with HTTP URLs: fix should exit 0 and output HTTPS URLs.
cat > /tmp/http_vast.xml <<'XMLEOF'
<VAST version="2.0"><Ad id="1"><InLine>
<AdSystem>Test</AdSystem><AdTitle>Test Ad</AdTitle>
<Impression>http://t.example.com/imp</Impression>
<Creatives><Creative><Linear>
<Duration>00:00:30</Duration>
<MediaFiles><MediaFile type="video/mp4" width="640" height="480" bitrate="500" delivery="progressive">
http://cdn.example.com/ad.mp4
</MediaFile></MediaFiles>
</Linear></Creative></Creatives>
</InLine></Ad></VAST>
XMLEOF
# Use stdin mode (-) so the fixed XML is written to stdout, not in-place.
FIXED=$(./target/release/vastlint fix - < /tmp/http_vast.xml 2>/dev/null)
if [ $? -ne 0 ]; then
echo "FAIL: fix subcommand exited non-zero"
exit 1
fi
echo "PASS: fix subcommand exits 0 ✓"
if echo "$FIXED" | grep -q 'http://'; then
echo "FAIL: fixed output still contains http:// URLs"
exit 1
fi
echo "PASS: no http:// in fixed output ✓"
if ! echo "$FIXED" | grep -q 'https://'; then
echo "FAIL: fixed output has no https:// URLs"
exit 1
fi
echo "PASS: fixed output contains https:// ✓"
- name: CLI smoke — fix --dry-run exits 0 and does not modify file
run: |
cp crates/vastlint-core/tests/fixtures/valid_4.2.xml /tmp/dryrun_test.xml
./target/release/vastlint fix /tmp/dryrun_test.xml --dry-run > /dev/null 2>&1
CODE=$?
if [ "$CODE" -ne 0 ]; then
echo "FAIL: fix --dry-run exited $CODE, expected 0"
exit 1
fi
echo "PASS: fix --dry-run exits 0 ✓"
# File must be unmodified
if ! diff -q crates/vastlint-core/tests/fixtures/valid_4.2.xml /tmp/dryrun_test.xml > /dev/null; then
echo "FAIL: --dry-run modified the input file"
exit 1
fi
echo "PASS: --dry-run did not modify input file ✓"
# ── 2f. CLI smoke — daemon OTP protocol ──────────────────────────────
- name: CLI smoke — daemon OTP protocol (valid XML → valid=true)
run: |
python3 - <<'PYEOF'
import subprocess, struct, json, sys
VALID_XML = open('crates/vastlint-core/tests/fixtures/valid_4.2.xml').read()
INVALID_XML = open('crates/vastlint-core/tests/fixtures/err_no_ad.xml').read()
def daemon_call(xml_str):
proc = subprocess.Popen(
['./target/release/vastlint', 'daemon'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
encoded = xml_str.encode('utf-8')
proc.stdin.write(struct.pack('>I', len(encoded)) + encoded)
proc.stdin.close()
resp_len = struct.unpack('>I', proc.stdout.read(4))[0]
result = json.loads(proc.stdout.read(resp_len).decode('utf-8'))
proc.wait(timeout=5)
return result
# Valid fixture → valid=true, errors=0
r = daemon_call(VALID_XML)
assert r.get('valid') is True, f"FAIL: daemon valid fixture: expected valid=true, got {r}"
assert r.get('summary', {}).get('errors') == 0, f"FAIL: daemon valid fixture: expected errors=0, got {r}"
assert r.get('version') == '4.2', f"FAIL: daemon valid fixture: expected version=4.2, got {r.get('version')}"
print(f"PASS: daemon valid fixture → valid=true, errors=0, version=4.2 ✓")
# Invalid fixture → valid=false, errors>0
r = daemon_call(INVALID_XML)
assert r.get('valid') is False, f"FAIL: daemon invalid fixture: expected valid=false, got {r}"
assert r.get('summary', {}).get('errors', 0) > 0, f"FAIL: daemon invalid fixture: expected errors>0, got {r}"
print(f"PASS: daemon invalid fixture → valid=false, errors={r['summary']['errors']} ✓")
# Rule ID check via daemon
IMP_XML = open('crates/vastlint-core/tests/fixtures/err_inline_missing_impression.xml').read()
r = daemon_call(IMP_XML)
ids = [i['id'] for i in r.get('issues', [])]
assert 'VAST-2.0-inline-impression' in ids, f"FAIL: daemon rule ID check: VAST-2.0-inline-impression not in {ids}"
print(f"PASS: daemon rule ID VAST-2.0-inline-impression fires correctly ✓")
print("All daemon smoke tests passed.")
PYEOF
# ── 3b. MCP smoke — actual tool calls ────────────────────────────────
- name: MCP smoke — validate_vast (valid + invalid) and fix_vast tool calls
run: |
python3 - <<'PYEOF'
import subprocess, json, sys, time
VALID_XML = open('crates/vastlint-core/tests/fixtures/valid_4.2.xml').read()
INVALID_XML = open('crates/vastlint-core/tests/fixtures/err_inline_missing_impression.xml').read()
HTTP_XML = ('<VAST version="2.0"><Ad id="1"><InLine>'
'<AdSystem>T</AdSystem><AdTitle>T</AdTitle>'
'<Impression>http://t.example.com/imp</Impression>'
'<Creatives><Creative><Linear><Duration>00:00:30</Duration>'
'<MediaFiles><MediaFile delivery="progressive" type="video/mp4"'
' width="640" height="480">http://cdn.example.com/ad.mp4'
'</MediaFile></MediaFiles></Linear></Creative></Creatives>'
'</InLine></Ad></VAST>')
proc = subprocess.Popen(
['./target/release/vastlint-mcp'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
_id = [0]
def send(msg):
_id[0] += 1
if 'id' not in msg:
msg = dict(msg, id=_id[0])
proc.stdin.write((json.dumps(msg) + '\n').encode())
proc.stdin.flush()
return msg.get('id')
def read_until(target_id, timeout=10):
import select
deadline = time.monotonic() + timeout
buf = b''
while time.monotonic() < deadline:
r, _, _ = select.select([proc.stdout], [], [], 0.5)
if r:
chunk = proc.stdout.read1(4096)
if chunk:
buf += chunk
while b'\n' in buf:
line, buf = buf.split(b'\n', 1)
line = line.strip()
if not line:
continue
try:
d = json.loads(line)
except Exception:
continue
if d.get('id') == target_id:
return d
raise TimeoutError(f'no response for id={target_id}')
# Initialize
init_id = send({'jsonrpc':'2.0','method':'initialize','params':{
'protocolVersion':'2024-11-05','capabilities':{},'clientInfo':{'name':'ci','version':'1.0'}}})
read_until(init_id)
proc.stdin.write((json.dumps({'jsonrpc':'2.0','method':'notifications/initialized','params':{}}) + '\n').encode())
proc.stdin.flush()
# validate_vast — valid fixture
vid = send({'jsonrpc':'2.0','method':'tools/call','params':{'name':'validate_vast','arguments':{'xml': VALID_XML}}})
r = read_until(vid)
obj = json.loads(r['result']['content'][0]['text'])
assert obj['valid'] is True, f"FAIL: MCP validate_vast valid: expected valid=true, got {obj}"
assert obj['summary']['errors'] == 0, f"FAIL: MCP validate_vast valid: errors={obj['summary']['errors']}"
assert obj['version'] == '4.2', f"FAIL: MCP validate_vast valid: version={obj['version']}"
print("PASS: MCP validate_vast valid fixture ✓")
# validate_vast — invalid fixture with specific rule ID
iid = send({'jsonrpc':'2.0','method':'tools/call','params':{'name':'validate_vast','arguments':{'xml': INVALID_XML}}})
r = read_until(iid)
obj = json.loads(r['result']['content'][0]['text'])
assert obj['valid'] is False, f"FAIL: MCP validate_vast invalid: expected valid=false, got {obj}"
assert obj['summary']['errors'] > 0, f"FAIL: MCP validate_vast invalid: errors=0"
ids = [i['id'] for i in obj['issues']]
assert 'VAST-2.0-inline-impression' in ids, f"FAIL: MCP validate_vast invalid: rule ID not found in {ids}"
print(f"PASS: MCP validate_vast invalid fixture, VAST-2.0-inline-impression fires ✓")
# fix_vast — HTTP→HTTPS upgrade
fid = send({'jsonrpc':'2.0','method':'tools/call','params':{'name':'fix_vast','arguments':{'xml': HTTP_XML}}})
r = read_until(fid)
obj = json.loads(r['result']['content'][0]['text'])
assert obj['applied_count'] > 0, f"FAIL: MCP fix_vast: no fixes applied, got {obj}"
assert 'https://' in obj['xml'], f"FAIL: MCP fix_vast: no https:// in fixed XML"
assert 'http://' not in obj['xml'], f"FAIL: MCP fix_vast: http:// still in fixed XML"
print(f"PASS: MCP fix_vast applied {obj['applied_count']} fix(es), HTTP→HTTPS ✓")
proc.stdin.close()
proc.wait(timeout=5)
print("All MCP tool-call smoke tests passed.")
PYEOF
- name: MCP smoke — list_rules and explain_rule tool calls
run: |
python3 - <<'PYEOF'
import subprocess, json, time
proc = subprocess.Popen(
['./target/release/vastlint-mcp'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
_id = [0]
def send(msg):
_id[0] += 1
if 'id' not in msg:
msg = dict(msg, id=_id[0])
proc.stdin.write((json.dumps(msg) + '\n').encode())
proc.stdin.flush()
return msg.get('id')
def read_until(target_id, timeout=10):
import select
deadline = time.monotonic() + timeout
buf = b''
while time.monotonic() < deadline:
r, _, _ = select.select([proc.stdout], [], [], 0.5)
if r:
chunk = proc.stdout.read1(4096)
if chunk:
buf += chunk
while b'\n' in buf:
line, buf = buf.split(b'\n', 1)
line = line.strip()
if not line:
continue
try:
d = json.loads(line)
except Exception:
continue
if d.get('id') == target_id:
return d
raise TimeoutError(f'no response for id={target_id}')
init_id = send({'jsonrpc':'2.0','method':'initialize','params':{
'protocolVersion':'2024-11-05','capabilities':{},'clientInfo':{'name':'ci','version':'1.0'}}})
read_until(init_id)
proc.stdin.write((json.dumps({'jsonrpc':'2.0','method':'notifications/initialized','params':{}}) + '\n').encode())
proc.stdin.flush()
# list_rules — must return a non-empty catalog
lid = send({'jsonrpc':'2.0','method':'tools/call','params':{'name':'list_rules','arguments':{}}})
r = read_until(lid)
obj = json.loads(r['result']['content'][0]['text'])
assert obj['count'] > 0, f"FAIL: list_rules returned count=0"
assert len(obj['rules']) == obj['count'], "FAIL: list_rules count mismatch"
ids = [rule['id'] for rule in obj['rules']]
for expected_id in ['VAST-2.0-inline-impression', 'VAST-4.1-adservingid-present', 'VAST-2.0-root-version']:
assert expected_id in ids, f"FAIL: list_rules missing rule {expected_id}"
print(f"PASS: MCP list_rules returned {obj['count']} rules, key IDs present ✓")
# explain_rule — known rule returns description and hint
eid = send({'jsonrpc':'2.0','method':'tools/call','params':{
'name':'explain_rule','arguments':{'rule_id':'VAST-2.0-inline-impression'}}})
r = read_until(eid)
obj = json.loads(r['result']['content'][0]['text'])
assert obj['id'] == 'VAST-2.0-inline-impression', f"FAIL: explain_rule wrong id: {obj['id']}"
assert len(obj.get('description','')) > 10, f"FAIL: explain_rule empty description"
assert obj.get('severity') == 'error', f"FAIL: explain_rule wrong severity: {obj.get('severity')}"
print(f"PASS: MCP explain_rule VAST-2.0-inline-impression: severity=error, description present ✓")
# explain_rule — unknown rule returns graceful not-found message
uid = send({'jsonrpc':'2.0','method':'tools/call','params':{
'name':'explain_rule','arguments':{'rule_id':'VAST-9.9-nonexistent'}}})
r = read_until(uid)
obj = json.loads(r['result']['content'][0]['text'])
assert 'not found' in obj.get('description','').lower() or obj.get('severity') == 'unknown', \
f"FAIL: explain_rule unknown ID did not return graceful response: {obj}"
print("PASS: MCP explain_rule unknown rule ID → graceful not-found ✓")
proc.stdin.close()
proc.wait(timeout=5)
print("All MCP list_rules/explain_rule smoke tests passed.")
PYEOF
# ── 4b. WASM smoke — specific rule IDs ───────────────────────────────
- name: WASM smoke — specific error rule ID fires
run: |
node - <<'EOF'
const { validate } = require('./npm');
const fs = require('fs');
const FIXTURES = [
['err_inline_missing_impression.xml', 'VAST-2.0-inline-impression', true],
['err_adservingid_missing.xml', 'VAST-4.1-adservingid-present', true],
['err_missing_adsystem.xml', 'VAST-2.0-inline-adsystem', true],
];
let pass = 0, fail = 0;
for (const [file, ruleId, expectFires] of FIXTURES) {
const xml = fs.readFileSync(`crates/vastlint-core/tests/fixtures/${file}`, 'utf8');
const result = validate(xml);
const fires = result.issues.some(i => i.id === ruleId);
if (fires === expectFires) {
console.log(`PASS [${file} → ${ruleId}]`);
pass++;
} else {
console.error(`FAIL [${file} → ${ruleId}]: expected fires=${expectFires}, got ${fires}`);
fail++;
}
}
console.log(`Results: ${pass} passed, ${fail} failed`);
if (fail > 0) process.exit(1);
EOF
- name: WASM smoke — warning fixture valid=true, warnings>0
run: |
node - <<'EOF'
const { validate } = require('./npm');
const fs = require('fs');
// warn_vpaid.xml fires VAST-4.1-vpaid-apiframework (Warning) — document
// must be valid=true (no errors) but have warnings>0.
const xml = fs.readFileSync('crates/vastlint-core/tests/fixtures/warn_vpaid.xml', 'utf8');
const result = validate(xml);
if (!result.summary.valid) {
console.error('FAIL: warn_vpaid.xml should be valid=true (warnings are not errors)');
process.exit(1);
}
console.log('PASS: warn_vpaid.xml valid=true ✓');
if (result.summary.warnings === 0) {
console.error('FAIL: warn_vpaid.xml should have warnings>0');
process.exit(1);
}
console.log(`PASS: warn_vpaid.xml warnings=${result.summary.warnings} ✓`);
const fires = result.issues.some(i => i.id === 'VAST-4.1-vpaid-apiframework');
if (!fires) {
console.error('FAIL: VAST-4.1-vpaid-apiframework should fire on warn_vpaid.xml');
console.error('Issues:', result.issues.map(i => i.id));
process.exit(1);
}
console.log('PASS: VAST-4.1-vpaid-apiframework fires on warn_vpaid.xml ✓');
EOF
- name: WASM smoke — info fixture valid=true, errors=0
run: |
node - <<'EOF'
const { validate } = require('./npm');
const fs = require('fs');
// info_http_tracking.xml fires VAST-2.0-tracking-https at Info level.
// Document must be valid=true and errors=0.
const xml = fs.readFileSync('crates/vastlint-core/tests/fixtures/info_http_tracking.xml', 'utf8');
const result = validate(xml);
if (!result.summary.valid) {
console.error('FAIL: info_http_tracking.xml should be valid=true');
process.exit(1);
}
if (result.summary.errors !== 0) {
console.error('FAIL: info_http_tracking.xml should have errors=0, got', result.summary.errors);
process.exit(1);
}
const fires = result.issues.some(i => i.id === 'VAST-2.0-tracking-https');
if (!fires) {
console.error('FAIL: VAST-2.0-tracking-https should fire on info_http_tracking.xml');
process.exit(1);
}
console.log(`PASS: info_http_tracking.xml valid=true, errors=0, VAST-2.0-tracking-https fires ✓`);
EOF
# ── 5. CLI smoke — default text format ───────────────────────────────
- name: CLI smoke — default text format contains rule ID and severity
run: |
# Default output (no --format flag) must print human-readable text
# with at least the rule ID and "error" for an error-level fixture.
OUTPUT=$(./target/release/vastlint check \
crates/vastlint-core/tests/fixtures/err_no_ad.xml 2>/dev/null || true)
if ! echo "$OUTPUT" | grep -qi 'VAST-2\.0-ad-required\|no-ad\|ad_required\|err_no_ad'; then
echo "FAIL: text output missing expected rule reference"
echo "Output was: $OUTPUT"
exit 1
fi
if ! echo "$OUTPUT" | grep -qi 'error'; then
echo "FAIL: text output missing 'error' keyword"
echo "Output was: $OUTPUT"
exit 1
fi
echo "PASS: default text format contains rule ID and severity ✓"
# ── 6. VS Code extension unit tests ──────────────────────────────────
- name: VS Code extension — unit tests (utils.ts pure functions)
working-directory: vscode
run: |
npm ci
npm test
# ── WASM build (single canonical build) ─────────────────────────────────────
# Builds the npm package once from the attested source tree and uploads it as
# a workflow artifact. publish-npm and publish-vscode both download this
# artifact instead of rebuilding — ensuring every consumer publishes the same
# bytes that were validated by smoke-test.
#
# Building independently in each publish job means:
# - Different jobs may produce different binaries (non-reproducible Rust/WASM)
# - The published npm package and the VSIX may embed different WASM blobs
# - Neither matches what was tested in smoke-test
# - The SLSA provenance covers the release binaries but not what npm/vscode ship
build-wasm:
name: Build WASM npm package
runs-on: ubuntu-latest
needs: smoke-test
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # v (pinned SHA)
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Install wasm-pack
run: cargo install wasm-pack --locked
- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '20'
- name: Build WASM (bundler target — ESM)
run: wasm-pack build crates/vastlint-wasm --target bundler --out-dir ../../npm/pkg
- name: Build WASM (nodejs target — CJS)
run: wasm-pack build crates/vastlint-wasm --target nodejs --out-dir ../../npm/pkg-node
- name: Assemble npm package
run: node npm/scripts/assemble.js
- name: Upload assembled npm package
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wasm-npm-package
path: npm/
# Retain for the full workflow run so publish jobs can download it.
retention-days: 1
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs: smoke-test
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
binary: vastlint
crate: vastlint-cli
archive: vastlint-linux-x86_64.tar.gz
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
binary: vastlint
crate: vastlint-cli
archive: vastlint-linux-aarch64.tar.gz
- target: x86_64-apple-darwin
os: macos-latest
binary: vastlint
crate: vastlint-cli
archive: vastlint-macos-x86_64.tar.gz
- target: aarch64-apple-darwin
os: macos-latest
binary: vastlint
crate: vastlint-cli
archive: vastlint-macos-aarch64.tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
binary: vastlint-mcp
crate: vastlint-mcp
archive: vastlint-mcp-linux-x86_64.tar.gz
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
binary: vastlint-mcp
crate: vastlint-mcp
archive: vastlint-mcp-linux-aarch64.tar.gz
- target: x86_64-apple-darwin
os: macos-latest
binary: vastlint-mcp
crate: vastlint-mcp
archive: vastlint-mcp-macos-x86_64.tar.gz
- target: aarch64-apple-darwin
os: macos-latest
binary: vastlint-mcp
crate: vastlint-mcp
archive: vastlint-mcp-macos-aarch64.tar.gz
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # v (pinned SHA)
with:
toolchain: stable
targets: ${{ matrix.target }}
# Stamp every crate's Cargo.toml with the release version so that
# env!("CARGO_PKG_VERSION") inside the binary matches the git tag.
- name: Bump crate versions to match git tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
for toml in crates/*/Cargo.toml; do
# crate's own [package] version
sed -i.bak -E "s/^version = \"[^\"]*\"/version = \"${VERSION}\"/" "$toml"
# inter-crate path-dependency version pins, e.g. cli/mcp/wasm pin
# vastlint-core = { path = "...", version = "X" }; path-only deps untouched
sed -i.bak -E "s/(vastlint-[a-z-]+ = \{[^}]*version = \")[^\"]*(\")/\1${VERSION}\2/g" "$toml"
rm "$toml.bak"
done
echo "Bumped all crates to ${VERSION}"
- name: Install musl tools (Linux)
if: contains(matrix.target, 'musl')
run: |
sudo apt-get update -q
sudo apt-get install -y musl-tools
- name: Install cross (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: cargo install cross --locked
- name: Build (cross — Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: cross build --release --target ${{ matrix.target }} -p ${{ matrix.crate }}
- name: Build (cargo — all others)
if: matrix.target != 'aarch64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }} -p ${{ matrix.crate }}
- name: Package
run: |
BINARY=target/${{ matrix.target }}/release/${{ matrix.binary }}
tar czf ${{ matrix.archive }} -C $(dirname $BINARY) $(basename $BINARY)
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
# ── C FFI library build ─────────────────────────────────────────────────────
# Builds vastlint-ffi as both a shared library (.so/.dylib) and a static
# archive (.a) for each supported platform. The output tarballs contain:
# vastlint.h — C header (ABI contract, same across all platforms)
# libvastlint.a — static library for link-time embedding (Go CGo, etc.)
# libvastlint.so — shared library for runtime linking (Linux)
# libvastlint.dylib — shared library for runtime linking (macOS)
#
# These artifacts are the foundation for Go, Ruby, Python, Java, and Erlang
# language bindings.
build-ffi:
name: Build FFI ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs: smoke-test
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
static: libvastlint.a
shared: libvastlint.so
archive: vastlint-ffi-linux-x86_64.tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
static: libvastlint.a
shared: libvastlint.so
archive: vastlint-ffi-linux-aarch64.tar.gz
- target: x86_64-apple-darwin
os: macos-latest
static: libvastlint.a
shared: libvastlint.dylib
archive: vastlint-ffi-macos-x86_64.tar.gz
- target: aarch64-apple-darwin
os: macos-latest
static: libvastlint.a
shared: libvastlint.dylib
archive: vastlint-ffi-macos-aarch64.tar.gz
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # v (pinned SHA)
with:
toolchain: stable
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1