diff --git a/.github/workflows/commit_test.yml b/.github/workflows/commit_test.yml index e04759f..48f4b99 100644 --- a/.github/workflows/commit_test.yml +++ b/.github/workflows/commit_test.yml @@ -18,9 +18,88 @@ jobs: scandir: './scripts' severity: error + probe_urls: + name: Probe all hardcoded PAServer URLs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Check every explicit PASERVER_URL is still reachable + run: | + set +e + fail=0 + broken=() + while IFS= read -r url; do + status=$(curl -sI --max-time 15 "$url" 2>/dev/null | awk 'NR==1{print $2}' | tr -d '\r') + if [ "$status" = "200" ]; then + echo "OK ($status): $url" + else + echo "::error::Broken PASERVER_URL (status='$status'): $url" + broken+=("$url (status='$status')") + fail=1 + fi + done < <(grep -oP 'PASERVER_URL="\Khttps?://[^"]+' scripts/SetupLinux4Delphi.sh) + + if [ "$fail" -ne 0 ]; then + { + echo "### Broken PASERVER_URL(s)" + printf -- '- `%s`\n' "${broken[@]}" + } >> "$GITHUB_STEP_SUMMARY" + fi + exit "$fail" + + plan: + name: Plan install tests + runs-on: ubuntu-latest + outputs: + versions: ${{ steps.plan.outputs.versions }} + steps: + - uses: actions/checkout@v5 + - name: Determine latest hardcoded version, probe for a newer guessed one + id: plan + run: | + set +e + latest=$(grep -oP 'PRODUCT="\K[0-9]+\.[0-9]+(\.[0-9]+)?' scripts/SetupLinux4Delphi.sh \ + | sort -Vu | tail -1) + echo "Latest hardcoded version: $latest" + + # Pull in just the guessing function; the full script requires root + # before it's even defined, and we don't want to install anything here. + source <(sed -n '/^try_guess_paserver_url()/,/^}/p' scripts/SetupLinux4Delphi.sh) + + major="${latest%%.*}" + rest="${latest#*.}" + minor="${rest%%.*}" + candidates=("${major}.$((minor + 1))" "$((major + 1)).0") + + guessed="" + for c in "${candidates[@]}"; do + if try_guess_paserver_url "$c"; then + echo "::warning::URL guessing found a newer, not-yet-listed PAServer version ($c -> $PASERVER_URL). Consider adding it to scripts/SetupLinux4Delphi.sh." + { + echo "### Newer version found by guessing" + echo "- **$c** -> \`$PASERVER_URL\`" + } >> "$GITHUB_STEP_SUMMARY" + guessed="$c" + break + fi + done + + if [ -n "$guessed" ]; then + versions=$(printf '%s\n' "$latest" "$guessed" | jq -R . | jq -sc .) + else + versions=$(printf '%s\n' "$latest" | jq -R . | jq -sc .) + fi + echo "versions=$versions" >> "$GITHUB_OUTPUT" + echo "Testing versions: $versions" + ubuntu_test: - name: Ubuntu 26.04 + name: Ubuntu 26.04 (${{ matrix.version }}) + needs: plan runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: ${{ fromJson(needs.plan.outputs.versions) }} steps: - uses: actions/checkout@v5 - name: Run Setup and Verify PAServer in Ubuntu 26.04 @@ -32,25 +111,30 @@ jobs: bash -c " set -e chmod +x /workspace/scripts/SetupLinux4Delphi.sh - /workspace/scripts/SetupLinux4Delphi.sh 13.1 - /usr/local/bin/pa13.1.sh & + /workspace/scripts/SetupLinux4Delphi.sh ${{ matrix.version }} + /usr/local/bin/pa${{ matrix.version }}.sh & sleep 15 pgrep paserver " rhel_test: - name: RHEL 10 + name: RHEL 10 (${{ matrix.version }}) + needs: plan runs-on: ubuntu-latest container: image: redhat/ubi10:latest + strategy: + fail-fast: false + matrix: + version: ${{ fromJson(needs.plan.outputs.versions) }} steps: - uses: actions/checkout@v5 - name: Run Setup run: | chmod +x ./scripts/SetupLinux4Delphi.sh - ./scripts/SetupLinux4Delphi.sh 13.1 + ./scripts/SetupLinux4Delphi.sh ${{ matrix.version }} - name: Verify PAServer run: | - /usr/local/bin/pa13.1.sh & + /usr/local/bin/pa${{ matrix.version }}.sh & sleep 15 pgrep paserver diff --git a/AGENTS.md b/AGENTS.md index 5e7f636..acaa9ba 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,9 +58,10 @@ Avoid split ownership of version mapping logic long-term. Target owner is pacomm ### A) Add or change PAServer version mapping Update all of: 1. `scripts/SetupLinux4Delphi.sh` alias map and `PASERVER_URL` entries. -2. Script help text (`--help`). -3. `README.md` version matrix/alias descriptions. -4. `.github/workflows/commit_test.yml` validation target(s) when coverage changes. +2. `scripts/SetupLinux4Delphi.sh`'s `KNOWN_VERSIONS` array — add the new product version string here too. This is the single source of truth `LATEST_VERSION` (`sort -V | tail -1` over it) is computed from, which in turn drives the default `PARAM` value and the help text's `[DEFAULT]` marker (via `version_tag`). Forgetting this step leaves the default pointed at an old version even though the case branch exists. +3. Script help text (`--help`) — add a line with a `$(version_tag X.Y)` call so the `[DEFAULT]` marker can land on it automatically once it's newest. +4. `README.md` version matrix/alias descriptions. +5. No CI edit needed for routine version additions: `.github/workflows/commit_test.yml`'s `probe_urls` job picks up every new `PASERVER_URL` automatically, and `plan` always targets whatever is newest (via its own independent `grep`/`sort -V` over `PRODUCT="..."` lines — it does not read `KNOWN_VERSIONS`). Only touch the workflow file itself if the *mechanism* needs to change (e.g. how many versions get full install tests, or the guess-probing candidates). Keep compiler aliases (`37.0`, `23.0`, etc.) mapping to latest point release, while explicit product aliases (`13.0`, `12.2`) stay exact. @@ -83,8 +84,10 @@ Current automated checks are shell/install focused: - `shellcheck scripts/SetupLinux4Delphi.sh` - `bash -n scripts/SetupLinux4Delphi.sh` - CI in `.github/workflows/commit_test.yml`: - - Ubuntu 26.04 installs 13.1, starts `pa13.1.sh`, verifies `pgrep paserver` - - RHEL 10 does the same + - `probe_urls` does a lightweight `HEAD` check against every hardcoded `PASERVER_URL` and fails if any have gone dead — cheap enough to run for the whole table, independently of the install jobs below. + - `plan` finds the newest `PRODUCT="..."` version and also probes `try_guess_paserver_url` for the next minor/major version; if guessing finds a real, not-yet-listed URL, it's added to the test list and flagged via a workflow warning + summary (a prompt to add it explicitly, not an assertion that it's already covered). + - Ubuntu 26.04 and RHEL 10 each run as a matrix over `plan`'s version list (normally just the latest version; two when guessing finds something newer): install, start `pa.sh`, verify `pgrep paserver`. + - Older explicit versions are covered only by the `probe_urls` reachability check, not a full install — full install/start testing is deliberately limited to the newest version(s) to keep CI light. For pacommander router work, testing is mandatory before calling behavior stable. Validate at least: 1. **Version identification**: incoming connection metadata is parsed into the correct target PAServer version. diff --git a/README.md b/README.md index 1108fb8..2486387 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ Usage: `sudo SetupLinux4Delphi.sh [version] [pkgmgr]` Where [version] is one of the following: -* Florence 13.1 = `Florence`, `37.0`, `13.1` or *blank* +* Florence 13.2 = `Florence`, `37.0`, `13.2` or *blank* +* Florence 13.1 = `13.1` * Florence 13.0 = `13.0` * Athens 12.3 = `Athens`, `23.0`, `12.3`, or `12` * Athens 12.2 = `12.2` @@ -111,7 +112,7 @@ The installation locations are as follows: * `SCRIPT_PATH="/usr/local/bin/pa$PRODUCT.sh"` * `SCRATCH_DIR="$REAL_HOME/.PAServer/$PRODUCT-scratch"` -Where `$PRODUCT` is 13.1, 13.0, 12.2, etc. So you launch the latest *Florence* PAServer with `pa13.1.sh`. +Where `$PRODUCT` is 13.2, 13.1, 12.2, etc. So you launch the latest *Florence* PAServer with `pa13.2.sh`. ## More information diff --git a/scripts/SetupLinux4Delphi.sh b/scripts/SetupLinux4Delphi.sh index 484b974..1ad81b8 100644 --- a/scripts/SetupLinux4Delphi.sh +++ b/scripts/SetupLinux4Delphi.sh @@ -21,8 +21,30 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi +# Every explicit PAServer product version below needs a matching case branch +# further down; this array only tracks which one is newest, so the default +# alias and the help text's [DEFAULT] marker can't drift out of sync with +# each other (or get left pointing at an old version) the way separate +# hardcoded literals did. +KNOWN_VERSIONS=( + 10.2.0 10.2.3 + 10.3.0 10.3.1 10.3.2 10.3.3 + 10.4.0 10.4.1 10.4.2 + 11.0 11.1 11.2 11.3 + 12.0 12.1 12.2 12.3 + 13.0 13.1 13.2 +) +LATEST_VERSION="$(printf '%s\n' "${KNOWN_VERSIONS[@]}" | sort -V | tail -1)" + +# Prints " [DEFAULT]" when $1 is the newest entry in KNOWN_VERSIONS, for tagging help text. +version_tag() { + if [[ "$1" == "$LATEST_VERSION" ]]; then + echo " [DEFAULT]" + fi +} + # Parse arguments -PARAM="37.0" # Default version +PARAM="$LATEST_VERSION" # Default version PKG_OVERRIDE="" # Function to download files using whichever tool is available @@ -52,25 +74,26 @@ while [[ $# -gt 0 ]]; do echo " manager = apt, pacman, dnf, or yum (force specific package manager)" echo "" echo "Where [version] is one of the following:" - echo " 37.0, 13.1 = Florence 13.1 [DEFAULT]" - echo " 13.0 = Florence 13.0" - echo " 23.0, 12.3, 12 = Athens 12.3" - echo " 12.2 = Athens 12.2" - echo " 12.1 = Athens 12.1" - echo " 12.0 = Athens 12.0" - echo " 22.0, 11.3, 11 = Alexandria 11.3" - echo " 11.2 = Alexandria 11.2" - echo " 11.1 = Alexandria 11.1" - echo " 11.0 = Alexandria 11.0" - echo " 21.0, 10.4, 10.4.2 = Sydney 10.4.2" - echo " 10.4.1 = Sydney 10.4.1" - echo " 10.4.0 = Sydney 10.4.0" - echo " 20.0, 10.3, 10.3.3 = Rio 10.3.3" - echo " 10.3.2 = Rio 10.3.2" - echo " 10.3.1 = Rio 10.3.1" - echo " 10.3.0 = Rio 10.3.0" - echo " 19.0, 10.2, 10.2.3 = Tokyo 10.2.3" - echo " 10.2 = Tokyo 10.2.0" + echo " 37.0, 13.2 = Florence 13.2$(version_tag 13.2)" + echo " 13.1 = Florence 13.1$(version_tag 13.1)" + echo " 13.0 = Florence 13.0$(version_tag 13.0)" + echo " 23.0, 12.3, 12 = Athens 12.3$(version_tag 12.3)" + echo " 12.2 = Athens 12.2$(version_tag 12.2)" + echo " 12.1 = Athens 12.1$(version_tag 12.1)" + echo " 12.0 = Athens 12.0$(version_tag 12.0)" + echo " 22.0, 11.3, 11 = Alexandria 11.3$(version_tag 11.3)" + echo " 11.2 = Alexandria 11.2$(version_tag 11.2)" + echo " 11.1 = Alexandria 11.1$(version_tag 11.1)" + echo " 11.0 = Alexandria 11.0$(version_tag 11.0)" + echo " 21.0, 10.4, 10.4.2 = Sydney 10.4.2$(version_tag 10.4.2)" + echo " 10.4.1 = Sydney 10.4.1$(version_tag 10.4.1)" + echo " 10.4.0 = Sydney 10.4.0$(version_tag 10.4.0)" + echo " 20.0, 10.3, 10.3.3 = Rio 10.3.3$(version_tag 10.3.3)" + echo " 10.3.2 = Rio 10.3.2$(version_tag 10.3.2)" + echo " 10.3.1 = Rio 10.3.1$(version_tag 10.3.1)" + echo " 10.3.0 = Rio 10.3.0$(version_tag 10.3.0)" + echo " 19.0, 10.2, 10.2.3 = Tokyo 10.2.3$(version_tag 10.2.3)" + echo " 10.2 = Tokyo 10.2.0$(version_tag 10.2.0)" exit 0 ;; *) @@ -82,7 +105,13 @@ done case "$PARAM" in # Florence - "37.0"|"13.1"|"florence") + "37.0"|"13.2"|"florence") + COMPILER="37.0" + PRODUCT="13.2" + RELEASE="Florence" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/37.0/132/LinuxPAServer37.0.tar.gz" + ;; + "13.1") COMPILER="37.0" PRODUCT="13.1" RELEASE="Florence" @@ -203,9 +232,143 @@ case "$PARAM" in ;; esac +# Attempt to locate a PAServer URL for versions not explicitly listed. +# Probes candidate URLs derived from observed Embarcadero URL patterns. +try_guess_paserver_url() { + local input="$1" + local base="https://altd.embarcadero.com/releases/studio" + local major minor patch has_patch compiler release product digits + + if [[ "$input" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + major="${BASH_REMATCH[1]}"; minor="${BASH_REMATCH[2]}"; patch="${BASH_REMATCH[3]}"; has_patch=1 + elif [[ "$input" =~ ^([0-9]+)\.([0-9]+)$ ]]; then + major="${BASH_REMATCH[1]}"; minor="${BASH_REMATCH[2]}"; patch="0"; has_patch=0 + else + return 1 + fi + + # Map product major version to internal compiler version and release name. + # Compiler numbers tracked the product major 1:1 through 23.0 (Athens/12.x), + # then jumped to 37.0 for Florence/13.x. 14.x/15.x aren't released yet, so + # 38.0/39.0 below are an unverified extrapolation (assuming the pre-jump + # +1-per-major pattern resumed) rather than a confirmed mapping — probing + # still decides whether a guess is actually used, and the caller prints an + # extra warning whenever `release` is empty. + case "$major" in + 10) + case "$minor" in + 2) compiler="19.0"; release="Tokyo" ;; + 3) compiler="20.0"; release="Rio" ;; + 4) compiler="21.0"; release="Sydney" ;; + *) return 1 ;; + esac + product="${major}.${minor}.${patch}" + digits="${major}${minor}${patch}" + ;; + 11|12|13|14|15) + # These eras are only ever named major.minor (no third-level patch + # release like 10.x's Release1/2/3); reject a 3-component input + # instead of silently ignoring the patch and guessing major.minor. + if [ "$has_patch" -eq 1 ]; then + return 1 + fi + case "$major" in + 11) compiler="22.0"; release="Alexandria" ;; + 12) compiler="23.0"; release="Athens" ;; + 13) compiler="37.0"; release="Florence" ;; + 14) compiler="38.0"; release="" ;; + 15) compiler="39.0"; release="" ;; + esac + product="${major}.${minor}" + digits="${major}${minor}" + ;; + *) return 1 ;; + esac + + # Build ordered candidate list based on the URL pattern for each era. + local candidates=() + case "$compiler" in + "19.0"|"20.0") + # Tokyo/Rio: updates use PAServer/Release{N}/ + if [ "$patch" -eq 0 ]; then + candidates+=("$base/$compiler/PAServer/LinuxPAServer${compiler}.tar.gz") + else + candidates+=( + "$base/$compiler/PAServer/Release${patch}/LinuxPAServer${compiler}.tar.gz" + "$base/$compiler/PAServer/LinuxPAServer${compiler}.tar.gz" + ) + fi + ;; + "21.0") + # Sydney: updates use {N}/PAServer/ + if [ "$patch" -eq 0 ]; then + candidates+=("$base/$compiler/PAServer/LinuxPAServer${compiler}.tar.gz") + else + candidates+=( + "$base/$compiler/${patch}/PAServer/LinuxPAServer${compiler}.tar.gz" + "$base/$compiler/PAServer/LinuxPAServer${compiler}.tar.gz" + ) + fi + ;; + "22.0") + # Alexandria: base release has no subdir; updates use {digits}[1]/ + if [ "$minor" -eq 0 ]; then + candidates+=("$base/$compiler/LinuxPAServer${compiler}.tar.gz") + else + candidates+=( + "$base/$compiler/${digits}1/LinuxPAServer${compiler}.tar.gz" + "$base/$compiler/${digits}/LinuxPAServer${compiler}.tar.gz" + ) + fi + ;; + *) + # Athens/Florence and future: flat {digits}/ or nested {digits}/{digits}1/ + candidates+=( + "$base/$compiler/${digits}/LinuxPAServer${compiler}.tar.gz" + "$base/$compiler/${digits}/${digits}1/LinuxPAServer${compiler}.tar.gz" + ) + ;; + esac + + echo "Version '$input' is not explicitly listed. Probing for PAServer..." + local url status + for url in "${candidates[@]}"; do + printf " Trying: %s\n" "$url" + # This runs before prerequisites are installed, so only wget or curl + # (whichever, if either, is already present) can be relied on here. + if command -v wget >/dev/null 2>&1; then + status=$(wget --spider --server-response --timeout=10 "$url" 2>&1 \ + | awk '/^ *HTTP\// {code=$2} END {print code}') + elif command -v curl >/dev/null 2>&1; then + status=$(curl -sI --max-time 10 "$url" 2>/dev/null | awk 'NR==1{print $2}' | tr -d '\r') + else + status="" + fi + if [ "$status" = "200" ]; then + PASERVER_URL="$url" + COMPILER="$compiler" + RELEASE="${release:-Unreleased}" + PRODUCT="$product" + echo " Found!" + echo "WARNING: Using a guessed URL — verify this PAServer matches your IDE version." + if [ -z "$release" ]; then + echo "WARNING: Compiler $compiler for $product is an unverified extrapolation," \ + "not a confirmed mapping — double-check against the DocWiki before relying on it." + fi + return 0 + fi + done + + echo "Could not locate a PAServer for '$input'. Check https://altd.embarcadero.com/releases/studio/ manually." + return 1 +} + if [ -z "$PASERVER_URL" ]; then - echo "Unknown version: $PARAM" - exit 1 + if ! try_guess_paserver_url "$PARAM"; then + echo "Unknown version: $PARAM" + echo "Run with 'help' to see supported versions." + exit 1 + fi fi ARCHIVE="${PASERVER_URL##*/}" diff --git a/test-local.ps1 b/test-local.ps1 index cf84c34..89bf99c 100644 --- a/test-local.ps1 +++ b/test-local.ps1 @@ -9,18 +9,30 @@ # .\test-local.ps1 -Ubuntu # + Ubuntu 26.04 install test # .\test-local.ps1 -RHEL # + RHEL 10 install test # .\test-local.ps1 -All # + both install tests -# .\test-local.ps1 -Version 13.0 # Override PAServer version (default: 13.1) +# .\test-local.ps1 -Version 13.0 # Override PAServer version (default: newest hardcoded version, auto-detected via WSL) param( [switch]$Ubuntu, [switch]$RHEL, [switch]$All, - [string]$Version = "13.1" # Match CI default + [string]$Version = "13.2" # Fallback only, used if WSL can't auto-detect the newest version below ) $Root = $PSScriptRoot $Failures = 0 $Skipped = 0 +$WslAvailable = $null -ne (Get-Command wsl -ErrorAction SilentlyContinue) + +# Mirror commit_test.yml's `plan` job: derive "latest" from the script's own +# PRODUCT="..." lines instead of a second hardcoded literal here, so this +# can't silently fall behind after a version bump. +if (-not $PSBoundParameters.ContainsKey('Version') -and $WslAvailable) { + $ScriptPathWsl = (wsl wslpath ($Root -replace "\\", "/")) + "/scripts/SetupLinux4Delphi.sh" + $Detected = (wsl bash -c "grep -oP 'PRODUCT=`"\K[0-9]+\.[0-9]+(\.[0-9]+)?' '$ScriptPathWsl' | sort -V | tail -1").Trim() + if ($Detected) { + $Version = $Detected + } +} function Write-Header([string]$Text) { Write-Host "" @@ -124,8 +136,6 @@ Invoke-Check "docker installed and daemon ready" { Set-CheckExitCode $script:DockerOk } -$WslAvailable = $null -ne (Get-Command wsl -ErrorAction SilentlyContinue) - # 1. bash -n syntax check (via WSL, no Docker needed) Write-Header "Syntax check (bash -n)"