name: Bazel Test

on:
  push:
    branches: [ "main" ]
    paths:
      - 'src/**'
      - 'WORKSPACE'
      - 'MODULE.bazel'
      - 'BUILD.bazel'
      - '.github/workflows/bazel_test.yml'
      - '!src/main/csharp/**'
      - '!src/test/csharp/**'
  pull_request:
    paths:
      - 'src/**'
      - 'WORKSPACE'
      - 'MODULE.bazel'
      - 'BUILD.bazel'
      - '.github/workflows/bazel_test.yml'
      - '!src/main/csharp/**'
      - '!src/test/csharp/**'

permissions:
  contents: read

jobs:
  test:
    runs-on: self-hosted

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        lfs: false
    - name: Run tests
      run: bazel test --build_event_json_file=test.json //src/test/... //src/main/go/...
    - name: Archive test results
      if: success() || failure()
      uses: actions/upload-artifact@v4
      with:
        name: test.json
        path: test.json
