name: "Lazer Rust Test Suite"
on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - .github/workflows/ci-lazer-rust.yml
      - lazer/**

jobs:
  lazer-rust-test-suite:
    name: Lazer Rust Test Suite
    runs-on: ubuntu-22.04
    defaults:
      run:
        working-directory: lazer
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Install Protoc
        uses: arduino/setup-protoc@v3
        with:
          version: "30.2"
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Install Foundry
        uses: foundry-rs/foundry-toolchain@v1
      - name: install taplo
        run: cargo install --locked taplo-cli@0.9.3
      - name: Install Solana Cli
        run: |
          sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
          echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH"
      - name: check Cargo.toml formatting
        run: find . -name Cargo.toml -exec taplo fmt --check --diff {} \;
      - name: Format check
        run: cargo fmt --all -- --check
        if: success() || failure()
      - name: Clippy check
        run: cargo clippy -p pyth-lazer-protocol -p pyth-lazer-client -p pyth-lazer-publisher-sdk --all-targets -- --deny warnings
        if: success() || failure()
      - name: Clippy check with mry
        run: cargo clippy -F mry -p pyth-lazer-protocol --all-targets -- --deny warnings
        if: success() || failure()
      - name: test
        run: cargo test -p pyth-lazer-protocol -p pyth-lazer-client -p pyth-lazer-publisher-sdk
        if: success() || failure()
      - name: test with mry
        run: cargo test -F mry -p pyth-lazer-protocol
        if: success() || failure()
