#!/usr/bin/env bash # Decides whether a CI suite must run: exit 0 = run, exit 1 = nothing relevant changed. # # The comparison base comes from the event (review M8 P2), never from HEAD^ alone: # - push: CI_BEFORE (the push's `before` SHA), so every commit of a multi-commit push # counts, not just the last; # - pull_request: CI_PR_BASE (the base SHA), diffed against the checked-out merge; # - workflow_dispatch, schedule, a local run or any other event: always run. # A missing, all-zero or unfetchable base, or any git failure, also runs the suite: # uncertainty never skips validation. tools/ci/ci-paths-check.sh tests this offline. set -euo pipefail suite=${1:?suite required} event="${CI_EVENT:-${GITHUB_EVENT_NAME:-}}" case "$event" in push) base="${CI_BEFORE:-${GITHUB_EVENT_BEFORE:-}}" ;; pull_request) base="${CI_PR_BASE:-}" ;; *) exit 0 ;; esac if [[ ! "$base" =~ ^[0-9a-f]{40}$ || "$base" == 0000000000000000000000000000000000000000 ]]; then exit 0 fi if ! git cat-file -e "$base^{commit}" 2> /dev/null; then git fetch --no-tags --quiet --depth=1 origin "$base" > /dev/null 2>&1 || exit 0 git cat-file -e "$base^{commit}" 2> /dev/null || exit 0 fi if ! files=$(git diff --name-only "$base" HEAD 2> /dev/null); then exit 0 fi # Every suite runs when the workflow or this selector changes. common='\.gitea/workflows/|tools/ci/ci-paths\.sh' native='CMakeLists\.txt|CMakePresets\.json|cmake/|include/|src/|apps/' # Sources compiled only into evo-postgres-tests (CMakeLists.txt). The native suites never # build them, so a change to one alone selects the PostgreSQL suites, not checks/tsan/ecs; # the PostgreSQL image runs the repository format check for them instead. postgres_only_tests='tests/(postgres_tests|region_lease_store_tests|cellular_publication_tests|population_publication_tests|environment_publication_tests|account_control_store_tests|probe_handoff_store_tests|life_reservation_store_tests|primitive_publication_tests|region_action_tests|region_checkpoint_store_tests|region_host_tests|region_server_process_tests|region_recovery_tests|region_ops_tests|region_clone_tests|region_migration_tests|region_store_tests|region_load_tests|region_upgrade_tests|region_session_tests|grant_broker_tests|region_m10_session_tests|region_handoff_process_tests|fixtures/postgres_relay)\.cpp' postgres_tools='migrations/|tools/prepare-postgres\.sh|tools/migrate-postgres\.sh|tools/backup/|tools/ci/postgres-check\.sh|tools/ci/life-reservations-|tools/ci/backup-check\.sh|tools/ci/dr-check\.sh|tools/ci/upgrade-check\.sh' case "$suite" in client) pattern="$common|$native|tests/client_lifecycle\.cpp|experiments/(client|ui)/|tools/(prepare-imgui|imgui-pin)\.cmake|tools/prepare-sdl3\\.cmake|tools/sdl3-pin\\.cmake|deploy/docker/Dockerfile" ;; network) pattern="$common|$native|tests/network_|tests/fuzz/dev_session|third_party/mbedtls/|tools/prepare-mbedtls\.cmake|tools/mbedtls-pin\.cmake|deploy/docker/Dockerfile" ;; checks|tsan|ecs) pattern="$common|$native|tests/|experiments/|tools/ci/linux-check\.sh|tools/ci/tsan-profile\.mjs|deploy/docker/Dockerfile" files=$(grep -Ev "^($postgres_only_tests)$" <<< "$files" || true) ;; postgres|postgres-tools) pattern="$common|$native|tests/|$postgres_tools|third_party/mbedtls/|tools/prepare-mbedtls\.cmake|tools/mbedtls-pin\.cmake|deploy/docker/Dockerfile" ;; deploy) pattern="$common|deploy/|tools/ops/|tools/backup/|tools/ci/deploy-policy-(check|selftest)\.py|tools/ci/prepare-kustomize\.sh|tools/ci/monitoring-check\.sh|tools/ci/ops-lib-check\.sh" ;; server-image) # Session-control, cellular lifecycle/publication and migration integration # tests exercise the server image's runtime and schema-bootstrap boundaries. pattern="$common|$native|tests/network_control\.cpp|tests/cellular_(session_batch|lives|publication)_tests\.cpp|tests/(region_migration|region_ops)_tests\.cpp|migrations/|tools/prepare-postgres\.sh|tools/ci/server-image-smoke\.sh|deploy/docker/Dockerfile" ;; image) pattern="$common|$native|tests/|deploy/docker/Dockerfile" ;; *) exit 0 ;; esac grep -Eq "^($pattern)" <<< "$files"