Files
aevolution/tools/ci/ci-paths.sh
T
dingo d316911355
Foundation / checks (deploy) (push) Successful in 18s
Foundation / checks (ecs) (push) Successful in 2m1s
Foundation / checks (tsan) (push) Successful in 8m42s
Foundation / checks (client) (push) Successful in 13m37s
Foundation / checks (network) (push) Successful in 15m7s
Foundation / checks (postgres) (push) Failing after 33m44s
Foundation / checks (checks) (push) Successful in 37m15s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Run server image for migration contract changes
2026-10-11 21:51:20 -04:00

64 lines
3.1 KiB
Bash
Executable File

#!/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/'
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"
;;
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)
# These session-control and cellular contract tests exercise the server image's
# runtime boundary; migration integration tests cover its schema bootstrap path.
pattern="$common|$native|tests/network_control\.cpp|tests/cellular_(session_batch|lives)_tests\.cpp|tests/region_migration_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"