From e2e7cbc3f40153a5be1e69f4da53f4082e2af2e5 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 5 Jun 2023 16:02:17 +0200 Subject: [PATCH 1/3] Make point release script compatible with docutils 0.16 --- scripts/release.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index bad5462fe071..cb107c68e091 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -141,8 +141,17 @@ def read_package(package_path: pathlib.Path) -> Package: return package +def _get_docutils_parser_settings(): + try: + return frontend.get_default_settings(Parser) + except AttributeError: + # docutils < 0.18. Remove fallback in 23.1 + components = (Parser,) + return frontend.OptionParser(components=components).get_default_values() + + def parse_changelog(package: Package) -> List[ChangelogItem]: - settings = frontend.get_default_settings(Parser) + settings = _get_docutils_parser_settings() document = utils.new_document(str(package.history_rst), settings) Parser().parse(package.history_rst.read_text(), document) changelog_items: List[ChangelogItem] = [] From 7cb93b3d931ec843609e645e735841c327433bad Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 6 Jun 2023 11:53:42 +0200 Subject: [PATCH 2/3] Support ro-crate >=0.8.0 and 0.7.0 I guess there's a chance downstream users may run into version conflicts if we pin ro-cate to 0.7.0, and we also don't really want to bump stable version dependencies. --- lib/galaxy/model/store/__init__.py | 2 +- lib/galaxy/model/store/ro_crate_utils.py | 14 ++++++++++++-- test/unit/data/model/test_model_store.py | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/model/store/__init__.py b/lib/galaxy/model/store/__init__.py index cee81a526cbb..828467ebf8e2 100644 --- a/lib/galaxy/model/store/__init__.py +++ b/lib/galaxy/model/store/__init__.py @@ -2450,7 +2450,7 @@ def _init_crate(self) -> ROCrate: "encodingFormat": encoding_format, } ro_crate.add_file( - file_name, + os.path.join(self.export_directory, file_name), dest_path=file_name, properties=properties, ) diff --git a/lib/galaxy/model/store/ro_crate_utils.py b/lib/galaxy/model/store/ro_crate_utils.py index fb769c01483a..e01d29e0e653 100644 --- a/lib/galaxy/model/store/ro_crate_utils.py +++ b/lib/galaxy/model/store/ro_crate_utils.py @@ -6,6 +6,8 @@ Optional, ) +from packaging.version import parse +from rocrate import __version__ as rocrate_version from rocrate.model.computationalworkflow import ( ComputationalWorkflow, WorkflowDescription, @@ -102,13 +104,21 @@ def _add_file(self, dataset: HistoryDatasetAssociation, properties: Dict[Any, An if dataset.dataset.id in self.model_store.dataset_id_to_path: filename, _ = self.model_store.dataset_id_to_path[dataset.dataset.id] if not filename: + # dataset was not serialized filename = f"datasets/dataset_{dataset.dataset.uuid}" + if parse(rocrate_version) >= parse("0.8.0"): + source = None + else: + # Drop in 23.1 + source = filename + else: + source = os.path.join(self.model_store.export_directory, filename) name = dataset.name encoding_format = dataset.datatype.get_mime() properties["name"] = name properties["encodingFormat"] = encoding_format file_entity = crate.add_file( - filename, + source, dest_path=filename, properties=properties, ) @@ -272,7 +282,7 @@ def _add_attrs_files(self, crate: ROCrate): "encodingFormat": "application/json", } crate.add_file( - attrs, + attrs_path, dest_path=attrs, properties=properties, ) diff --git a/test/unit/data/model/test_model_store.py b/test/unit/data/model/test_model_store.py index 6164b2974e55..9481a3bffd1a 100644 --- a/test/unit/data/model/test_model_store.py +++ b/test/unit/data/model/test_model_store.py @@ -347,7 +347,6 @@ def validate_has_pl_galaxy(ro_crate: ROCrate): assert programming_language.id == "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" assert programming_language.name == "Galaxy" assert programming_language.url == "https://galaxyproject.org/" - assert programming_language.version def validate_organize_action(ro_crate: ROCrate): From 70569426824e9854ba51400475a689c6c7d29a37 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 6 Jun 2023 13:20:37 +0200 Subject: [PATCH 3/3] Fail if local branch doesn't match remote branch --- scripts/release.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index bad5462fe071..e5bbf6935036 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -440,6 +440,23 @@ def is_merge_required(base_branch: str, new_branch: str, galaxy_root: pathlib.Pa return True +def ensure_branches_up_to_date(branches: List[str], base_branch: str, upstream: str, galaxy_root: pathlib.Path): + for branch in branches: + subprocess.run(["git", "checkout", branch], cwd=galaxy_root).check_returncode() + # Check that the head commit matches the commit for the same branch at the specified remote repo url + result = subprocess.run(["git", "ls-remote", upstream, f"refs/heads/{branch}"], capture_output=True, text=True) + result.check_returncode() + remote_commit_hash = result.stdout.split("\t")[0] + result = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True) + result.check_returncode() + local_commit_hash = result.stdout.strip() + if remote_commit_hash != local_commit_hash: + raise Exception( + f"Local tip of branch {branch} is {local_commit_hash}, remote tip of branch is {remote_commit_hash}. Make sure that your local branches are up to date and track f{upstream}." + ) + subprocess.run(["git", "checkout", base_branch], cwd=galaxy_root).check_returncode() + + def push_references(references: List[str], upstream: str = "https://github.com/galaxyproject/galaxy.git"): for reference in references: subprocess.run(["git", "push", upstream, reference]).check_returncode() @@ -525,8 +542,11 @@ def create_point_release( click.confirm("Does this look correct?", abort=True) base_branch = current_branch = get_current_branch(galaxy_root) newer_branches = get_branches(galaxy_root, new_version, base_branch) + all_branches = newer_branches + [base_branch] + click.echo("Making sure that all branches are up to date") + ensure_branches_up_to_date(all_branches, base_branch, upstream, galaxy_root) + click.echo("Making sure that merging forward will result in clean merges") - merge_required = False for new_branch in newer_branches: merge_required = is_merge_required(base_branch=current_branch, new_branch=new_branch, galaxy_root=galaxy_root) if merge_required: @@ -537,7 +557,7 @@ def create_point_release( if click.confirm("Continue anyway ?", abort=True): current_branch = new_branch break - subprocess.run(["git", "checkout", base_branch], cwd=galaxy_root) + subprocess.run(["git", "checkout", base_branch], cwd=galaxy_root).check_returncode() modified_paths = [set_root_version(galaxy_root, new_version)] # read packages and find prs that affect a package packages: List[Package] = [] @@ -600,7 +620,7 @@ def create_point_release( click.echo(f"Merging {base_branch} into {new_branch}") merge_and_resolve_branches(galaxy_root, current_branch, new_branch, packages) current_branch = new_branch - references = [release_tag, base_branch] + newer_branches + references = [release_tag] + all_branches if no_confirm or click.confirm(f"Push {','.join(references)} to upstream '{upstream}' ?", abort=True): push_references(references=references, upstream=upstream)