name: Project

on:
  workflow_dispatch:
  push:
    branches: [main, stable-*]
  pull_request:
    types: [opened, reopened, synchronize, edited]
    branches: [main, stable-*]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.x"

      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-project-pre-commit-pip-${{ hashFiles('.pre-commit-config.yaml') }}
          restore-keys: |
            ${{ runner.os }}-project-pre-commit-pip

      - uses: pre-commit/action@v3.0.1

  test-tools:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.x"
      - run: make all
        working-directory: tools
