# Workflow patches for skipping Google Cloud unit test CI on PRs from external repositories.
name: Integration Tests on GCP

# Run on PRs from external repositories, let them pass, and then Mergify will check them.
# GitHub doesn't support filtering workflows by source branch names, so we have to do it for each
# job.
on:
  pull_request:

# IMPORTANT
#
# The job names in `ci-integration-tests-gcp.yml`, `ci-integration-tests-gcp.patch.yml` and
# `ci-integration-tests-gcp.patch-external.yml` must be kept in sync.
jobs:
  # We don't patch the testnet job, because testnet isn't required to merge (it's too unstable)
  get-available-disks:
    name: Check if cached state disks exist for Mainnet / Check if cached state disks exist
    # Only run on PRs from external repositories.
    if: ${{ startsWith(github.event_name, 'pull') && github.event.pull_request.head.repo.fork }}
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  build:
    name: Build CI Docker / Build images
    # This dependency allows all these jobs to depend on a single condition, making it easier to
    # change.
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  test-stateful-sync:
    name: Zebra checkpoint update / Run sync-past-checkpoint test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  test-update-sync:
    name: Zebra tip update / Run update-to-tip test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  checkpoints-mainnet:
    name: Generate checkpoints mainnet / Run checkpoints-mainnet test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  lightwalletd-rpc-test:
    name: Zebra tip JSON-RPC / Run fully-synced-rpc test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  lightwalletd-transactions-test:
    name: lightwalletd tip send / Run lwd-send-transactions test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  get-block-template-test:
    name: get block template / Run get-block-template test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  submit-block-test:
    name: submit block / Run submit-block test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  scan-start-where-left-test:
    name: Scan starts where left / Run scan-start-where-left test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "No build required"'

  lightwalletd-full-sync:
    name: lightwalletd tip / Run lwd-full-sync test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  lightwalletd-update-sync:
    name: lightwalletd tip update / Run lwd-update-sync test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'

  lightwalletd-grpc-test:
    name: lightwalletd GRPC tests / Run lwd-grpc-wallet test
    needs: get-available-disks
    runs-on: ubuntu-latest
    steps:
      - run: 'echo "Skipping job on fork"'
