name: Test Pinepods
on:
  # pull_request:
  #   types:
  #     - opened
  #     - synchronize
  #   branches: [ master ]
    workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Build the Docker test container
      run: docker build -t madeofpendletonwool/pinepods-test . -f dockerfile-test
    - uses: rustsec/audit-check@v1.4.1
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
    - name: Run tests in the Docker container
      run: docker run madeofpendletonwool/pinepods-test

  cache-checkmate:
    runs-on: ubuntu-latest
    steps:
    - uses: taiki-e/cache-cargo-install-action@v1
      with:
        tool: cargo-checkmate

  run-phase:
    strategy:
      matrix:
        phase: [audit, build, check, clippy, doc, test]
    needs: cache-checkmate
    runs-on: ubuntu-latest
    steps:
    - uses: taiki-e/cache-cargo-install-action@v1
      with:
        tool: cargo-checkmate
    - uses: actions/checkout@v4
    - run: cargo-checkmate run ${{ matrix.phase }}