yewprint/.github/workflows/rust.yml
2020-10-04 13:50:30 +02:00

93 lines
2.5 KiB
YAML

name: Rust
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: 0 0 1 * *
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
outputs:
size: ${{ steps.build.outputs.size }}
steps:
- uses: actions/checkout@v2
- name: Install wasm-pack
run: |
curl -sSL https://github.com/rustwasm/wasm-pack/releases/download/v0.9.1/wasm-pack-v0.9.1-x86_64-unknown-linux-musl.tar.gz \
| tar xzO wasm-pack-v0.9.1-x86_64-unknown-linux-musl/wasm-pack \
> $HOME/.cargo/bin/wasm-pack
chmod +x $HOME/.cargo/bin/wasm-pack
- run: cargo test --all-features --verbose
- run: cargo doc --verbose --all-features
- name: Build (Release)
id: build
run: "./build.sh --release && echo ::set-output name=size::`cat public/wasm_bg.wasm | wc -c`"
build-main:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
outputs:
size: ${{ steps.build.outputs.size }}
steps:
- uses: actions/checkout@v2
with:
ref: main
- name: Install wasm-pack
run: |
curl -sSL https://github.com/rustwasm/wasm-pack/releases/download/v0.9.1/wasm-pack-v0.9.1-x86_64-unknown-linux-musl.tar.gz \
| tar xzO wasm-pack-v0.9.1-x86_64-unknown-linux-musl/wasm-pack \
> $HOME/.cargo/bin/wasm-pack
chmod +x $HOME/.cargo/bin/wasm-pack
- name: Build (Release)
id: build
run: "./build.sh --release && echo ::set-output name=size::`cat public/wasm_bg.wasm | wc -c`"
checks:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v2
- run: rustup install --profile default nightly
# NOTE: we use nightly here to enable the options error_on_line_overflow and
# error_on_unformatted
- run: cargo +nightly fmt -- --check
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features -- -D warnings
report-wasm-size:
runs-on: ubuntu-latest
needs:
- build
- build-main
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
**Compiled size report**
| File name | Old Size | New Size |
| --- | --- | --- |
| public/wasm_bg.wasm | ${{needs.build-main.outputs.size}} | ${{needs.build.outputs.size}} |