name: Cargo Build & Test

on:
  push:
  pull_request:

env: 
  CARGO_TERM_COLOR: always

jobs:
  build_and_test:
    name: Rust project - latest
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain:
          - stable
          - beta
          - nightly
    steps:
      - uses: actions/checkout@v4
      - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
      - name: Install meson
        run: |
          sudo apt-get update
          sudo apt-get install -y meson git
      - name: Pull Wycheproof-RS
        run: git clone https://github.com/randombit/wycheproof-rs
      - name: Meson setup
        run: meson setup build -Dtests=disabled -Dslh_dsa_ascon_128s=enabled -Dslh_dsa_ascon_128f=enabled -Dsbsigntools=disabled
      - name: Meson compile
        run: meson compile -C build
      - name: Meson install
        run: |
          sudo meson install -C build
          sudo ldconfig
      - run: cd rust && cargo build --verbose
      - run: cd rust && cargo test --verbose
