-
Notifications
You must be signed in to change notification settings - Fork 1
150 lines (131 loc) · 4.67 KB
/
Copy pathwasm.yml
File metadata and controls
150 lines (131 loc) · 4.67 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
name: Build Playground WASM
on:
push:
branches:
- master
- main
paths:
- '.github/workflows/wasm.yml'
- '.github/workflows/wasm-semantic.yml'
- 'projects/vb6parse/**'
- 'projects/vb6semantic/**'
- 'projects/vb6interpret/**'
workflow_dispatch:
permissions:
contents: write
jobs:
detect:
runs-on: ubuntu-latest
outputs:
parse: ${{ steps.filter.outputs.parse }}
semantic: ${{ steps.filter.outputs.semantic }}
interpret: ${{ steps.filter.outputs.interpret }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Detect WASM targets
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
parse:
- '.github/workflows/wasm.yml'
- '.github/workflows/wasm-semantic.yml'
- 'projects/vb6parse/**'
- '!projects/vb6parse/tests/**'
- '!projects/vb6parse/benches/**'
- '!projects/vb6parse/examples/**'
- '!projects/vb6parse/README.md'
- '!projects/vb6parse/CHANGELOG.md'
- '!projects/vb6parse/CONTRIBUTING.md'
- '!projects/vb6parse/docs/**'
semantic:
- '.github/workflows/wasm.yml'
- '.github/workflows/wasm-semantic.yml'
- 'projects/vb6semantic/**'
- '!projects/vb6semantic/README.md'
- '!projects/vb6semantic/LICENSE'
- '!projects/vb6semantic/docs/**'
interpret:
- '.github/workflows/wasm.yml'
- '.github/workflows/wasm-semantic.yml'
- 'projects/vb6interpret/**'
- '!projects/vb6interpret/README.md'
- '!projects/vb6interpret/docs/**'
wasm:
needs: detect
if: needs.detect.outputs.parse == 'true' || needs.detect.outputs.semantic == 'true' || needs.detect.outputs.interpret == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Install wasm-opt
run: cargo install wasm-opt
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Show build tool versions
run: |
rustc --version
cargo --version
wasm-pack --version
wasm-opt --version
python3 --version
- name: Build changed WASM modules
env:
BUILD_PARSE: ${{ needs.detect.outputs.parse }}
BUILD_SEMANTIC: ${{ needs.detect.outputs.semantic }}
BUILD_INTERPRET: ${{ needs.detect.outputs.interpret }}
run: |
set -euo pipefail
if [[ "$BUILD_PARSE" == "true" ]]; then
echo "Building vb6parse WASM"
pushd projects/vb6parse > /dev/null
python3 scripts/build-wasm.py --optimize --no-typescript
popd > /dev/null
fi
if [[ "$BUILD_SEMANTIC" == "true" ]]; then
echo "Building vb6semantic WASM"
pushd projects/vb6semantic > /dev/null
python3 scripts/build-wasm.py --optimize --no-typescript
popd > /dev/null
fi
if [[ "$BUILD_INTERPRET" == "true" ]]; then
echo "Building vb6interpret WASM"
pushd projects/vb6interpret > /dev/null
python3 scripts/build-wasm.py --optimize --no-typescript
popd > /dev/null
fi
- name: Commit and push if changed
env:
BUILD_PARSE: ${{ needs.detect.outputs.parse }}
BUILD_SEMANTIC: ${{ needs.detect.outputs.semantic }}
BUILD_INTERPRET: ${{ needs.detect.outputs.interpret }}
run: |
set -euo pipefail
git pull --rebase --autostash
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if [[ "$BUILD_PARSE" == "true" ]]; then
git add -f docs/vb6parse/assets/wasm/
fi
if [[ "$BUILD_SEMANTIC" == "true" ]]; then
git add -f docs/vb6semantic/assets/wasm/
fi
if [[ "$BUILD_INTERPRET" == "true" ]]; then
git add -f docs/vb6interpret/assets/wasm/
fi
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update playground WASM assets"
git push
fi