name: Rust

on:
  push:
  pull_request:
    branches: ["master"]

env:
  CARGO_TERM_COLOR: always

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Install rustfmt for nightly
        run: rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt clippy
      - name: Add AArch64 Target
        run: rustup target add aarch64-unknown-none
      - name: Run format check
        run: cargo fmt --check
      - name: Run lint
        run: cargo clippy -- -D warnings

  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Install rustfmt for nightly
        run: rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt clippy
      - name: Add AArch64 Target
        run: rustup target add aarch64-unknown-none
      - name: Build
        run: cargo build --verbose
