diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index c71585f701..20ca4b9098 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -4,6 +4,11 @@ on: push: branches: - develop + # Dispatchable so the diagnostic fast-test job can be run on a branch (e.g. + # "is the SQLite JDBC staging red on develop too?"). The release-publishing + # build and the API deploy stay push-only: a dispatch must never publish a + # snapshot or redeploy the API from an arbitrary branch. + workflow_dispatch: permissions: contents: write @@ -253,6 +258,7 @@ jobs: ############################################# build: needs: fast-test + if: github.event_name == 'push' uses: ./.github/workflows/release.yml secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} @@ -279,6 +285,7 @@ jobs: # version on api.wheels.dev tracks the current framework state. deploy-api-snapshot: needs: fast-test + if: github.event_name == 'push' runs-on: ubuntu-24.04 permissions: contents: read diff --git a/tools/ci/fetch-sqlite-jdbc.sh b/tools/ci/fetch-sqlite-jdbc.sh index 7584ff3114..f2d4c94bc8 100755 --- a/tools/ci/fetch-sqlite-jdbc.sh +++ b/tools/ci/fetch-sqlite-jdbc.sh @@ -1,16 +1,29 @@ #!/usr/bin/env bash -# Download the SQLite JDBC driver that CI installs into Lucee Express, and fail -# loudly unless the file is exactly the pinned jar. +# Provide the SQLite JDBC driver CI installs into Lucee Express, and fail loudly +# unless the file is exactly the pinned jar. # -# A plain `curl -sL` exits 0 on an HTTP error page or a truncated transfer, and -# the damaged jar only surfaced later as Tomcat's "zip END header not found" -# and `org.sqlite.JDBC` missing at test time. Each attempt here must pass -# `curl --fail` and the SHA-256 check; a mismatch is downloaded again, up to -# three attempts. +# The jar is VENDORED in this repository: the Docker images and the CI helpers +# all use tools/docker/lib/sqlite-jdbc-.jar. Resolving it from the tree +# means a Maven Central 429/404 cannot red a build before any Wheels code runs +# (the flake behind #4722/#4728/#4729). There is deliberately no network +# fallback: an unknown version must be vendored deliberately, with its SHA-256 +# from the upstream release, rather than reintroducing a silent download. +# +# Version note: two versions are intentional. 3.50.3.0 is the framework/Docker +# CI driver. The CLI-staged 3.49.1.x extension (cli/lucli/resources/extensions/ +# sqlite) and the Lucee extension source (tools/lucee-extensions/sqlite/src) are +# differently packaged and have different SHA-256s, so callers pass the version +# and hash they need. Reconciling them is a deliberate CLI/extension decision, +# not a cleanup; the exact hashes live in the callers below. +# +# Every candidate is verified against the expected SHA-256 before it is copied, +# and the destination is verified again, so a corrupted or wrong jar still fails +# loudly. # # Usage: bash tools/ci/fetch-sqlite-jdbc.sh [output-path [version sha256]] -# output-path defaults to /tmp/sqlite-jdbc.jar. Without a version, it fetches the -# 3.50.3.0 jar CI installs. A different version must come with its SHA-256. +# output-path defaults to /tmp/sqlite-jdbc.jar. Without a version, it uses the +# 3.50.3.0 jar CI installs. A different version must come with its SHA-256 and +# must already be vendored in one of the known locations. set -euo pipefail OUT="${1:-/tmp/sqlite-jdbc.jar}" @@ -26,7 +39,9 @@ else # Maven Central's published sqlite-jdbc-3.50.3.0.jar.sha256. SHA256="a3f53a2aa15ae9425a9e793bbe9c8e5288febeb4b65ef5c1a4e80d4c2045cf08" fi -URL="https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/${VERSION}/sqlite-jdbc-${VERSION}.jar" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" sha256_of() { if command -v sha256sum >/dev/null 2>&1; then @@ -36,23 +51,46 @@ sha256_of() { fi } -tmp="${OUT}.download" -for attempt in 1 2 3; do - rm -f "$tmp" - if ! curl -fsSL --retry 3 --retry-delay 2 --retry-all-errors -o "$tmp" "$URL"; then - echo "Attempt ${attempt}: could not download ${URL}" >&2 - else - actual="$(sha256_of "$tmp")" - if [ "$actual" = "$SHA256" ]; then - mv "$tmp" "$OUT" - echo "sqlite-jdbc ${VERSION} downloaded and verified (sha256 ${SHA256}): ${OUT}" - exit 0 - fi - echo "Attempt ${attempt}: sqlite-jdbc ${VERSION} has sha256 ${actual} ($(wc -c <"$tmp" | tr -d ' ') bytes), expected ${SHA256}" >&2 +# Every vendored location, in preference order. The CLI extension jar and the +# Lucee-extension source jar are differently packaged, so the SHA-256 check (not +# the filename) decides which one is the right bytes for the requested version. +CANDIDATES=( + "$REPO_ROOT/tools/docker/lib/sqlite-jdbc-${VERSION}.jar" + "$REPO_ROOT/tools/docker/adobe2021/lib/sqlite-jdbc-${VERSION}.jar" + "$REPO_ROOT/tools/docker/adobe2023/lib/sqlite-jdbc-${VERSION}.jar" + "$REPO_ROOT/tools/docker/adobe2025/lib/sqlite-jdbc-${VERSION}.jar" + "$REPO_ROOT/cli/lucli/resources/extensions/sqlite/org.xerial.sqlite-jdbc-${VERSION}.jar" + "$REPO_ROOT/tools/lucee-extensions/sqlite/src/sqlite-jdbc-${VERSION}.jar" +) + +SRC="" +CHECKED="" +for candidate in "${CANDIDATES[@]}"; do + [ -f "$candidate" ] || continue + CHECKED="${CHECKED}${CHECKED:+, }${candidate#"$REPO_ROOT/"}" + actual="$(sha256_of "$candidate")" + if [ "$actual" = "$SHA256" ]; then + SRC="$candidate" + break fi - [ "$attempt" -lt 3 ] && sleep 5 + echo "Vendored candidate ${candidate} has sha256 ${actual}, expected ${SHA256}; continuing." >&2 done -rm -f "$tmp" -echo "::error::Could not download a verified sqlite-jdbc ${VERSION} from ${URL}" >&2 -exit 1 +if [ -z "$SRC" ]; then + echo "::error::No vendored sqlite-jdbc ${VERSION} with sha256 ${SHA256} found under tools/docker/lib, tools/docker/adobe*/lib, cli/lucli/resources/extensions/sqlite, or tools/lucee-extensions/sqlite/src. Vendor the jar (and its upstream SHA-256) instead of downloading it at build time." >&2 + if [ -n "$CHECKED" ]; then + echo "Candidates checked: ${CHECKED}" >&2 + fi + exit 1 +fi + +mkdir -p "$(dirname "$OUT")" +if [ "$SRC" != "$OUT" ]; then + cp "$SRC" "$OUT" +fi +actual="$(sha256_of "$OUT")" +if [ "$actual" != "$SHA256" ]; then + echo "::error::Copied sqlite-jdbc ${VERSION} to ${OUT} but its sha256 is ${actual}, expected ${SHA256}" >&2 + exit 1 +fi +echo "sqlite-jdbc ${VERSION} resolved from the tree and verified (sha256 ${SHA256}): ${SRC} -> ${OUT}" diff --git a/tools/test-cli-e2e.sh b/tools/test-cli-e2e.sh index 0e3708b324..b52e62c476 100755 --- a/tools/test-cli-e2e.sh +++ b/tools/test-cli-e2e.sh @@ -507,7 +507,7 @@ sleep 1 # Ensure SQLite JDBC driver is available LUCEE_LIB=$(find ~/.lucli/express -path "*/lib/ext" -type d 2>/dev/null | head -1) if [ -n "$LUCEE_LIB" ] && ! ls "$LUCEE_LIB"/sqlite-jdbc*.jar 1>/dev/null 2>&1; then - echo " Downloading SQLite JDBC driver..." + echo " Staging SQLite JDBC driver from the vendored tree..." bash "$PROJECT_ROOT/tools/ci/fetch-sqlite-jdbc.sh" "$LUCEE_LIB/sqlite-jdbc-3.49.1.0.jar" \ 3.49.1.0 5c8609d2ca341deb8c6f71778974b5ba4995c7d32d7c7c89d9392a3e72c39291 fi diff --git a/tools/test-cli-local.sh b/tools/test-cli-local.sh index 544ace9d44..744fd63670 100755 --- a/tools/test-cli-local.sh +++ b/tools/test-cli-local.sh @@ -370,7 +370,7 @@ else done fi if [ -n "$LUCEE_LIB" ] && ! ls "$LUCEE_LIB"/sqlite-jdbc*.jar 1>/dev/null 2>&1; then - echo "Downloading SQLite JDBC driver to $LUCEE_LIB..." + echo "Staging SQLite JDBC driver from the vendored tree to $LUCEE_LIB..." # The CLI stages 3.49.1.0 (`wheels start`); pinned by SHA-256 like the release packages. bash "$PROJECT_ROOT/tools/ci/fetch-sqlite-jdbc.sh" "$LUCEE_LIB/sqlite-jdbc-3.49.1.0.jar" \ 3.49.1.0 5c8609d2ca341deb8c6f71778974b5ba4995c7d32d7c7c89d9392a3e72c39291 diff --git a/tools/test-local.sh b/tools/test-local.sh index c38d0203d8..724f0b5899 100755 --- a/tools/test-local.sh +++ b/tools/test-local.sh @@ -493,10 +493,10 @@ stage_sqlite_driver() { [ "$STAGING_ALLOWED" = "true" ] || return 1 [ -n "$1" ] && [ -d "$lib" ] || return 1 ls "$lib"/sqlite-jdbc*.jar 1>/dev/null 2>&1 && return 1 - echo "Downloading SQLite JDBC driver into Lucee Express $1..." + echo "Staging SQLite JDBC driver from the vendored tree into Lucee Express $1..." if ! bash "$PROJECT_ROOT/tools/ci/fetch-sqlite-jdbc.sh" "$lib/sqlite-jdbc-${SQLITE_JDBC_VERSION}.jar" \ "$SQLITE_JDBC_VERSION" "$SQLITE_JDBC_SHA256"; then - echo "::warning::Could not download the SQLite JDBC driver into $lib" >&2 + echo "::warning::Could not stage the SQLite JDBC driver into $lib" >&2 return 2 fi return 0