Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

1.3 KB
Raw Blame
#!/usr/bin/env bash
set -euo pipefail

script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
map_file="$script_dir/e2e-escalation.map"

suites=(api-extended cli-extended infra-extended smoke)

known_suite() {
  local candidate
  for candidate in "${suites[@]}"; do
    [ "$1" = "$candidate" ] && return 0
  done
  return 1
}

patterns=()
targets=()
while IFS= read -r line || [ -n "$line" ]; do
  case "$line" in '' | '#'*) continue ;; esac
  read -r pattern rule_suites <<<"$line"
  if [ -z "${rule_suites:-}" ]; then
    echo "detect-e2e-suites: rule names no suite: $line" >&2
    exit 1
  fi
  for suite in $rule_suites; do
    if [ "$suite" != "-" ] && ! known_suite "$suite"; then
      echo "detect-e2e-suites: unknown suite \"$suite\" in rule: $line" >&2
      exit 1
    fi
  done
  patterns+=("$pattern")
  targets+=("$rule_suites")
done <"$map_file"

if [ ${#patterns[@]} -eq 0 ]; then
  echo "detect-e2e-suites: $map_file holds no rule" >&2
  exit 1
fi

escalated=""
while IFS= read -r path || [ -n "$path" ]; do
  [ -n "$path" ] || continue
  for i in "${!patterns[@]}"; do
    if [[ $path =~ ${patterns[$i]} ]]; then
      escalated+=" ${targets[$i]} "
      break
    fi
  done
done

for suite in "${suites[@]}"; do
  if [[ $escalated == *" $suite "* ]]; then
    echo "run_${suite//-/_}=true"
  else
    echo "run_${suite//-/_}=false"
  fi
done