name: Build and Test

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build-test:
    # https://github.com/42ByteLabs/.github/blob/main/.github/workflows/cargo.yml
    uses: 42ByteLabs/.github/.github/workflows/cargo.yml@main
    permissions:
      contents: read
      actions: read
      security-events: write
    secrets: inherit

  test-template:
    runs-on: ubuntu-latest
    needs: [ build-test ]
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v6
      - name: Test template
        run: |
          cargo install cargo-generate
          cd ./action-template

          cargo generate --vcs none --test
