Skip to content

Commit a05fbaa

Browse files
committed
confirm the test_repo_token
1 parent 7916d3f commit a05fbaa

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

.github/workflows/integration-functional.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 25
1717
env:
18+
# Use a repository *secret* (Settings → Secrets → Actions), not a variable.
1819
GH_TEST_REPO_TOKEN: ${{ secrets.GH_TEST_REPO_TOKEN }}
1920
steps:
2021
# actions/checkout v6.0.2
@@ -27,6 +28,22 @@ jobs:
2728
with:
2829
python-version: '3.12'
2930

31+
- name: Check GitHub test token availability
32+
run: |
33+
set -euo pipefail
34+
if [ "${{ github.event_name }}" = "pull_request" ] && \
35+
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
36+
echo "::notice::Fork PR: repository secrets (including GH_TEST_REPO_TOKEN)" \
37+
"are not passed to workflows from forks."
38+
fi
39+
if [ -n "${GH_TEST_REPO_TOKEN:-}" ]; then
40+
echo "GH_TEST_REPO_TOKEN is set (${#GH_TEST_REPO_TOKEN} characters)."
41+
else
42+
echo "::warning::GH_TEST_REPO_TOKEN is empty. E2E/Celery functional tests will be skipped."
43+
echo "Add a classic PAT with the 'repo' scope as repository secret GH_TEST_REPO_TOKEN."
44+
echo "Re-run the workflow after saving the secret (secrets are not applied retroactively to old runs)."
45+
fi
46+
3047
- name: Run integration functional tests
3148
run: bash scripts/integration-functional.sh
3249

scripts/integration-functional.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ export WEBLATE_COMPOSE_PROJECT="${COMPOSE_PROJECT_NAME}"
4242
echo "=== Extracting Weblate SSH public key ==="
4343
export WEBLATE_SSH_PUBKEY="$(compose exec -T weblate cat /app/data/ssh/id_rsa.pub)"
4444

45+
if [[ -n "${GH_TEST_REPO_TOKEN:-}" ]]; then
46+
export GH_TEST_REPO_TOKEN
47+
echo "=== GH_TEST_REPO_TOKEN is set (${#GH_TEST_REPO_TOKEN} chars); GitHub E2E tests enabled ==="
48+
else
49+
echo "=== GH_TEST_REPO_TOKEN is not set; GitHub E2E/Celery tests will be skipped ==="
50+
fi
51+
4552
echo "=== Running functional tests ==="
4653
pip install --quiet pytest pytest-timeout
4754
python -m pytest --confcutdir=tests/integration --override-ini addopts= \

tests/integration/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ def test_repo(weblate_ssh_pubkey: str) -> EphemeralGitHubRepo:
5959
"""Ephemeral GitHub repo with fixture docs and Weblate deploy key."""
6060
token = os.environ.get("GH_TEST_REPO_TOKEN", "").strip()
6161
if not token:
62-
pytest.skip("GH_TEST_REPO_TOKEN is not set")
62+
pytest.skip(
63+
"GH_TEST_REPO_TOKEN is not set in the job environment "
64+
"(repository Actions secret with classic PAT 'repo' scope; "
65+
"not available on pull_request workflows from forks)"
66+
)
6367

6468
repo_name = default_repo_name()
6569
manager = EphemeralGitHubRepo(token, repo_name)

0 commit comments

Comments
 (0)