Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codespaces at risk report: Exclude uninteresting repos from reporting #706

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion workspace/codespaces/codespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CODE = RichTextElementParts.TextStyle(code=True)
BOLD = RichTextElementParts.TextStyle(bold=True)
Text = RichTextElementParts.Text
Link = RichTextElementParts.Link
Emoji = RichTextElementParts.Emoji


Expand Down Expand Up @@ -129,13 +130,27 @@ def is_at_risk(codespace, threshold_in_days):


def main(threshold_in_days):
# These could be parameters instead of hard-coded but no need for now.
org = "opensafely"
excluded_repos = [
# Repos unlikely to contain valuable work product.
# Template for tutorial.
"ehrql-tutorial",
# Tagged non-research.
"research-template",
"roadmap",
"documentation",
]

# Fetch info on org CodeSpaces at risk from GitHub API.
records = fetch(URL_PATTERN.format(org=org), "codespaces")
codespaces = (get_codespace(rec) for rec in records)
at_risk_codespaces = sorted(
(cs for cs in codespaces if is_at_risk(cs, threshold_in_days)),
(
cs
for cs in codespaces
if is_at_risk(cs, threshold_in_days) and cs.repo not in excluded_repos
),
key=lambda cs: cs.remaining_retention_period_days,
)

Expand All @@ -145,6 +160,12 @@ def main(threshold_in_days):
if at_risk_codespaces:
intro_block = RichTextSectionElement(
elements=[
Text(text=("For how to use this report, refer to ")),
Link(
url="https://github.com/ebmdatalab/team-manual/blob/main/docs/tech-group/playbooks/codespaces.md",
text="the Codespaces playbook",
),
Text(text=". "),
Text(text=org, style=CODE),
Text(
text=(
Expand Down