Update all npm dependencies #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |