diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 5cde76c..a18c1fb 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -133,24 +133,40 @@ jobs: timeout-minutes: 10 strategy: matrix: - runner-index: ${{ fromJSON(needs.discover-runners.outputs.runner-indices) }} + runner-index: [1, 2, 3] steps: - uses: actions/checkout@v4 - name: Set up environment run: make setup - name: Discover assigned test pairs + env: + RUNNER_INDEX: ${{ matrix.runner-index }} + MAX_RUNNERS: ${{ needs.discover-runners.outputs.runner-count }} run: | set -euo pipefail . .venv/bin/activate - RUNNER_INDEX="${{ matrix.runner-index }}" - MAX_RUNNERS="${{ needs.discover-runners.outputs.runner-count }}" + echo "Runner index: $RUNNER_INDEX" + echo "Max runners: $MAX_RUNNERS" + # Skip if runner index exceeds available runners + if [ "$RUNNER_INDEX" -gt "$MAX_RUNNERS" ]; then + echo "Skipping — runner index $RUNNER_INDEX > max runners $MAX_RUNNERS" + echo "TEST_PAIRS=" >> $GITHUB_ENV + echo "SKIP=true" >> $GITHUB_ENV + exit 0 + fi PAIRS=$(python3 scripts/ci/distribute_molecule.py --runner-index "$RUNNER_INDEX" --max-runners "$MAX_RUNNERS") echo "Assigned pairs: $PAIRS" echo "TEST_PAIRS=$PAIRS" >> $GITHUB_ENV + echo "SKIP=false" >> $GITHUB_ENV - name: Run molecule tests + if: env.SKIP != 'true' run: | set -euo pipefail . .venv/bin/activate + if [ -z "$TEST_PAIRS" ]; then + echo "No test pairs assigned — skipping" + exit 0 + fi python3 scripts/ci/molecule_ci_guard.py $TEST_PAIRS env: GITEA_URL: ${{ github.server_url }} diff --git a/scripts/ci/molecule_ci_guard.py b/scripts/ci/molecule_ci_guard.py index c2b01db..2529a38 100644 --- a/scripts/ci/molecule_ci_guard.py +++ b/scripts/ci/molecule_ci_guard.py @@ -126,7 +126,7 @@ def cli(pairs: tuple[str, ...]) -> None: if not all([gitea_url, token, run_id]): click.echo(_("GITEA_URL/REPO_TOKEN/RUN_ID not set; running without cross-runner cancellation.")) - repo_root = Path(__file__).resolve().parent.parent + repo_root = Path(__file__).resolve().parent.parent.parent role_dir = repo_root / "ansible" / "roles" / "gitea-runner" base_env = os.environ.copy()