Skip to content

Finish milestone#178

Merged
James Bruten (james-bruten-mo) merged 24 commits intoMetOffice:mainfrom
jennyhickson:finish_milestone
Feb 10, 2026
Merged

Finish milestone#178
James Bruten (james-bruten-mo) merged 24 commits intoMetOffice:mainfrom
jennyhickson:finish_milestone

Conversation

@jennyhickson
Copy link
Copy Markdown
Collaborator

@jennyhickson Jenny Hickson (jennyhickson) commented Feb 3, 2026

PR Summary

Sci/Tech Reviewer:
Code Reviewer: James Bruten (@james-bruten-mo)

New script for closing a milestone from the Review Tracker project during a release. It:

  • checks if there are still open PRs against the milestone
  • checks if there are closed PRs against another milestone, and changes closed PRs with no milestone to the current one
  • reports on the number of PRs closed for the milestone
  • archives all closed PRs for the milestone
  • gives the command for closing the milestone in each repo

To do this it also improves the project data class, simplifying the data structure, including functions for handling milestones and storing the PR details in objects rather than a dictionary.

The user will need to authenticate themselves to modify the project, github prompts for this on first use.

Code Quality Checklist

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid understanding and enhance the readability of the code
  • My changes generate no new warnings
  • All automated checks in the CI pipeline have completed successfully

Testing

  • This change has been tested appropriately (please describe)

Security Considerations

  • I have reviewed my changes for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance of Generative AI tool name (e.g., Met Office Github Copilot Enterprise, Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the Simulation Systems AI policy (including attribution labels)

Sci/Tech Review

  • I understand this area of code and the changes being added
  • The proposed changes correspond to the pull request description
  • Documentation is sufficient (do documentation papers need updating)
  • Sufficient testing has been completed

(Please alert the code reviewer via a tag when you have approved the SR)

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Security considerations have been addressed
  • Performance impact is acceptable

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of suggestions

Comment thread gh_review_project/review_project.py Outdated
import shlex
from collections import defaultdict

project_id = 376
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
project_id = 376
PROJECT_ID = 376

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread gh_review_project/review_project.py Outdated
from collections import defaultdict

project_id = 376
project_owner = "MetOffice"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
project_owner = "MetOffice"
PROJECT_OWNER = "MetOffice"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread gh_review_project/review_project.py Outdated
raise RuntimeError(
"Error fetching GitHub Project data: \n " + output.stderr.decode()
)
command = f"gh project item-list {project_id} -L 500 --owner {project_owner} --format json"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like project_id/owner should be inputs to this function, rather than hard-coded to the global variable.
Maybe def from_github(cls, project_id=PROJECT_ID, project_owner=PROJECT_OWNER...)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given there is much in this code that is specific to this project, I've left it just pulling directly from the globals for now since there are bigger changes needed to make this an option.

Comment thread gh_review_project/review_project.py Outdated
"""

data = defaultdict(list)
data = []
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would pull_requests or pull_requests_data be a clearer name?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess same with self.data? If it's not just pr's then fair enough

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread gh_review_project/review_project.py Outdated
dry_run: If true, print the command used rather than archiving.
"""

command = f"gh project item-archive {project_id} --owner {project_owner} --id {self.id}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comments around project_owner/id as above

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

pr.archive(dry_run)


class PullRequest:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably wants a docstring

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. Hopefully doc strings everywhere now?

Comment thread gh_review_project/review_project.py Outdated
self.scitechReview = None
self.codeReview = None

def archive(self, dry_run: bool = False):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def archive(self, dry_run: bool = False):
def archive(self, dry_run: bool = False) -> None:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread gh_review_project/finish_milestone.py Outdated
exceptions.
"""
total_open = still_open(open_prs[milestone], milestone)
total_other = closed_other(closed_prs, milestone)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to update the milestone on these PRs to match the closing milestone? I guess you'd logically do it after the check_ready step and before report?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think I could, but worked it out now. Added to the closed_other function as no harm in doing this even if you're not ready to fully archive things.

This also had the side effect of reading things directly from the data everywhere as the modify_milestone function changes things so the copies I'd taken of open and closed PRs by milestone were then out of date.

Comment thread gh_review_project/finish_milestone.py Outdated
* Remaining open PRs and issues against this milestone
* Closed PRs against this milestone
"""
from collections import defaultdict
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure you're using this in this file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jenny, changes look good

@james-bruten-mo James Bruten (james-bruten-mo) merged commit 7fd9c30 into MetOffice:main Feb 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants