trunk 0.11.0

Build, bundle & ship your Rust WASM application to the web.
name: CI
on:
  push:
    paths-ignore:
      - "**.md"
  pull_request:
    paths-ignore:
      - "**.md"

jobs:
  lint:
    name: lint
    runs-on: ubuntu-latest
    steps:
      - name: Setup | Checkout
        uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-lint-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-lint-

      - name: Setup | Toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          default: true
          components: clippy, rustfmt

      - name: Build | Clippy
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-targets -- -D warnings

      - name: Build | Rustfmt
        run: cargo fmt -- --check

  check:
    runs-on: ubuntu-latest
    steps:
      - name: Setup | Checkout
        uses: actions/checkout@v2

      - name: Setup | Cache Cargo
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-check-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-check-

      - name: Setup | Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal

      - name: Build | Check
        run: cargo check --all

  test:
    needs: check # Ensure check is run first.
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        include:
          - os: ubuntu-latest
            binPath: target/debug/trunk
          - os: macos-latest
            binPath: target/debug/trunk
          - os: windows-latest
            binPath: target/debug/trunk.exe
    runs-on: ${{ matrix.os }}
    steps:
      - name: Setup | Checkout
        uses: actions/checkout@v2

      - name: Setup | Cache Cargo
        # WHY? Because we are getting: error[E0463]: can't find crate for `structopt_derive` which `structopt` depends on
        # only on macos when using the cache.
        if: matrix.os != 'macos-latest'
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Setup | Cache Examples
        uses: actions/cache@v2
        with:
          path: examples/yew/target
          key: wasm32-example-yew-debug-${{ hashFiles('examples/yew/Cargo.lock') }}
          restore-keys: |
            wasm32-example-yew-debug-

      - name: Setup | Cache Examples
        uses: actions/cache@v2
        with:
          path: examples/seed/target
          key: wasm32-example-seed-debug-${{ hashFiles('examples/seed/Cargo.lock') }}
          restore-keys: |
            wasm32-example-seed-debug-

      - name: Setup | Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          target: wasm32-unknown-unknown

      - name: Build | Test
        run: cargo test

      # Run the CLI to ensure we don't have any subtle runtime issues.
      - name: Build | Run
        run: cargo run -- -h

      # Build examples via our newly built debug artifact.
      - name: Setup | wasm-bindgen
        run: cargo install wasm-bindgen-cli --version 0.2.70
      - name: Build | Examples
        run: ${{ matrix.binPath }} --config=examples/yew/Trunk.toml build
      - name: Build | Examples
        run: ${{ matrix.binPath }} --config=examples/seed/Trunk.toml build