-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (82 loc) · 2.71 KB
/
rust.yaml
File metadata and controls
97 lines (82 loc) · 2.71 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
on: push
name: Build and test
jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Clippy
run: cargo clippy --all-features -- -D warnings
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Format
run: cargo fmt --all -- --check
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build
run: cargo build --all-features
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Test
run: cargo test --all-features
ai_website:
runs-on: ubuntu-latest
needs: [clippy, format, build, test]
defaults:
run:
working-directory: wordle_ai_web
steps:
- uses: actions/checkout@v6
# -----------------------------
# Install wasm target + Trunk
# -----------------------------
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install Trunk
run: cargo binstall trunk
# -----------------------------
# Install latest wasm-opt
# -----------------------------
- name: Install wasm-opt
run: |
WASM_OPT_VERSION=version_124
curl -L -o binaryen.tar.gz \
"https://github.com/WebAssembly/binaryen/releases/download/${WASM_OPT_VERSION}/binaryen-${WASM_OPT_VERSION}-x86_64-linux.tar.gz"
tar -xzf binaryen.tar.gz
mv binaryen-${WASM_OPT_VERSION}/bin/wasm-opt ./wasm-opt
chmod +x ./wasm-opt
echo "$(pwd)" >> $GITHUB_PATH
# -----------------------------
# Build website
# -----------------------------
- name: Clean project
run: |
trunk clean
cargo clean
- name: Build website
run: trunk build --release --no-sri --verbose
# -----------------------------
# Optimize WASM files
# -----------------------------
- name: Optimize WASM
run: |
find dist/ -name "*.wasm" | while read wasm; do
./wasm-opt -Oz -o "$wasm" "$wasm"
done
# -----------------------------
# Deploy to Cloudflare Pages
# -----------------------------
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy wordle_ai_web/dist --project-name=wordle-ai-web