From 83a448c498c08b77ea991e89c3cbe32dd7dbb56d Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 15 Feb 2026 11:58:47 +0100 Subject: [PATCH] Rename e2e env vars to E2E_URL, simplify URL detection Rename GITEA_TEST_SERVER_URL and GITEA_URL to E2E_URL for consistency with E2E_USER and E2E_PASSWORD. Simplify the if/else in test-e2e.sh. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/pull-e2e-tests.yml | 2 +- playwright.config.ts | 2 +- tools/test-e2e.sh | 27 +++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pull-e2e-tests.yml b/.github/workflows/pull-e2e-tests.yml index 0cdf37cd2d..2c850cbdf6 100644 --- a/.github/workflows/pull-e2e-tests.yml +++ b/.github/workflows/pull-e2e-tests.yml @@ -51,5 +51,5 @@ jobs: INSTALL_LOCK = true EOF - run: ./gitea web & - - run: GITEA_URL=http://localhost:3000 make test-e2e + - run: E2E_URL=http://localhost:3000 make test-e2e timeout-minutes: 10 diff --git a/playwright.config.ts b/playwright.config.ts index 79979ad931..a194960a50 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ timeout: env.CI ? 15000 : 5000, }, use: { - baseURL: env.GITEA_TEST_SERVER_URL?.replace?.(/\/$/g, '') || 'http://localhost:3000', + baseURL: env.E2E_URL?.replace?.(/\/$/g, '') || 'http://localhost:3000', locale: 'en-US', trace: 'off', screenshot: 'off', diff --git a/tools/test-e2e.sh b/tools/test-e2e.sh index bde5d76561..edd42efc8e 100755 --- a/tools/test-e2e.sh +++ b/tools/test-e2e.sh @@ -1,15 +1,13 @@ #!/bin/bash set -euo pipefail -# Determine the Gitea server URL, either from GITEA_URL env var or from custom/conf/app.ini -if [ -n "${GITEA_URL:-}" ]; then - GITEA_TEST_SERVER_URL="$GITEA_URL" -else +# Determine the Gitea server URL, either from E2E_URL env var or from custom/conf/app.ini +if [ -z "${E2E_URL:-}" ]; then INI_FILE="custom/conf/app.ini" if [ ! -f "$INI_FILE" ]; then - echo "error: $INI_FILE not found and GITEA_URL not set" >&2 - echo "Either start Gitea with a config or set GITEA_URL explicitly:" >&2 - echo " GITEA_URL=http://localhost:3000 make test-e2e" >&2 + echo "error: $INI_FILE not found and E2E_URL not set" >&2 + echo "Either start Gitea with a config or set E2E_URL explicitly:" >&2 + echo " E2E_URL=http://localhost:3000 make test-e2e" >&2 exit 1 fi ROOT_URL=$(sed -n 's/^ROOT_URL\s*=\s*//p' "$INI_FILE" | tr -d '[:space:]') @@ -17,20 +15,20 @@ else echo "error: ROOT_URL not found in $INI_FILE" >&2 exit 1 fi - GITEA_TEST_SERVER_URL="$ROOT_URL" + E2E_URL="$ROOT_URL" fi # Normalize URL: trim trailing slash to avoid double slashes when appending paths -GITEA_TEST_SERVER_URL="${GITEA_TEST_SERVER_URL%/}" +E2E_URL="${E2E_URL%/}" -echo "Using Gitea server: $GITEA_TEST_SERVER_URL" +echo "Using Gitea server: $E2E_URL" # Verify server is reachable, retry for up to 2 minutes for slow startup MAX_WAIT=120 ELAPSED=0 -while ! curl -sf --max-time 5 "$GITEA_TEST_SERVER_URL" > /dev/null 2>&1; do +while ! curl -sf --max-time 5 "$E2E_URL" > /dev/null 2>&1; do if [ "$ELAPSED" -ge "$MAX_WAIT" ]; then - echo "error: Gitea server at $GITEA_TEST_SERVER_URL is not reachable after ${MAX_WAIT}s" >&2 + echo "error: Gitea server at $E2E_URL is not reachable after ${MAX_WAIT}s" >&2 echo "Start Gitea first: ${EXECUTABLE:-./gitea}" >&2 exit 1 fi @@ -42,7 +40,7 @@ done E2E_USER="e2e" E2E_EMAIL="e2e@test.gitea.io" E2E_PASSWORD="password" -if ! curl -sf --max-time 5 "$GITEA_TEST_SERVER_URL/api/v1/users/$E2E_USER" > /dev/null 2>&1; then +if ! curl -sf --max-time 5 "$E2E_URL/api/v1/users/$E2E_USER" > /dev/null 2>&1; then echo "Creating e2e test user..." if ${EXECUTABLE:-./gitea} admin user create --username "$E2E_USER" --email "$E2E_EMAIL" --password "$E2E_PASSWORD" --must-change-password=false 2>/dev/null; then echo "User '$E2E_USER' created" @@ -52,7 +50,8 @@ if ! curl -sf --max-time 5 "$GITEA_TEST_SERVER_URL/api/v1/users/$E2E_USER" > /de fi fi -export GITEA_TEST_SERVER_URL +export E2E_URL export E2E_USER export E2E_PASSWORD + exec pnpm exec playwright test "$@"