name: build

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build-rust:
    strategy:
      matrix:
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Setup DynamoDB Local
        uses: rrainn/dynamodb-action@v2.0.1
        with:
          port: 8000
          cors: '*'
      - name: Install Rust
        run: rustup toolchain install stable --component llvm-tools-preview
      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov
      - name: install nextest
        uses: taiki-e/install-action@nextest
      - uses: Swatinem/rust-cache@v1
      - name: Check code format
        run: cargo fmt -- --check
      - name: Check the package for errors
        run: cargo check --all
      - name: Lint rust sources
        run: cargo clippy --all-targets --all-features --tests --benches -- -D warnings
      - name: Execute rust tests
        run: cargo nextest run --all-targets --all-features
        env:
          AWS_DEFAULT_REGION: us-west-2
          AWS_REGION: us-west-2
          AWS_ACCESS_KEY_ID: dummy-key
          AWS_SECRET_ACCESS_KEY: dummy-secret
