diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 50ba456..5cde76c 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -142,7 +142,9 @@ jobs: run: | set -euo pipefail . .venv/bin/activate - PAIRS=$(python3 scripts/ci/distribute_molecule.py --runner-index ${{ matrix.runner-index }} --max-runners ${{ needs.discover-runners.outputs.runner-count }}) + RUNNER_INDEX="${{ matrix.runner-index }}" + MAX_RUNNERS="${{ needs.discover-runners.outputs.runner-count }}" + 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 - name: Run molecule tests diff --git a/scripts/ci/discover_runners.py b/scripts/ci/discover_runners.py index bb63dce..8371b32 100644 --- a/scripts/ci/discover_runners.py +++ b/scripts/ci/discover_runners.py @@ -111,9 +111,14 @@ def get_runner_count(api_url: str, token: str, owner: str, repo: str) -> int: return DEFAULT_MAX_RUNNERS -def generate_indices(count: int) -> list[int]: - """Generate a list of runner indices [0, 1, ..., count-1].""" - return list(range(count)) +def generate_indices(count: int) -> list[str]: + """Generate a list of runner indices ["0", "1", ..., "N-1"]. + + Uses strings instead of ints because Gitea Actions renders + integer 0 as empty in ${{ matrix.runner-index }} expressions, + causing --runner-index to be passed without a value. + """ + return [str(i) for i in range(count)] @click.command() diff --git a/tests/unit/test_discover_runners.py b/tests/unit/test_discover_runners.py index 9cac15d..fbd3183 100644 --- a/tests/unit/test_discover_runners.py +++ b/tests/unit/test_discover_runners.py @@ -19,13 +19,13 @@ class TestGenerateIndices: assert generate_indices(0) == [] def test_one(self) -> None: - assert generate_indices(1) == [0] + assert generate_indices(1) == ["0"] def test_three(self) -> None: - assert generate_indices(3) == [0, 1, 2] + assert generate_indices(3) == ["0", "1", "2"] def test_five(self) -> None: - assert generate_indices(5) == [0, 1, 2, 3, 4] + assert generate_indices(5) == ["0", "1", "2", "3", "4"] class TestQueryRunners: @@ -166,7 +166,7 @@ class TestMain: result = runner.invoke(main, []) assert result.exit_code == 0 assert "count=3" in result.output - assert "indices=[0, 1, 2]" in result.output + assert 'indices=["0", "1", "2"]' in result.output @patch("scripts.ci.discover_runners.get_runner_count", return_value=5) def test_count_only(self, mock_count: MagicMock) -> None: @@ -180,11 +180,11 @@ class TestMain: runner = CliRunner() result = runner.invoke(main, ["--indices"]) assert result.exit_code == 0 - assert json.loads(result.output.strip()) == [0, 1, 2, 3] + assert json.loads(result.output.strip()) == ["0", "1", "2", "3"] @patch("scripts.ci.discover_runners.get_runner_count", return_value=1) def test_single_runner(self, mock_count: MagicMock) -> None: runner = CliRunner() result = runner.invoke(main, ["--indices"]) assert result.exit_code == 0 - assert json.loads(result.output.strip()) == [0] + assert json.loads(result.output.strip()) == ["0"]