name: Main Workflow
on:
  push:
  schedule:
    - cron: "0 0 * * 0"
jobs:
  build:
    name: Build
    timeout-minutes: 10
    strategy:
      matrix:
        rust-version: [
          "1.56.1",
          "1.60.0",
          "1.62.0",
          "1.63.0",
          "1.64.0",
          "1.65.0",
          "latest"
        ]
    runs-on: ubuntu-latest
    container: rust:${{ matrix.rust-version }}
    steps:
      - uses: actions/checkout@v1
      - run: |
          rustup component add rustfmt
          rustup component add clippy
        name: Install Rust components
      - run: rustc --version
        name: Print Rust information
      - run: cargo fmt --all -- --check
        name: Verify Rust code format
      - run: cargo clippy -- -D warnings -A unknown-lints
        name: Verify Rust code linting
      - run: cargo build
        name: Build development version
      - run: cargo build --release
        name: Build release version
  build-wasm:
    name: Build WASM
    timeout-minutes: 30
    strategy:
      matrix:
        rust-version: [
          "1.56.1",
          "1.60.0",
          "1.62.0",
          "1.63.0",
          "1.64.0",
          "1.65.0",
          "latest"
        ]
        node-version: ["16"]
    runs-on: ubuntu-latest
    container: rust:${{ matrix.rust-version }}
    steps:
      - uses: actions/checkout@v1
      - run: |
          rustup component add rustfmt
          rustup component add clippy
        name: Install Rust components
      - run: rustc --version
        name: Print Rust information
      - run: cargo fmt --all -- --check
        name: Verify Rust code format
      - run: cargo clippy -- -D warnings -A unknown-lints
        name: Verify Rust code linting
      - run: cargo install wasm-pack
        name: Install wasm-pack
      - run: wasm-pack build --release --target=web --out-dir=frontends/web/lib -- --features wasm
        name: Build WASM Web binary
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
        name: Install Node.js
      - run: cd frontends/web && npm install && npm run build && npm run lint
        name: Build and lint Web code
