@@ -406,6 +406,42 @@ def test_restore_publication_changelog_restores_candidate_snapshot(
406406 assert (root_changelog / "123.changed.md" ).read_text () == "Changed a thing.\n "
407407
408408
409+ def test_restore_publication_changelog_falls_back_to_scope_snapshot (
410+ tmp_path ,
411+ monkeypatch ,
412+ ):
413+ module = _load_script (
414+ ".github/scripts/restore_publication_changelog.py" ,
415+ "restore_publication_changelog_scope_fallback_test" ,
416+ )
417+ root_changelog = tmp_path / "changelog.d"
418+ publication_dir = tmp_path / ".github" / "publication_candidates"
419+ snapshot = publication_dir / "versioning-run" / "changelog.d"
420+ snapshot .mkdir (parents = True )
421+ (snapshot / "123.changed.md" ).write_text ("Changed a thing.\n " )
422+ scope_path = tmp_path / ".github" / "publication_scope.json"
423+ scope_path .write_text (
424+ json .dumps (
425+ {
426+ "base_release_version" : "1.115.3" ,
427+ "candidate_scope" : "1.115.3-patch" ,
428+ "release_bump" : "patch" ,
429+ "run_id" : "versioning-run" ,
430+ }
431+ )
432+ )
433+ monkeypatch .setenv ("US_DATA_CANDIDATE_VERSION" , "1.115.3-patch" )
434+ monkeypatch .setenv ("US_DATA_BASE_RELEASE_VERSION" , "1.115.3" )
435+ monkeypatch .setenv ("US_DATA_RELEASE_BUMP" , "patch" )
436+ monkeypatch .setattr (module , "ROOT_CHANGELOG_DIR" , root_changelog )
437+ monkeypatch .setattr (module , "PUBLICATION_SCOPE_PATH" , scope_path )
438+ monkeypatch .setattr (module , "PUBLICATION_CANDIDATES_DIR" , publication_dir )
439+
440+ module .restore_candidate_changelog ("pipeline-run" )
441+
442+ assert (root_changelog / "123.changed.md" ).read_text () == "Changed a thing.\n "
443+
444+
409445def test_restore_publication_changelog_rejects_unrelated_root_fragments (
410446 tmp_path ,
411447 monkeypatch ,
@@ -650,6 +686,49 @@ def from_name(app_name, function_name, **kwargs):
650686 assert "VERSION_OVERRIDE" not in json .dumps (captured ["calls" ])
651687
652688
689+ def test_promote_publication_script_prefers_manifest_release_version (
690+ tmp_path ,
691+ monkeypatch ,
692+ ):
693+ monkeypatch .setitem (
694+ sys .modules ,
695+ "modal" ,
696+ types .SimpleNamespace (Function = types .SimpleNamespace ()),
697+ )
698+ module = _load_script (
699+ ".github/scripts/promote_publication_pipeline.py" ,
700+ "promote_publication_pipeline_release_version_test" ,
701+ )
702+ _write_pyproject (tmp_path , "1.74.0" )
703+ monkeypatch .setattr (module , "_REPO_ROOT" , tmp_path )
704+ context = module .RunContext .from_mapping (
705+ {"run_id" : "run-123" },
706+ modal_app_name = "app" ,
707+ modal_environment = "main" ,
708+ )
709+
710+ promoted_context = module ._promotion_context_from_status (
711+ context ,
712+ {
713+ "run_manifest" : {
714+ "run_id" : "run-123" ,
715+ "candidate_version" : "1.73.0-minor" ,
716+ "base_release_version" : "1.73.0" ,
717+ "release_bump" : "minor" ,
718+ "release_version" : "1.74.0" ,
719+ "run_context" : {
720+ "run_id" : "run-123" ,
721+ "candidate_version" : "1.73.0-minor" ,
722+ "base_release_version" : "1.73.0" ,
723+ "release_bump" : "minor" ,
724+ },
725+ }
726+ },
727+ )
728+
729+ assert promoted_context .release_version == "1.74.0"
730+
731+
653732def test_promote_publication_script_requires_release_bump (
654733 tmp_path ,
655734 monkeypatch ,
0 commit comments