Skip to content

Commit dfacb5b

Browse files
ci: simplify example check
1 parent 017a9de commit dfacb5b

File tree

5 files changed

+100
-142
lines changed

5 files changed

+100
-142
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

.github/workflows/legacy-check.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: check legacy examples
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
paths:
9+
- legacy/examples
10+
schedule:
11+
- cron: "0 10 * * 2"
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os:
18+
- ubuntu-latest
19+
- macos-latest
20+
- windows-latest
21+
runs-on: ${{ matrix.os }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: install
26+
uses: ./.github/actions/setup
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: "3.x"
32+
33+
- name: moon check and test
34+
run: python scripts/check-legacy-examples.py

.github/workflows/next-check.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ on:
88
paths:
99
- next/sources/**
1010
schedule:
11-
- cron: '0 10 * * 2'
11+
- cron: "0 10 * * 2"
1212

1313
jobs:
1414
build:
1515
strategy:
1616
matrix:
17-
os:
17+
os:
1818
- ubuntu-latest
1919
- macos-latest
2020
- windows-latest
21-
backend: [wasm, wasm-gc, js]
2221
runs-on: ${{ matrix.os }}
2322
steps:
2423
- uses: actions/checkout@v4
@@ -29,9 +28,8 @@ jobs:
2928
- name: Set up Python
3029
uses: actions/setup-python@v4
3130
with:
32-
python-version: '3.x'
31+
python-version: "3.x"
3332

3433
- name: moon check and test
3534
run: |
36-
moon update
37-
python scripts/check-document.py --backend ${{ matrix.backend }}
35+
python scripts/check-document.py

scripts/check-document.py

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,46 @@
11
#!/usr/bin/env python3
2-
import sys
32
import subprocess
4-
import argparse
3+
import sys
54
from pathlib import Path
65

76

8-
def run_cmd(cmd, cwd=None):
9-
"""Run command and return success status."""
10-
try:
11-
subprocess.run(cmd, cwd=cwd, check=True)
12-
return True
13-
except subprocess.CalledProcessError:
14-
print(f"Failed: {' '.join(cmd)} in {cwd}")
15-
return False
16-
17-
187
def main():
19-
parser = argparse.ArgumentParser()
20-
parser.add_argument("--backend", required=True,
21-
choices=["wasm", "wasm-gc", "js"])
22-
args = parser.parse_args()
23-
248
# Process directories
259
failed = []
2610
for dir_path in Path("next/sources").iterdir():
27-
if not dir_path.is_dir():
11+
if not dir_path.is_dir() or dir_path.name.startswith('.') or dir_path.name == "target":
2812
continue
2913

3014
# Skip error codes; they should be handled with another script
3115
if dir_path.name == "error_codes":
3216
continue
17+
3318
# Skip async for non-js backends
34-
if dir_path.name == "async" and args.backend != "js":
35-
continue
19+
targets = "all"
20+
if dir_path.name == "async":
21+
targets = "js"
3622

3723
print(f"Processing {dir_path}")
3824

3925
# Run moon commands
40-
commands = [
41-
["moon", "install"],
42-
["moon", "check", "--deny-warn", "--target", args.backend],
43-
["moon", "test", "--target", args.backend]
44-
]
45-
46-
if not all(run_cmd(cmd, dir_path) for cmd in commands):
47-
failed.append(str(dir_path))
26+
try:
27+
subprocess.run(["moon", "install"], cwd=dir_path, check=True)
28+
subprocess.run(["moon", "check", "--target",
29+
targets], cwd=dir_path, check=True)
30+
subprocess.run(["moon", "test", "--target", targets],
31+
cwd=dir_path, check=True)
32+
print(f"✓ {dir_path.name}")
33+
except subprocess.CalledProcessError:
34+
print(f"✗ {dir_path.name}")
35+
failed.append(dir_path.name)
4836

4937
# Report results
5038
if failed:
51-
print("\nFailed directories:")
52-
for d in failed:
53-
print(d)
54-
return 1
55-
56-
# Show file sizes
57-
target = Path("target")
58-
if target.exists():
59-
for pattern in ["*.wasm", "*.js"]:
60-
files = list(target.rglob(pattern))
61-
if files:
62-
print(f"\n{pattern.upper()} files:")
63-
for f in files:
64-
print(f"{f} ({f.stat().st_size} bytes)")
65-
66-
print("\nAll checks passed!")
67-
return 0
39+
print(f"\nFailed: {', '.join(failed)}")
40+
sys.exit(1)
41+
else:
42+
print("\nAll examples passed!")
6843

6944

7045
if __name__ == "__main__":
71-
sys.exit(main())
46+
main()

scripts/check-legacy-examples.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
import subprocess
3+
import sys
4+
from pathlib import Path
5+
6+
7+
def main():
8+
root = Path(__file__).parent.parent
9+
examples_dir = root / "legacy" / "examples"
10+
11+
failed = []
12+
for example in sorted(examples_dir.iterdir()):
13+
if not example.is_dir() or example.name.startswith('.') or example.name == "target":
14+
continue
15+
16+
# Skip wasi-http for non-wasm backends
17+
targets = "all"
18+
if example.name == "wasi-http":
19+
targets = "wasm"
20+
21+
print(f"Processing {example.name}")
22+
try:
23+
subprocess.run(["moon", "install"], cwd=example, check=True)
24+
subprocess.run(["moon", "check", "--target",
25+
targets], cwd=example, check=True)
26+
subprocess.run(["moon", "test", "--target", targets],
27+
cwd=example, check=True)
28+
print(f"✓ {example.name}")
29+
except subprocess.CalledProcessError:
30+
print(f"✗ {example.name}")
31+
failed.append(example.name)
32+
33+
if failed:
34+
print(f"\nFailed: {', '.join(failed)}")
35+
sys.exit(1)
36+
else:
37+
print("\nAll examples passed!")
38+
39+
40+
if __name__ == "__main__":
41+
main()

0 commit comments

Comments
 (0)