name: Pre Code Review Checks

on:
  pull_request:
    branches:
      - master

jobs:
  pre-code-review-checks:
    runs-on: ubuntu-18.04
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v2
      - name: Install latest nightly
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly-2020-07-08
          components: rustfmt, clippy
          target: i686-unknown-linux-gnu
          # This overwrites the default toolchain with the toolchain specified above.
          override: true

      # Setup Environments
      - name: Setup Environments
        run: ./.github/scripts/ci-setup.sh

      # Build
      - name: Build
        run: ./.github/scripts/ci-build.sh

      # Test
      - name: Test
        run: |
          sudo apt-get update
          sudo apt-get install libc6-dev-i386
          export RUSTUP_TOOLCHAIN=nightly-2020-07-08
          ./.github/scripts/ci-test.sh

      # Style checks
      - name: Style checks
        run: ./.github/scripts/ci-style.sh

      # Document check
      - name: Rustdoc
        run: ./.github/scripts/ci-doc.sh
