-
-
Notifications
You must be signed in to change notification settings - Fork 3
253 lines (206 loc) · 6.64 KB
/
main.yml
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
name: Main
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTUP_MAX_RETRIES: 10
jobs:
# run all cargo tests in workspace
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Restore Cache
uses: Swatinem/rust-cache@v2
- name: Run Codegen
run: cargo xtask codegen
- name: Run Tests
run: cargo test --workspace --all-features
# build syntastica-js
build-js:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare CI
run: |
bash _prepare_ci.sh
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-emscripten
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 18
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v11
with:
actions-cache-folder: 'emsdk-cache'
- name: Restore Cache
uses: Swatinem/rust-cache@v2
- name: Run Codegen
run: cargo xtask codegen
- name: Prepare CI
run: |
bash _prepare_ci.sh
- name: Build
run: |
cd syntastica-js
npm ci
npm run build
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: syntastica-js
path: syntastica-js/pkg
retention-days: 5
# run and commit auto-generated code
codegen:
runs-on: ubuntu-latest
if: github.repository == 'RubixDev/syntastica'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare CI
run: |
bash _prepare_ci.sh
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Jetbrains Mono
run: sudo apt update && sudo apt install -y fonts-jetbrains-mono
- name: Install Typst
uses: yusancky/setup-typst@v2
with:
version: 'v0.8.0'
- name: Restore Cache
uses: Swatinem/rust-cache@v2
- name: Create SVGs
run: cargo xtask codegen queries && cargo xtask theme-svgs
- name: Generate Code
run: cargo xtask codegen
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
add:
syntastica-queries/src/lib.rs syntastica-parsers/Cargo.toml
syntastica-parsers-gitdep/Cargo.toml syntastica-parsers*/README.md
syntastica-js/src/index.ts syntastica-themes/assets/theme-svgs
syntastica-themes/theme_list.md
committer_name: github-actions[bot]
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
message: 'chore: run codegen'
- name: Upload Queries as Artifact
uses: actions/upload-artifact@v3
with:
name: queries
path: syntastica-queries/generated_queries
retention-days: 10
- name: Upload Theme List as Artifact
uses: actions/upload-artifact@v3
with:
name: theme-list-md
path: syntastica-themes/theme_list.md
retention-days: 1
# build the gh-pages site
pages:
needs: [build-js, tests, codegen]
if: github.repository == 'RubixDev/syntastica'
continue-on-error: true
runs-on: ubuntu-latest
env:
RUSTFLAGS: '--deny warnings'
DOCS_RS: true
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download syntastica-js build
uses: actions/download-artifact@v3
with:
name: syntastica-js
path: syntastica-js/pkg
- name: Download theme_list.md
uses: actions/download-artifact@v3
with:
name: theme-list-md
path: syntastica-themes/
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dioxus CLI
uses: taiki-e/install-action@v2
with:
tool: dioxus-cli
- name: Install wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- name: Restore Cache
uses: Swatinem/rust-cache@v2
with:
cache-targets: false
cache-on-failure: true
- name: Run Codegen
run: cargo xtask codegen
- name: Build Rust Documentation
run: cargo doc --workspace --all-features --no-deps
- name: Build TypeScript Documentation
run: |
cd syntastica-js
npm ci
npm run doc
- name: Build Vite Demo
run: |
cd examples/wasm/vite
# set base directory to `/syntastica/demos/vite/`
sed -i 's#defineConfig({#\0base:"/syntastica/demos/vite/",#g' vite.config.ts
npm ci
npm run build
- name: Build Dioxus Demo
run: |
cd examples/wasm/dioxus
# set base directory to `/syntastica/demos/dioxus/`
sed -i -E 's#(\[web.app\])#\1\nbase_path = "syntastica/demos/dioxus"#g' Dioxus.toml
dx build --release
- name: Build wasm-pack + NPM Demo
run: |
cd examples/wasm/wasm-pack-with-npm-pkg
# set base directory to `/syntastica/demos/wasm-pack-npm/`
sed -i 's#defineConfig({#\0base:"/syntastica/demos/wasm-pack-npm/",#g' vite.config.ts
wasm-pack build --target web .
npm ci
npm run build
- name: Prepare GitHub Pages Deployment
run: |
# redirect to `syntastica` Rust docs from main page
echo '<meta http-equiv="Refresh" content="0; url=syntastica" />' >> target/doc/index.html
# copy over the TypeScript docs
cp -r syntastica-js/docs target/doc/js
# create the `demos` folder
mkdir -p target/doc/demos
# copy over the vite demo
cp -r examples/wasm/vite/dist target/doc/demos/vite
# copy over the dioxus demo
cp -r examples/wasm/dioxus/dist target/doc/demos/dioxus
# copy over the wasm-pack-npm demo
cp -r examples/wasm/wasm-pack-with-npm-pkg/dist target/doc/demos/wasm-pack-npm
- name: Deploy Docs
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./target/doc