diff --git a/.github/scripts/fetch_publication_scope.py b/.github/scripts/fetch_publication_scope.py index a3f51ac12..089804cd5 100644 --- a/.github/scripts/fetch_publication_scope.py +++ b/.github/scripts/fetch_publication_scope.py @@ -13,6 +13,7 @@ PUBLICATION_SCOPE_PATH = REPO_ROOT / ".github" / "publication_scope.json" VALID_FIELDS = frozenset( { + "run_id", "base_release_version", "release_bump", "candidate_scope", diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 06c2cbbde..bb36acb28 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -146,7 +146,6 @@ jobs: runs-on: ubuntu-latest needs: - lint - - run-context - data-release-version if: startsWith(github.event.head_commit.message, 'Update publication candidate') permissions: @@ -157,9 +156,9 @@ jobs: - name: Dispatch pipeline workflow env: GH_TOKEN: ${{ github.token }} - US_DATA_RUN_ID: ${{ needs.run-context.outputs.run_id }} SOURCE_SHA: ${{ github.sha }} run: | + export US_DATA_RUN_ID="$(python .github/scripts/fetch_publication_scope.py run_id)" export CANDIDATE_VERSION="$(python .github/scripts/fetch_publication_scope.py candidate_scope)" export BASE_RELEASE_VERSION="$(python .github/scripts/fetch_publication_scope.py base_release_version)" export RELEASE_BUMP="$(python .github/scripts/fetch_publication_scope.py release_bump)" diff --git a/changelog.d/1153.fixed.md b/changelog.d/1153.fixed.md new file mode 100644 index 000000000..b2f8db4a9 --- /dev/null +++ b/changelog.d/1153.fixed.md @@ -0,0 +1 @@ +Fixed publication pipeline dispatch to reuse the committed publication candidate run ID. diff --git a/tests/unit/test_publication_scripts.py b/tests/unit/test_publication_scripts.py index d7df93b0c..d646b3964 100644 --- a/tests/unit/test_publication_scripts.py +++ b/tests/unit/test_publication_scripts.py @@ -171,6 +171,7 @@ def test_fetch_publication_scope_prints_requested_field( path.write_text( json.dumps( { + "run_id": "run-123", "base_release_version": "1.73.0", "release_bump": "minor", "candidate_scope": "1.73.0-minor", @@ -186,6 +187,35 @@ def test_fetch_publication_scope_prints_requested_field( assert capsys.readouterr().out.strip() == "1.73.0-minor" +def test_fetch_publication_scope_prints_committed_run_id( + tmp_path, + monkeypatch, + capsys, +): + module = _load_script( + ".github/scripts/fetch_publication_scope.py", + "fetch_publication_scope_run_id_script_test", + ) + path = tmp_path / "publication_scope.json" + path.write_text( + json.dumps( + { + "run_id": "run-123", + "base_release_version": "1.73.0", + "release_bump": "minor", + "candidate_scope": "1.73.0-minor", + "would_release_as_at_build_time": "1.74.0", + } + ) + ) + monkeypatch.setattr(module, "PUBLICATION_SCOPE_PATH", path) + monkeypatch.setattr(sys, "argv", ["fetch_publication_scope.py", "run_id"]) + + module.main() + + assert capsys.readouterr().out.strip() == "run-123" + + def test_fetch_publication_scope_exits_on_missing_field( tmp_path, monkeypatch, @@ -206,6 +236,19 @@ def test_fetch_publication_scope_exits_on_missing_field( assert "Publication scope file is missing required field" in capsys.readouterr().err +def test_launch_pipeline_reuses_publication_scope_run_id(): + workflow = (REPO_ROOT / ".github" / "workflows" / "push.yaml").read_text() + launch_pipeline = workflow.split(" launch-pipeline:", maxsplit=1)[1] + + assert ( + 'export US_DATA_RUN_ID="$(python .github/scripts/fetch_publication_scope.py run_id)"' + in launch_pipeline + ) + assert ( + "US_DATA_RUN_ID: ${{ needs.run-context.outputs.run_id }}" not in launch_pipeline + ) + + def test_fetch_release_version_prints_stable_version(tmp_path, monkeypatch, capsys): module = _load_script( ".github/scripts/fetch_release_version.py",