name: "Test Boltzmann CLI & framework"
on:
  push:
    branches:
      - latest
  pull_request:
jobs:
  build_and_test:
    env:
      DEBUG: 1
    name: ${{ matrix.os }} / Node ${{ matrix.node_version }} test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        # eventually: add node 14 + lts
        node_version: ["12.x"]
      fail-fast: false
    steps:
      - uses: actions/checkout@v2

      - name: Use Node.js 12.x
        uses: actions/setup-node@v2.1.2
        with:
          node-version: ${{ matrix.node_version }}

      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - uses: actions/cache@v2
        if: runner.os != 'macOS'
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - uses: Swatinem/rust-cache@v1
        if: runner.os == 'macOS'

      - uses: actions-rs/cargo@v1
        timeout-minutes: 10
        with:
          command: build

      - name: run cargo build --release for caching
        run: |
          cargo build --release

      - name: run selftest tests
        shell: bash
        run: |
          bin/test selftest

      - name: run startup tests
        shell: bash
        run: |
          bin/test startup

      - name: run examples tests
        shell: bash
        run: |
          bin/test examples
