-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin-functional.sh
More file actions
executable file
·66 lines (55 loc) · 2.19 KB
/
Copy pathplugin-functional.sh
File metadata and controls
executable file
·66 lines (55 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Andrew Zhang <whisper67265@outlook.com>
# SPDX-License-Identifier: BSL-1.0
# Plugin functional test entrypoint (P1).
# Builds the stack, waits for health, creates API token, extracts SSH pubkey,
# runs functional tests against a live Weblate instance.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=lib/weblate-stack.sh
source "${SCRIPT_DIR}/lib/weblate-stack.sh"
cleanup() {
local exit_code=$?
set +e
echo "--- Collecting logs ---"
stack_logs /tmp/compose-logs.txt
echo "--- Tearing down stack ---"
stack_down
exit "$exit_code"
}
trap cleanup EXIT
echo "=== Building stack ==="
stack_build
echo "=== Starting stack ==="
stack_up
echo "=== Waiting for Weblate ==="
stack_wait_healthy "${HEALTH_TIMEOUT:-300}"
stack_wait_api_ready
echo "=== Creating API token ==="
WEBLATE_API_TOKEN="$(stack_create_token_retry admin)"
export WEBLATE_API_TOKEN
export WEBLATE_LIVE_BASE_URL="${WEBLATE_LIVE_BASE_URL:-http://localhost:${WEBLATE_PORT:-8080}}"
export WEBLATE_COMPOSE_FILE="${COMPOSE_FILE}"
export WEBLATE_COMPOSE_PROJECT="${COMPOSE_PROJECT_NAME}"
echo "=== Extracting Weblate SSH public key ==="
TMP_WEBLATE_SSH_PUBKEY="$(compose exec -T weblate cat /app/data/ssh/id_rsa.pub)"
if [[ -z "${TMP_WEBLATE_SSH_PUBKEY}" ]]; then
echo "ERROR: Failed to read Weblate SSH public key from container." >&2
exit 1
fi
export WEBLATE_SSH_PUBKEY="${TMP_WEBLATE_SSH_PUBKEY}"
unset TMP_WEBLATE_SSH_PUBKEY
if [[ -n "${GH_TEST_REPO_TOKEN:-}" ]]; then
export GH_TEST_REPO_TOKEN
echo "=== Configuring Weblate SSH known_hosts for GitHub ==="
stack_ensure_github_known_hosts
echo "=== GH_TEST_REPO_TOKEN is set (${#GH_TEST_REPO_TOKEN} chars); GitHub E2E tests enabled ==="
else
echo "=== GH_TEST_REPO_TOKEN is not set; GitHub E2E/Celery tests will be skipped ==="
fi
echo "=== Running functional tests ==="
uv pip install --quiet --system --group plugin
PYTEST_PLUGIN_OPTS="${PYTEST_PLUGIN_OPTS:---timeout=300 --timeout-method=thread --reruns 1 --reruns-delay 5}"
# shellcheck disable=SC2086
python -m pytest --confcutdir=tests/plugin --override-ini addopts= \
$PYTEST_PLUGIN_OPTS tests/plugin/test_functional.py -v