name: PR build fake backend images for smoke tests

on:
  pull_request:
    paths:
      - "smoke-tests/images/fake-backend/**"
      - ".github/workflows/pr-smoke-test-fake-backend-images.yml"

permissions:
  contents: read

jobs:
  buildLinux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

      - name: Free disk space
        run: .github/scripts/gha-free-disk-space.sh

      - name: Set up JDK for running Gradle
        uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
        with:
          distribution: temurin
          java-version: 21

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
        with:
          cache-read-only: true
          # gradle enterprise is used for the build cache
          gradle-home-cache-excludes: caches/build-cache-1

      - name: Build Docker image
        run: ./gradlew :smoke-tests:images:fake-backend:jibDockerBuild -Djib.httpTimeout=120000 -Djib.console=plain

  buildWindows:
    runs-on: windows-latest
    defaults:
      run:
        shell: bash
    steps:
      - name: Support long paths
        run: git config --system core.longpaths true

      - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

      - name: Set up JDK for running Gradle
        uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
        with:
          distribution: temurin
          java-version: 21

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
        with:
          cache-read-only: true

      - name: Build Docker image
        run: ./gradlew :smoke-tests:images:fake-backend:windowsBackendImageBuild
