name: "Tests"

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    steps:
      - name: Check out
        uses: actions/checkout@v7

      - name: Setup Go
        uses: actions/setup-go@v7
        with:
          go-version: "1.26"

      - name: Setup uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true

      - name: Install Python dependencies
        # Precompile bytecode (as pip did by default) so the Python test
        # helpers start fast enough for the Go tests' server-startup wait.
        run: uv sync
        env:
          UV_COMPILE_BYTECODE: "1"

      - name: Activate Python environment
        # The Go tests spawn the Python helpers via bare `python`, so put the
        # uv-managed virtualenv on PATH for the steps that follow.
        run: |
          echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
          echo "VIRTUAL_ENV=$PWD/.venv" >> "$GITHUB_ENV"

      - name: Install gofumpt
        run: go install mvdan.cc/gofumpt@latest

      - name: Check format
        run: python hyperbole.py format-check

      - name: Test core
        working-directory: core
        run: go test -v -count=1 -skip 'Stress' ./...

      - name: Test extras
        working-directory: extras
        run: go test -v -count=1 ./...

      - name: Test app
        working-directory: app
        run: go test -v -count=1 ./...
