Files
LiveSplitOne/.github/workflows/ci.yml
T

130 lines
3.4 KiB
YAML

name: CI
on:
pull_request:
push:
branches:
- 'master'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set CURRENT_TWO_WEEKS for use in cache keys
run: echo "::set-env name=CURRENT_TWO_WEEKS::$(($(date +%-V) / 2))"
- name: Cache Cargo
uses: actions/cache@v1
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ env.CURRENT_TWO_WEEKS }}
- name: Cache binaryen
if: github.repository == 'LiveSplit/LiveSplitOne' && github.ref == 'refs/heads/master'
uses: actions/cache@v1
with:
path: ~/binaryen
key: ${{ runner.os }}-binaryen-${{ env.CURRENT_TWO_WEEKS }}
- name: Cache target
uses: actions/cache@v1
with:
path: livesplit-core/target
key: ${{ runner.os }}-target-${{ env.CURRENT_TWO_WEEKS }}
- name: Install Node
uses: actions/setup-node@v1
with:
node-version: '12.x' # FIXME: https://github.com/actions/setup-node/issues/26
- name: Install Rust
uses: hecrj/setup-rust-action@v1
- name: Install target
run: rustup target add wasm32-unknown-unknown
- name: Install optimizers
if: github.repository == 'LiveSplit/LiveSplitOne' && github.ref == 'refs/heads/master'
run: |
set -e
cd $HOME
git -C binaryen pull || git clone https://github.com/WebAssembly/binaryen binaryen
cd binaryen
cmake .
make wasm-opt
# FIXME: Use actions-rs/[email protected] again once it can handle wasm-bindgen
- name: Install wasm-bindgen
run: |
set -e
cargo install wasm-bindgen-cli
- name: Install npm packages
run: |
set -e
npm install
env:
DETECT_CHROMEDRIVER_VERSION: true
- name: Build Core
run: |
set -e
npm run build:core
- name: Set up tslint matcher
run: echo "::add-matcher::.github/workflows/tslint.json"
- name: Run tslint
run: npm run lint
- name: Build Frontend
run: |
set -e
npm run publish
- name: Cache screenshots
uses: actions/cache@v1
with:
path: test/screenshots
key: ${{ runner.os }}-screenshots-${{ hashFiles('test/rendering-test.js') }}
restore-keys: ${{ runner.os }}-screenshots-
- name: Run tests
run: |
echo "::add-matcher::.github/workflows/test-failures.json"
npm run test
- name: Upload screenshots
if: success() || failure()
uses: actions/upload-artifact@v1
with:
name: Screenshots
path: test/screenshots
- name: Optimize
if: github.repository == 'LiveSplit/LiveSplitOne' && github.ref == 'refs/heads/master'
run: |
set -e
WASM_FILE=$(ls dist/*.wasm)
~/binaryen/bin/wasm-opt -O4 "$WASM_FILE" -o "$WASM_FILE"
- name: Add CNAME file
if: github.repository == 'LiveSplit/LiveSplitOne' && github.ref == 'refs/heads/master'
run: |
cp ./.github/workflows/CNAME ./dist/CNAME
- name: Deploy
if: github.repository == 'LiveSplit/LiveSplitOne' && github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_branch: gh-pages
publish_dir: ./dist
force_orphan: true