Skip to content

Commit 574777b

Browse files
gHashTagona-agent
andcommitted
ci: Add GitHub Actions workflow for extension WASM tests
- Build WASM module with Zig 0.13.0 - Verify WASM magic bytes - Run Node.js WASM tests - Validate manifest.json syntax and required fields - Package extension as artifact Triggers on changes to extension/ or neodetect_wasm.zig Co-authored-by: Ona <no-reply@ona.com>
1 parent f317dba commit 574777b

1 file changed

Lines changed: 155 additions & 0 deletions

File tree

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# NeoDetect Extension CI
2+
# Tests WASM module and extension functionality
3+
4+
name: Extension Tests
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths:
10+
- 'extension/**'
11+
- 'src/firebird/neodetect_wasm.zig'
12+
- '.github/workflows/extension-tests.yml'
13+
pull_request:
14+
branches: [main]
15+
paths:
16+
- 'extension/**'
17+
- 'src/firebird/neodetect_wasm.zig'
18+
19+
jobs:
20+
build-wasm:
21+
name: Build WASM Module
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Setup Zig
28+
uses: goto-bus-stop/setup-zig@v2
29+
with:
30+
version: 0.13.0
31+
32+
- name: Build WASM
33+
run: |
34+
zig build-exe src/firebird/neodetect_wasm.zig \
35+
-target wasm32-freestanding \
36+
-O ReleaseFast \
37+
-fno-entry \
38+
-rdynamic \
39+
-femit-bin=extension/chrome/wasm/neodetect.wasm
40+
41+
echo "WASM built successfully"
42+
ls -la extension/chrome/wasm/neodetect.wasm
43+
44+
- name: Verify WASM magic bytes
45+
run: |
46+
MAGIC=$(head -c 4 extension/chrome/wasm/neodetect.wasm | xxd -p)
47+
if [ "$MAGIC" = "0061736d" ]; then
48+
echo "✅ Valid WASM magic bytes"
49+
else
50+
echo "❌ Invalid WASM magic bytes: $MAGIC"
51+
exit 1
52+
fi
53+
54+
- name: Upload WASM artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: neodetect-wasm
58+
path: extension/chrome/wasm/neodetect.wasm
59+
60+
test-wasm:
61+
name: Test WASM Module
62+
runs-on: ubuntu-latest
63+
needs: build-wasm
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Download WASM artifact
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: neodetect-wasm
72+
path: extension/chrome/wasm/
73+
74+
- name: Setup Node.js
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: '20'
78+
79+
- name: Install test dependencies
80+
run: |
81+
cd extension/test
82+
npm install --ignore-scripts
83+
84+
- name: Run WASM tests
85+
run: |
86+
cd extension/test
87+
node wasm-test.js
88+
89+
validate-manifest:
90+
name: Validate Extension Manifest
91+
runs-on: ubuntu-latest
92+
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- name: Validate manifest.json
97+
run: |
98+
cd extension/chrome
99+
100+
# Check JSON syntax
101+
python3 -c "import json; json.load(open('manifest.json'))"
102+
echo "✅ manifest.json is valid JSON"
103+
104+
# Check required fields
105+
python3 << 'EOF'
106+
import json
107+
108+
with open('manifest.json') as f:
109+
manifest = json.load(f)
110+
111+
required = ['manifest_version', 'name', 'version', 'description']
112+
for field in required:
113+
if field not in manifest:
114+
print(f"❌ Missing required field: {field}")
115+
exit(1)
116+
print(f"✅ {field}: {manifest[field]}")
117+
118+
if manifest['manifest_version'] != 3:
119+
print("❌ Must be Manifest V3")
120+
exit(1)
121+
122+
print("✅ All required fields present")
123+
EOF
124+
125+
package-extension:
126+
name: Package Extension
127+
runs-on: ubuntu-latest
128+
needs: [build-wasm, test-wasm, validate-manifest]
129+
130+
steps:
131+
- uses: actions/checkout@v4
132+
133+
- name: Download WASM artifact
134+
uses: actions/download-artifact@v4
135+
with:
136+
name: neodetect-wasm
137+
path: extension/chrome/wasm/
138+
139+
- name: Create extension package
140+
run: |
141+
cd extension/chrome
142+
zip -r ../neodetect-${{ github.sha }}.zip . \
143+
-x "*.DS_Store" \
144+
-x "__MACOSX/*" \
145+
-x "screenshots/*" \
146+
-x "promo/*"
147+
148+
echo "Package created:"
149+
ls -la ../neodetect-${{ github.sha }}.zip
150+
151+
- name: Upload extension package
152+
uses: actions/upload-artifact@v4
153+
with:
154+
name: neodetect-extension
155+
path: extension/neodetect-*.zip

0 commit comments

Comments
 (0)