0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-16 19:07:41 +02:00

add temp server for local development, misc tweaks

This commit is contained in:
silverwind 2026-02-15 14:34:17 +01:00
parent a7af563050
commit 9a70946124
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
5 changed files with 42 additions and 4 deletions

1
.gitignore vendored
View File

@ -67,6 +67,7 @@ cpu.out
/indexers
/log
/public/assets/img/avatar
/tests/e2e-output
/tests/integration/gitea-integration-*
/tests/integration/indexers-*
/tests/*.ini

View File

@ -178,7 +178,15 @@ Here's how to run the test suite:
| :------------------------------------------ | :------------------------------------------------------- | ------------------------------------------- |
|``make test[\#SpecificTestName]`` | run unit test(s) | |
|``make test-sqlite[\#SpecificTestName]`` | run [integration](tests/integration) test(s) for SQLite | [More details](tests/integration/README.md) |
|``make test-e2e`` | run [end-to-end](tests/e2e) test(s) using Playwright | Requires a running Gitea server |
|``make test-e2e`` | run [end-to-end](tests/e2e) test(s) using Playwright | |
- e2e test environment variables
| Variable | Description |
| :-------------- | :-------------------------------------------------------------------------- |
|``E2E_URL`` | URL of the Gitea server to test against (default: read from ``app.ini``) |
|``E2E_DEBUG`` | When set, show Gitea server output (only for auto-started server) |
|``E2E_FLAGS`` | Additional flags passed to Playwright (e.g. ``--headed --debug``) |
## Translation

View File

@ -559,7 +559,7 @@ playwright: deps-frontend
.PHONY: test-e2e
test-e2e: playwright
EXECUTABLE=$(EXECUTABLE) ./tools/test-e2e.sh $(E2E_FLAGS)
@EXECUTABLE=$(EXECUTABLE) ./tools/test-e2e.sh $(E2E_FLAGS)
.PHONY: bench-sqlite
bench-sqlite: integrations.sqlite.test generate-ini-sqlite

View File

@ -3,6 +3,7 @@ import {defineConfig, devices} from '@playwright/test';
export default defineConfig({
testDir: './tests/e2e/',
outputDir: './tests/e2e-output/',
testMatch: /.*\.test\.ts/,
forbidOnly: Boolean(env.CI),
reporter: 'list',

View File

@ -23,13 +23,41 @@ E2E_URL="${E2E_URL%/}"
echo "Using Gitea server: $E2E_URL"
SERVER_PID=""
cleanup() {
if [ -n "$SERVER_PID" ]; then
echo "Stopping temporary Gitea server (PID $SERVER_PID)..."
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT
# For local development, if no gitea server is running, start a temporary one.
if [ -z "${CI:-}" ] && ! curl -sf --max-time 5 "$E2E_URL" > /dev/null 2>&1; then
if [ ! -x "./$EXECUTABLE" ]; then
echo "error: ./$EXECUTABLE not found or not executable, run 'make backend' first" >&2
exit 1
fi
echo "Starting temporary Gitea server..."
if [ -n "${E2E_DEBUG:-}" ]; then
"./$EXECUTABLE" web &
else
"./$EXECUTABLE" web > /dev/null 2>&1 &
fi
SERVER_PID=$!
fi
# Verify server is reachable, retry for up to 2 minutes for slow startup
MAX_WAIT=120
ELAPSED=0
while ! curl -sf --max-time 5 "$E2E_URL" > /dev/null 2>&1; do
if [ -n "$SERVER_PID" ] && ! kill -0 "$SERVER_PID" 2>/dev/null; then
echo "error: Gitea server process exited unexpectedly" >&2
exit 1
fi
if [ "$ELAPSED" -ge "$MAX_WAIT" ]; then
echo "error: Gitea server at $E2E_URL is not reachable after ${MAX_WAIT}s" >&2
echo "Start Gitea first: ./${EXECUTABLE}" >&2
exit 1
fi
sleep 2
@ -54,4 +82,4 @@ export E2E_URL
export E2E_USER
export E2E_PASSWORD
exec pnpm exec playwright test "$@"
pnpm exec playwright test "$@"