name: Integration Test

on:
  workflow_dispatch:
  push:
    branches:
      - main
      - "release/**"
    paths:
      - "**.go"
      - "**/go.mod"
      - "**/go.sum"
      - ".github/workflows/test-integration.yml"
  pull_request:
    paths:
      - "**.go"
      - "**/go.mod"
      - "**/go.sum"
      - ".github/workflows/test-integration.yml"

jobs:
  integration-test:
    runs-on: ubuntu-22.04
    env:
      CTEST_OUTPUT_ON_FAILURE: True
    steps:
      - name: Checkout
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
        with:
          ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}

      - name: Setup bazel
        uses: ./.github/actions/setup_bazel_nix
        with:
          useCache: "true"
          buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}

      - name: Integration Tests
        env:
          TMPDIR: ${{ runner.temp }}
        run: sudo -E "PATH=$PATH" bazel test //... --config=nostamp --remote_download_minimal --config=integration  --spawn_strategy=standalone
