-
Notifications
You must be signed in to change notification settings - Fork 0
874 lines (725 loc) · 31.8 KB
/
Copy pathecosystem-smoke.yml
File metadata and controls
874 lines (725 loc) · 31.8 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
name: Ecosystem smoke
on:
schedule:
- cron: "17 */4 * * *"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ecosystem-smoke
cancel-in-progress: true
env:
VASTLINT_VERSION: "0.4.22"
VALID_FIXTURE: crates/vastlint-core/tests/fixtures/valid_4.2.xml
INVALID_FIXTURE: crates/vastlint-core/tests/fixtures/err_no_ad.xml
CHROME_WEB_STORE_EXTENSION_ID: "chbbcgdpdpcmkocbmeljkfefeeknghnb"
jobs:
smoke-cli:
name: Smoke published CLI
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # v (pinned SHA)
with:
toolchain: stable
- name: Install published vastlint CLI
run: |
INSTALL_ROOT="$RUNNER_TEMP/vastlint-cli"
cargo install --locked vastlint-cli --version "$VASTLINT_VERSION" --root "$INSTALL_ROOT"
echo "$INSTALL_ROOT/bin" >> "$GITHUB_PATH"
- name: Validate fixtures with published CLI
shell: bash
run: |
set -euo pipefail
valid_json="$RUNNER_TEMP/valid-cli.json"
invalid_json="$RUNNER_TEMP/invalid-cli.json"
vastlint check "$VALID_FIXTURE" --format json > "$valid_json"
set +e
vastlint check "$INVALID_FIXTURE" --format json > "$invalid_json"
exit_code=$?
set -e
if [ "$exit_code" -eq 0 ]; then
echo "Expected invalid fixture to fail the CLI smoke test"
exit 1
fi
python3 -c 'import json, sys; valid = json.load(open(sys.argv[1], encoding="utf-8")); invalid = json.load(open(sys.argv[2], encoding="utf-8")); assert valid["summary"]["errors"] == 0, valid; assert invalid["summary"]["errors"] > 0, invalid; print("CLI smoke passed")' "$valid_json" "$invalid_json"
smoke-rust-core:
name: Smoke published Rust crate
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # v (pinned SHA)
with:
toolchain: stable
- name: Build disposable Rust app with vastlint-core
shell: bash
run: |
set -euo pipefail
APP_DIR="$RUNNER_TEMP/vastlint-core-smoke"
mkdir -p "$APP_DIR/src"
printf '%s\n' \
'[package]' \
'name = "vastlint-core-smoke"' \
'version = "0.1.0"' \
'edition = "2021"' \
'' \
'[dependencies]' \
"vastlint-core = { version = \"=${VASTLINT_VERSION}\" }" \
> "$APP_DIR/Cargo.toml"
printf '%s\n' \
'use std::{env, fs};' \
'use vastlint_core::validate;' \
'' \
'fn main() {' \
' let mut args = env::args().skip(1);' \
' let valid_path = args.next().expect("valid fixture path");' \
' let invalid_path = args.next().expect("invalid fixture path");' \
'' \
' let valid = validate(&fs::read_to_string(valid_path).expect("read valid fixture"));' \
' assert_eq!(valid.summary.errors, 0, "expected valid fixture to have zero errors");' \
'' \
' let invalid = validate(&fs::read_to_string(invalid_path).expect("read invalid fixture"));' \
' assert!(invalid.summary.errors > 0, "expected invalid fixture to have errors");' \
'' \
' println!("Rust crate smoke passed ({} errors on invalid fixture)", invalid.summary.errors);' \
'}' \
> "$APP_DIR/src/main.rs"
cargo run --quiet --manifest-path "$APP_DIR/Cargo.toml" -- \
"$GITHUB_WORKSPACE/$VALID_FIXTURE" \
"$GITHUB_WORKSPACE/$INVALID_FIXTURE"
smoke-npm:
name: Smoke published npm packages
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
package-manager-cache: false
- name: Install published vastlint npm package in a clean app
shell: bash
run: |
set -euo pipefail
APP_DIR="$RUNNER_TEMP/vastlint-npm-smoke"
mkdir -p "$APP_DIR"
printf '%s\n' \
'{' \
' "name": "vastlint-npm-smoke",' \
' "private": true,' \
' "type": "module"' \
'}' \
> "$APP_DIR/package.json"
pushd "$APP_DIR" >/dev/null
PACKED_TARBALL="$(npm pack "vastlint@${VASTLINT_VERSION}" --silent)"
mkdir -p node_modules
tar -xzf "$PACKED_TARBALL" -C node_modules
mv node_modules/package node_modules/vastlint
rm "$PACKED_TARBALL"
printf '%s\n' \
"import fs from 'node:fs';" \
"import { validate } from 'vastlint';" \
'' \
'const [validPath, invalidPath] = process.argv.slice(2);' \
'' \
"const valid = validate(fs.readFileSync(validPath, 'utf8'));" \
'if (!valid.summary.valid || valid.summary.errors !== 0) {' \
' throw new Error("expected valid fixture to pass: " + JSON.stringify(valid.summary));' \
'}' \
'' \
"const invalid = validate(fs.readFileSync(invalidPath, 'utf8'));" \
'if (invalid.summary.valid || invalid.summary.errors === 0) {' \
' throw new Error("expected invalid fixture to fail: " + JSON.stringify(invalid.summary));' \
'}' \
'' \
'console.log("npm smoke passed (" + invalid.summary.errors + " errors on invalid fixture)");' \
> smoke.mjs
node smoke.mjs \
"$GITHUB_WORKSPACE/$VALID_FIXTURE" \
"$GITHUB_WORKSPACE/$INVALID_FIXTURE"
popd >/dev/null
- name: Install published vastlint-client npm package in a clean app
shell: bash
run: |
set -euo pipefail
APP_DIR="$RUNNER_TEMP/vastlint-client-smoke"
mkdir -p "$APP_DIR"
printf '%s\n' \
'{' \
' "name": "vastlint-client-smoke",' \
' "private": true,' \
' "type": "module"' \
'}' \
> "$APP_DIR/package.json"
pushd "$APP_DIR" >/dev/null
PACKED_TARBALL="$(npm pack "vastlint-client@${VASTLINT_VERSION}" --silent)"
npm install --no-package-lock --ignore-scripts "./$PACKED_TARBALL"
rm "$PACKED_TARBALL"
cat > smoke.mjs <<'EOF'
import fs from 'node:fs';
import {
createVastPlaybackController,
createVastSession,
selectResolvedAdMediaFile,
selectTrackingTargets,
} from 'vastlint-client';
const [validPath, invalidPath] = process.argv.slice(2);
const playbackFixture = `<?xml version="1.0" encoding="UTF-8"?>
<VAST version="4.2">
<Ad id="playback-1">
<InLine>
<AdSystem>Playback Demo</AdSystem>
<AdTitle>Playback Fixture</AdTitle>
<Error><![CDATA[https://track.example.com/error?code=%%ERRORCODE%%]]></Error>
<Impression><![CDATA[https://track.example.com/impression]]></Impression>
<Creatives>
<Creative>
<Linear>
<Duration>00:00:20</Duration>
<TrackingEvents>
<Tracking event="creativeView"><![CDATA[https://track.example.com/creative-view]]></Tracking>
<Tracking event="start"><![CDATA[https://track.example.com/start]]></Tracking>
<Tracking event="firstQuartile"><![CDATA[https://track.example.com/first-quartile]]></Tracking>
</TrackingEvents>
<VideoClicks>
<ClickThrough><![CDATA[https://click.example.com/landing]]></ClickThrough>
<ClickTracking><![CDATA[https://track.example.com/click]]></ClickTracking>
</VideoClicks>
<MediaFiles>
<MediaFile delivery="progressive" type="video/mp4" width="1280" height="720"><![CDATA[https://cdn.example.com/video.mp4]]></MediaFile>
</MediaFiles>
</Linear>
</Creative>
</Creatives>
</InLine>
</Ad>
</VAST>`;
function createPixelResponse() {
return {
ok: true,
status: 204,
statusText: 'No Content',
async text() {
return '';
},
};
}
const validSession = createVastSession({
source: { kind: 'xml', xml: fs.readFileSync(validPath, 'utf8') },
});
const validResult = await validSession.validate();
if (!validResult.summary.valid || validResult.summary.errors !== 0) {
throw new Error('expected valid fixture to pass: ' + JSON.stringify(validResult.summary));
}
const invalidSession = createVastSession({
source: { kind: 'xml', xml: fs.readFileSync(invalidPath, 'utf8') },
});
const invalidResult = await invalidSession.validate();
if (invalidResult.summary.valid || invalidResult.summary.errors === 0) {
throw new Error('expected invalid fixture to fail: ' + JSON.stringify(invalidResult.summary));
}
const trackingCalls = [];
const playbackSession = createVastSession({
source: { kind: 'xml', xml: playbackFixture },
fetch: async (url) => {
trackingCalls.push(String(url));
return createPixelResponse();
},
});
await playbackSession.resolve();
const playbackSnapshot = playbackSession.getSnapshot();
if (!playbackSnapshot.resolvedAd?.resolved) {
throw new Error('expected playback fixture to resolve to an inline ad');
}
const mediaSelection = selectResolvedAdMediaFile(playbackSnapshot.resolvedAd, {
supportedMimeTypes: ['video/mp4'],
});
if (mediaSelection.selected?.url !== 'https://cdn.example.com/video.mp4') {
throw new Error('expected playback fixture media to be selected');
}
const startTargets = selectTrackingTargets(playbackSession.getSnapshot().tracking.plan, 'start');
if (startTargets.length !== 1) {
throw new Error('expected one start tracking target, got ' + startTargets.length);
}
const playback = createVastPlaybackController({
session: playbackSession,
autoResolve: false,
mediaSelection: {
supportedMimeTypes: ['video/mp4'],
},
});
await playback.initialize();
await playback.start();
if (playback.getSnapshot().status !== 'playing') {
throw new Error('expected playback controller to enter playing state');
}
for (const url of [
'https://track.example.com/impression',
'https://track.example.com/creative-view',
'https://track.example.com/start',
]) {
if (!trackingCalls.includes(url)) {
throw new Error('expected playback tracking call for ' + url);
}
}
console.log('vastlint-client smoke passed');
EOF
node smoke.mjs \
"$GITHUB_WORKSPACE/$VALID_FIXTURE" \
"$GITHUB_WORKSPACE/$INVALID_FIXTURE"
popd >/dev/null
- name: Install published vastlint-react npm package in a clean app
shell: bash
run: |
set -euo pipefail
APP_DIR="$RUNNER_TEMP/vastlint-react-smoke"
mkdir -p "$APP_DIR"
printf '%s\n' \
'{' \
' "name": "vastlint-react-smoke",' \
' "private": true,' \
' "type": "module"' \
'}' \
> "$APP_DIR/package.json"
pushd "$APP_DIR" >/dev/null
PACKED_TARBALL="$(npm pack "vastlint-react@${VASTLINT_VERSION}" --silent)"
npm install --no-package-lock --ignore-scripts \
"./$PACKED_TARBALL" \
react@19.2.0 \
react-dom@19.2.0 \
jsdom@26.1.0
rm "$PACKED_TARBALL"
cat > smoke.mjs <<'EOF'
import React, { act } from 'react';
import { JSDOM } from 'jsdom';
import { createRoot } from 'react-dom/client';
import { createVastSession } from 'vastlint-client';
import { useVastPlayback } from 'vastlint-react';
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
function defineGlobal(name, value) {
Object.defineProperty(globalThis, name, {
configurable: true,
writable: true,
value,
});
}
function installDomGlobals(window) {
defineGlobal('window', window);
defineGlobal('document', window.document);
defineGlobal('navigator', window.navigator);
defineGlobal('HTMLElement', window.HTMLElement);
defineGlobal('Node', window.Node);
defineGlobal('Event', window.Event);
defineGlobal('CustomEvent', window.CustomEvent);
defineGlobal('requestAnimationFrame', (callback) => setTimeout(() => callback(Date.now()), 0));
defineGlobal('cancelAnimationFrame', (id) => clearTimeout(id));
}
function createPixelResponse() {
return {
ok: true,
status: 204,
statusText: 'No Content',
async text() {
return '';
},
};
}
const playbackFixture = `<?xml version="1.0" encoding="UTF-8"?>
<VAST version="4.2">
<Ad id="playback-1">
<InLine>
<AdSystem>Playback Demo</AdSystem>
<AdTitle>Playback Fixture</AdTitle>
<Impression><![CDATA[https://track.example.com/impression]]></Impression>
<Creatives>
<Creative>
<Linear>
<Duration>00:00:20</Duration>
<TrackingEvents>
<Tracking event="creativeView"><![CDATA[https://track.example.com/creative-view]]></Tracking>
<Tracking event="start"><![CDATA[https://track.example.com/start]]></Tracking>
</TrackingEvents>
<MediaFiles>
<MediaFile delivery="progressive" type="video/mp4" width="1280" height="720"><![CDATA[https://cdn.example.com/video.mp4]]></MediaFile>
</MediaFiles>
</Linear>
</Creative>
</Creatives>
</InLine>
</Ad>
</VAST>`;
const trackingCalls = [];
const dom = new JSDOM('<!doctype html><html><body></body></html>');
installDomGlobals(dom.window);
async function mountHook(useHook) {
let latestResult = null;
const container = dom.window.document.createElement('div');
dom.window.document.body.append(container);
const root = createRoot(container);
function Probe() {
latestResult = useHook();
return null;
}
await act(async () => {
root.render(React.createElement(Probe));
});
return {
getLatest() {
if (!latestResult) {
throw new Error('expected hook result to be available');
}
return latestResult;
},
async unmount() {
await act(async () => {
root.unmount();
});
},
};
}
const session = createVastSession({
source: { kind: 'xml', xml: playbackFixture },
fetch: async (url) => {
trackingCalls.push(String(url));
return createPixelResponse();
},
});
const mounted = await mountHook(() => useVastPlayback({
session,
autoInitialize: false,
mediaSelection: {
supportedMimeTypes: ['video/mp4'],
},
}));
if (mounted.getLatest().snapshot.status !== 'idle') {
throw new Error('expected hook playback to start idle');
}
await act(async () => {
await mounted.getLatest().initialize();
});
if (mounted.getLatest().snapshot.status !== 'ready') {
throw new Error('expected hook playback to become ready');
}
if (mounted.getLatest().snapshot.resolvedAd?.adTitle !== 'Playback Fixture') {
throw new Error('expected hook playback to expose resolved ad metadata');
}
await act(async () => {
await mounted.getLatest().start();
});
if (mounted.getLatest().snapshot.status !== 'playing') {
throw new Error('expected hook playback to enter playing state');
}
if (mounted.getLatest().snapshot.mediaSelection.selected?.url !== 'https://cdn.example.com/video.mp4') {
throw new Error('expected hook playback to expose selected media metadata');
}
for (const url of [
'https://track.example.com/impression',
'https://track.example.com/creative-view',
'https://track.example.com/start',
]) {
if (!trackingCalls.includes(url)) {
throw new Error('expected hook playback tracking call for ' + url);
}
}
await mounted.unmount();
dom.window.close();
console.log('vastlint-react smoke passed');
EOF
node smoke.mjs
popd >/dev/null
smoke-chrome-extension:
name: Smoke Chrome extension build
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '20'
package-manager-cache: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
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: Build WASM payload for extensions
run: |
wasm-pack build crates/vastlint-wasm --target bundler --out-dir ../../npm/pkg
wasm-pack build crates/vastlint-wasm --target nodejs --out-dir ../../npm/pkg-node
- name: Assemble npm package
run: node npm/scripts/assemble.js
- name: Install Chrome extension dependencies
working-directory: chrome
run: npm ci
- name: Build Chrome extension
working-directory: chrome
run: npm run build
- name: Verify Chrome extension dist output
working-directory: chrome
run: |
REQUIRED=(
dist/manifest.json
dist/content.js
dist/service-worker.js
dist/popup.js
dist/popup.html
dist/vastlint_wasm_bg.wasm
)
MISSING=0
for f in "${REQUIRED[@]}"; do
if [ ! -f "$f" ]; then
echo "MISSING: $f"
MISSING=$((MISSING + 1))
else
echo "OK: $f"
fi
done
[ "$MISSING" -eq 0 ] || { echo "$MISSING required file(s) missing from dist/"; exit 1; }
- name: Install Playwright and Google Chrome
shell: bash
run: |
set -euo pipefail
SMOKE_DIR="$RUNNER_TEMP/chrome-browser-smoke"
mkdir -p "$SMOKE_DIR"
pushd "$SMOKE_DIR" >/dev/null
npm init -y >/dev/null 2>&1
npm install --no-save playwright@1.55.0
npx playwright install --with-deps chrome
popd >/dev/null
echo "CHROME_SMOKE_DIR=$SMOKE_DIR" >> "$GITHUB_ENV"
- name: Configure Chrome Web Store policy install
shell: bash
run: |
set -euo pipefail
sudo install -d -m 0755 /etc/opt/chrome/policies/managed
cat <<EOF | sudo tee /etc/opt/chrome/policies/managed/vastlint-smoke.json >/dev/null
{
"ExtensionInstallForcelist": [
"${CHROME_WEB_STORE_EXTENSION_ID};https://clients2.google.com/service/update2/crx"
]
}
EOF
- name: Smoke unpacked and Web Store Chrome extension installs
shell: bash
run: |
set -euo pipefail
cat > "$CHROME_SMOKE_DIR/smoke-extension.mjs" <<'EOF'
import http from 'node:http';
import path from 'node:path';
import { chromium } from 'playwright';
const extensionPath = path.join(process.env.GITHUB_WORKSPACE, 'chrome', 'dist');
const publishedExtensionId = process.env.CHROME_WEB_STORE_EXTENSION_ID;
const fixtureHtml = `<!doctype html>
<html>
<body>
<pre><?xml version="1.0" encoding="UTF-8"?>
<VAST version="4.2">
<Ad id="fixture-1">
<InLine>
<AdTitle>Broken fixture</AdTitle>
</InLine>
</Ad>
</VAST></pre>
</body>
</html>`;
let server;
async function waitForOverlay(page, timeoutMs) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const overlayCount = await page.locator('[data-vastlint-overlay]').count();
if (overlayCount > 0) {
return overlayCount;
}
await page.reload({ waitUntil: 'networkidle' });
await page.waitForTimeout(1500);
}
throw new Error('Timed out waiting for VASTlint overlay injection');
}
async function smokeChromeInstall({ label, userDataDir, args = [], expectedPrefix }) {
let context;
try {
context = await chromium.launchPersistentContext(userDataDir, {
channel: 'chrome',
headless: false,
args,
});
const page = await context.newPage();
await page.goto(`http://127.0.0.1:${server.address().port}/`, { waitUntil: 'networkidle' });
await waitForOverlay(page, 90000);
const overlayCount = await page.locator('[data-vastlint-overlay]').count();
if (overlayCount < 1) {
throw new Error(`Expected VASTlint overlay to be injected for ${label}`);
}
// The MV3 service worker can spin up lazily after extension activity.
// Overlay injection is the primary smoke signal; service worker URL is best-effort diagnostics.
let serviceWorkerUrl = 'unavailable';
let serviceWorker = context.serviceWorkers().find((worker) => worker.url().startsWith(expectedPrefix));
if (!serviceWorker) {
try {
serviceWorker = await context.waitForEvent('serviceworker', {
timeout: 15000,
predicate: (worker) => worker.url().startsWith(expectedPrefix),
});
} catch {
// Do not fail solely on lazy worker startup once overlay was confirmed.
}
}
if (serviceWorker) {
serviceWorkerUrl = serviceWorker.url();
}
console.log(`${label} smoke passed (${serviceWorkerUrl})`);
} finally {
await context?.close();
}
}
try {
server = http.createServer((_req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.end(fixtureHtml);
});
await new Promise((resolve, reject) => {
server.listen(0, '127.0.0.1', (err) => (err ? reject(err) : resolve()));
});
const address = server.address();
if (!address || typeof address === 'string') {
throw new Error('Failed to determine local server address');
}
await smokeChromeInstall({
label: 'Unpacked Chrome extension',
userDataDir: path.join(process.env.RUNNER_TEMP, 'chrome-profile-unpacked'),
args: [
`--disable-extensions-except=${extensionPath}`,
`--load-extension=${extensionPath}`,
],
expectedPrefix: 'chrome-extension://',
});
await smokeChromeInstall({
label: 'Chrome Web Store extension',
userDataDir: path.join(process.env.RUNNER_TEMP, 'chrome-profile-webstore'),
expectedPrefix: `chrome-extension://${publishedExtensionId}/`,
});
} finally {
await new Promise((resolve) => server?.close(() => resolve()));
}
EOF
xvfb-run -a env CHROME_WEB_STORE_EXTENSION_ID="$CHROME_WEB_STORE_EXTENSION_ID" node "$CHROME_SMOKE_DIR/smoke-extension.mjs"
smoke-vscode-vscodium-extension:
name: Smoke VS Code/VSCodium extension package
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '22'
package-manager-cache: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
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: Build WASM payload for extension npm dependency
run: |
wasm-pack build crates/vastlint-wasm --target bundler --out-dir ../../npm/pkg
wasm-pack build crates/vastlint-wasm --target nodejs --out-dir ../../npm/pkg-node
- name: Assemble npm package
run: node npm/scripts/assemble.js
- name: Install VS Code extension dependencies
working-directory: vscode
run: npm ci
- name: Bundle extension
working-directory: vscode
run: npm run bundle
- name: Package VSIX (usable by VS Code and VSCodium/Open VSX)
working-directory: vscode
run: npx --no-install vsce package --no-update-package-json --out vastlint-smoke.vsix
- name: Verify VSIX contents
working-directory: vscode
run: |
test -s vastlint-smoke.vsix
unzip -l vastlint-smoke.vsix | grep -q 'extension/package.json'
unzip -l vastlint-smoke.vsix | grep -q 'extension/out/extension.js'
smoke-editor-marketplace-install:
name: Smoke editor marketplace installs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '22'
package-manager-cache: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
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: Build WASM payload for extension npm dependency
run: |
wasm-pack build crates/vastlint-wasm --target bundler --out-dir ../../npm/pkg
wasm-pack build crates/vastlint-wasm --target nodejs --out-dir ../../npm/pkg-node
- name: Assemble npm package
run: node npm/scripts/assemble.js
- name: Build and package VSIX
working-directory: vscode
run: |
npm ci
npm run bundle
npx --no-install vsce package --no-update-package-json --out vastlint-smoke.vsix
- name: Download portable VS Code and VSCodium
shell: bash
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/editors"
curl -fL "https://update.code.visualstudio.com/latest/linux-x64/stable" -o "$RUNNER_TEMP/editors/vscode.tar.gz"
mkdir -p "$RUNNER_TEMP/editors/vscode"
tar -xzf "$RUNNER_TEMP/editors/vscode.tar.gz" -C "$RUNNER_TEMP/editors/vscode"
echo "VSCODE_BIN=$RUNNER_TEMP/editors/vscode/VSCode-linux-x64/bin/code" >> "$GITHUB_ENV"
CODIUM_URL="$(curl -fsSL https://api.github.com/repos/VSCodium/vscodium/releases/latest | grep browser_download_url | grep 'VSCodium-linux-x64-.*\.tar\.gz' | head -n1 | cut -d '"' -f4)"
if [[ -z "$CODIUM_URL" ]]; then
echo "Could not determine VSCodium release tarball URL"
exit 1
fi
curl -fL "$CODIUM_URL" -o "$RUNNER_TEMP/editors/vscodium.tar.gz"
mkdir -p "$RUNNER_TEMP/editors/vscodium"
tar -xzf "$RUNNER_TEMP/editors/vscodium.tar.gz" -C "$RUNNER_TEMP/editors/vscodium"
echo "VSCODIUM_BIN=$RUNNER_TEMP/editors/vscodium/bin/codium" >> "$GITHUB_ENV"
- name: Install from VS Code Marketplace in VS Code
shell: bash
run: |
set -euo pipefail
"$VSCODE_BIN" --user-data-dir "$RUNNER_TEMP/vscode-user" --extensions-dir "$RUNNER_TEMP/vscode-exts" --install-extension aleksUIX.vastlint --force
"$VSCODE_BIN" --user-data-dir "$RUNNER_TEMP/vscode-user" --extensions-dir "$RUNNER_TEMP/vscode-exts" --list-extensions | grep -qi '^aleksuix\.vastlint$'
- name: Install from Open VSX in VSCodium
shell: bash
run: |
set -euo pipefail
"$VSCODIUM_BIN" --user-data-dir "$RUNNER_TEMP/codium-user" --extensions-dir "$RUNNER_TEMP/codium-exts" --install-extension aleksUIX.vastlint --force
"$VSCODIUM_BIN" --user-data-dir "$RUNNER_TEMP/codium-user" --extensions-dir "$RUNNER_TEMP/codium-exts" --list-extensions | grep -qi '^aleksuix\.vastlint$'
- name: Install local VSIX in both editors
shell: bash
run: |
set -euo pipefail
VSIX_PATH="$GITHUB_WORKSPACE/vscode/vastlint-smoke.vsix"
test -f "$VSIX_PATH"
"$VSCODE_BIN" --user-data-dir "$RUNNER_TEMP/vscode-user-local" --extensions-dir "$RUNNER_TEMP/vscode-exts-local" --install-extension "$VSIX_PATH" --force
"$VSCODE_BIN" --user-data-dir "$RUNNER_TEMP/vscode-user-local" --extensions-dir "$RUNNER_TEMP/vscode-exts-local" --list-extensions | grep -qi '^aleksuix\.vastlint$'
"$VSCODIUM_BIN" --user-data-dir "$RUNNER_TEMP/codium-user-local" --extensions-dir "$RUNNER_TEMP/codium-exts-local" --install-extension "$VSIX_PATH" --force
"$VSCODIUM_BIN" --user-data-dir "$RUNNER_TEMP/codium-user-local" --extensions-dir "$RUNNER_TEMP/codium-exts-local" --list-extensions | grep -qi '^aleksuix\.vastlint$'