name: Integration tests

on:
  push:
    branches:
      - 'main'
  pull_request:
    branches:
      - 'main'

permissions: {}

jobs:
  tests:
    runs-on: ubuntu-latest

    permissions:
      contents: read

    env:
      IMAGE_REPO: 'localhost:5000'
      REGISTRY: 'localhost:5000'
      DOCKER_BUILDKIT: '0'
      DOCKER_API_VERSION: '1.44'

    strategy:
      fail-fast: false
      matrix:
        make-target:
        - integration-test-layers
        - integration-test-misc
        - integration-test-run
        - k8s-executor-build-push integration-test-k8s

    steps:
      - name: Harden Runner
        uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
        with:
          egress-policy: audit

      - name: Maximize build space
        uses: AdityaGarg8/remove-unwanted-software@90e01b21170618765a73370fcc3abbd1684a7793 # v5
        with:
          remove-android: 'true'
          remove-dotnet: 'true'
          remove-haskell: 'true'

      - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
        with:
          go-version: '1.25'
          check-latest: true

      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
        with:
          driver: docker-container
          driver-opts: network=host # Allows buildx to access the local registry.

      - run: make install-container-diff k3s-setup
      - run: make ${{ matrix.make-target }}
