-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (91 loc) · 2.97 KB
/
cd.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
name: Test and Deploy
on:
push:
branches:
- master
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
test-and-deploy:
name: Test, build, and deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest stable Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Lint with rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Install node.js
uses: actions/setup-node@v2
- name: Get tools versions
id: versions
run: |
echo "::set-output name=rustc::`rustc --version | awk '{print $2}'`"
echo "::set-output name=node::`node --version`"
- name: Cache backend (cargo) dependencies
uses: actions/cache@v2
with:
path: |
target
.cargo_home
key: ${{ runner.os }}-rustc-${{ steps.versions.outputs.rustc }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rustc-${{ steps.versions.outputs.rustc }}-
${{ runner.os }}-rustc-
- name: Lint with clippy
uses: actions-rs/cargo@v1
env:
RUSTFLAGS: "-D warnings"
with:
command: clippy
args: --all-targets --all-features
- name: Run backend tests
uses: actions-rs/[email protected]
env:
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable
- name: Install wasm-pack
uses: jetli/[email protected]
- name: Build backend
run: cd wasm && CARGO_HOME=../.cargo_home wasm-pack build
- name: Audit npm dependencies (with --audit-level=high)
run: cd wasm/www && npm audit --audit-level=high
- name: Cache frontend (npm) dependencies
uses: actions/cache@v2
with:
path: wasm/www/node_modules
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node }}-${{ hashFiles('wasm/www/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.versions.outputs.node }}-
${{ runner.os }}-node-
- name: Install frontend (npm) dependencies
run: cd wasm/www && npm install
- name: Get frontend assets from current staging branch
uses: actions/checkout@v2
with:
ref: gh-pages-staging
path: wasm/www/assets.tmp
- name: Move over assets
run: |
cd wasm/www
mv assets.tmp/*.dwe assets/*.dwe
mv assets.tmp/*.bin assets/*.bin
rm -rf assets.tmp
- name: Build frontend
run: cd wasm/www && npm run build
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./wasm/www/dist
commit_message: Deploy