Repository navigation
feat: add repo check to re-enable disabled workflows - #712
Conversation
GitHub can automatically disable workflows (e.g. cron jobs on inactive forked repos). The new EnsureWorkflowsEnabled check detects all non-active workflows in a repo and re-enables them. See: https://github.com/orgs/community/discussions/59547 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the pull request, @salman2013! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
- Replace all_paged_items with a direct API call since list_repo_workflows
returns {"total_count": N, "workflows": [...]} not a plain list, causing
paged() to loop indefinitely
- Print all workflow names alongside the "All workflows are enabled" message
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new repository check to detect disabled GitHub Actions workflows and re-enable them automatically (helping recover from GitHub auto-disabling workflows due to inactivity, etc.).
Changes:
- Introduces
EnsureWorkflowsEnabledcheck to list workflows and flag any non-active ones. - Implements
fix()to call the GitHub API to re-enable workflows found disabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
irfanuddinahmad
left a comment
There was a problem hiding this comment.
Independent Review — Issues Copilot Missed
I also reviewed Copilot's four inline comments. All are valid:
- State filter (comments 1 & 2): confirmed —
state != "active"is too broad and will hitdeleted/disabled_manually. - Pagination (comment 3): confirmed — only the first page is fetched; the repo already has
all_paged_items()at line 42 that should be used here. - Duplicate
api.repos.get()calls (comment 4): valid, though this is a pre-existing pattern shared by other checks. Worth a follow-up issue rather than blocking this PR.
Beyond those, a few more things caught my eye:
1. No tests added
The PR adds significant new behaviour but no test coverage. tests/test_repo_checks.py already shows exactly how to mock GhApi with MagicMock. At minimum I'd expect:
check()returns(False, …)when disabled workflows existcheck()returns(True, …)when all workflows are activefix()callsapi.actions.enable_workflow()for each disabled workflowdry_run()does not callapi.actions.enable_workflow()is_relevant()returnsFalsefor security forks and empty repos
2. disabled_manually policy should be explicit
The PR description says the goal is to re-enable automatically disabled workflows, but state != "active" silently catches disabled_manually too. Re-enabling a manually-disabled workflow overrides an intentional admin decision. Even if the team decides to include that state, the docstring and the filter should make it explicit.
3. No error handling in fix() — partial re-enable risk
If enable_workflow() raises for any workflow (e.g. an unexpected state slips through the filter), the loop aborts and the repo is left in a partially re-enabled state with no indication of which workflows succeeded. Either fix the state filter defensively (which resolves this too) or wrap the call in a try/except that logs the failure and continues to the next workflow.
4. Success message lists every workflow name (minor)
When all workflows are enabled, check() returns every workflow name. For repos with many workflows this produces very verbose output. A count-based summary (e.g. "All 14 workflows are enabled") would be more consistent with other checks.
- Filter only disabled_inactivity and disabled_fork states to avoid re-enabling manually disabled workflows (intentional admin decisions) - Add per_page=100 to avoid missing workflows on large repos - Show count-based success message; include manually disabled count only when non-zero - Wrap enable_workflow() in try/except to continue on failure - Add tests covering check(), fix(), dry_run(), and is_relevant() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feanil
left a comment
There was a problem hiding this comment.
One suggestion otherwise, looks good to me.
| ) | ||
|
|
||
| def check(self) -> tuple[bool, str]: | ||
| response = self.api.actions.list_repo_workflows( |
There was a problem hiding this comment.
Use all_paged_items so we don't miss anything. It's very unlikely that we'll have more than a 100 workflows but not impossible. We should write the code to be resilient, especially since the helper already exists.
| False, | ||
| f"Some workflows are disabled:\n\t\t" + "\n\t\t".join(names), | ||
| ) | ||
| manually_disabled = [w for w in response.workflows if w.state == "disabled_manually"] |
There was a problem hiding this comment.
extract disabled_manually into a name string so we can add comments near it if needed.
- Use all_paged_items-compatible pagination via a wrapper function that
extracts .workflows from list_repo_workflows response, since the
endpoint returns {total_count, workflows} rather than a flat list
- Extract DISABLED_MANUALLY_STATE class constant with explanatory comment
- Fix enabled count in message: report "X of Y enabled (Z manually
disabled)" instead of incorrectly showing total as enabled count
- Update make_workflows_api mock to use side_effect for correct
pagination simulation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Description:
GitHub can automatically disable workflows (e.g. cron jobs on inactive forked repos). The new EnsureWorkflowsEnabled check detects all non-active workflows in a repo and re-enables them.
See: https://github.com/orgs/community/discussions/59547
Ticket: #596
How to test
Details can be found here https://github.com/openedx/repo-tools/blob/master/edx_repo_tools/repo_checks/README.rst
Testing results
command
Output on terminal
Verification of output on github
command
Verify that all workflows have been re-enabled