Skip to content

scripts: de-duplicate and harden the close_pull_requests_with_*.sh backlog jobs - #15169

Closed
priya-sundaram-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
priya-sundaram-dev:improve-close-scripts
Closed

scripts: de-duplicate and harden the close_pull_requests_with_*.sh backlog jobs#15169
priya-sundaram-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
priya-sundaram-dev:improve-close-scripts

Conversation

@priya-sundaram-dev

Copy link
Copy Markdown
Contributor

As requested by @cclauss in #15081 (comment)... — the follow-up PR applying the script recommendations I made in #15168.

What changed

The five scripts/close_pull_requests_with_*.sh jobs were byte-for-byte identical apart from one label name and one comment string. This PR extracts the shared logic into one parameterized close_pull_requests_with_label.sh and turns each named script into a one-line wrapper, so the existing entry points (referenced in docs/hacktober_2026_prep.md) keep working.

Each recommendation from #15168, applied:

  1. Correctness — no more silently skipped PRs. The old scripts ran gh pr list --state open --limit 500 and matched labels in jq. With ~900 open PRs, any matching PR past the 500th was never closed. The new script filters server-side with gh pr list --label "<label>", so the cap can't hide PRs (and it's much faster — it fetches only the matching PRs).
  2. De-duplication. One implementation removes the drift between the copies: awaiting_changes/failing_tests had sleep 2, require_tests had it commented out, and the other two had none.
  3. Consistent throttling. A single deliberate SLEEP (default 2s) between closes to avoid tripping GitHub's secondary rate limits during bulk closes.
  4. Safety rails. set -euo pipefail, an explicit --repo (overridable via REPO=), and a DRY_RUN=1 mode that prints exactly what would close before a maintainer commits.
  5. Machine-readable summary. Ends with CLOSED_COUNT=<n> CLOSED_PRS=<...> so docs/hacktober_2026_prep.md can be updated from the output instead of by hand.

Verification

  • bash -n passes on all six files.
  • Read-only dry run against this repo works end-to-end:
    $ DRY_RUN=1 scripts/close_pull_requests_with_require_tests.sh
    Found 24 open PR(s) with label "require tests" in TheAlgorithms/Python
    [dry-run] would close PR #14973: feat: add MinHash Jaccard similarity estimator
    ...
    CLOSED_COUNT=24 CLOSED_PRS=14973,14732,...,13523
    

Behaviour of the named scripts is unchanged for a maintainer running them; they just share one hardened implementation now.

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only touches shell scripts under scripts/; no algorithm added.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • Related to priya-sundaram-dev as a maintainer? #15081.

…cklog jobs

Extract the five byte-for-byte-identical backlog-closing scripts into one
parameterized close_pull_requests_with_label.sh and make each named script a
thin wrapper. Addresses the recommendations from TheAlgorithms#15168:

- Correctness: filter by label server-side (gh pr list --label) instead of
  listing all ~900 open PRs and matching client-side, so no PR is skipped by
  an arbitrary --limit cap.
- De-duplication: one implementation removes the drift between copies (some
  had sleep 2, one had it commented out, two had none).
- Throttling: a single, deliberate SLEEP (default 2s) between closes.
- Safety rails: set -euo pipefail, explicit --repo, and a DRY_RUN=1 preview
  mode that prints what would close before a maintainer commits.
- Machine-readable summary (CLOSED_COUNT/CLOSED_PRS) so the Hacktoberfest
  tracker can be updated from script output.

Follow-up to TheAlgorithms#15081.
@algorithms-keeper

Copy link
Copy Markdown

Closing this pull request as invalid

@priya-sundaram-dev, this pull request is being closed as the files submitted contains an invalid extension. This repository only accepts Python algorithms. Please read the Contributing guidelines first.

Invalid files in this pull request: scripts/close_pull_requests_with_awaiting_changes.sh, scripts/close_pull_requests_with_failing_tests.sh, scripts/close_pull_requests_with_label.sh, scripts/close_pull_requests_with_require_descriptive_names.sh, scripts/close_pull_requests_with_require_tests.sh, scripts/close_pull_requests_with_require_type_hints.sh

@algorithms-keeper algorithms-keeper Bot closed this Sep 3, 2026
@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Sep 3, 2026
@cclauss cclauss reopened this Sep 3, 2026
@algorithms-keeper

Copy link
Copy Markdown

Closing this pull request as invalid

@priya-sundaram-dev, this pull request is being closed as the files submitted contains an invalid extension. This repository only accepts Python algorithms. Please read the Contributing guidelines first.

Invalid files in this pull request: scripts/close_pull_requests_with_awaiting_changes.sh, scripts/close_pull_requests_with_failing_tests.sh, scripts/close_pull_requests_with_label.sh, scripts/close_pull_requests_with_require_descriptive_names.sh, scripts/close_pull_requests_with_require_tests.sh, scripts/close_pull_requests_with_require_type_hints.sh

@algorithms-keeper algorithms-keeper Bot closed this Sep 3, 2026
@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Sep 3, 2026
@priya-sundaram-dev

Copy link
Copy Markdown
Contributor Author

Heads-up: algorithms-keeper auto-closed this as "invalid" because the diff is .sh-only (the bot only expects Python algorithm files). These are the existing maintenance scripts under scripts/ being de-duplicated — no algorithm content — so the label is a false positive here.

CI is green (build / build_docs / ruff all ✅). @cclauss, happy for you to reopen when convenient, or I can resubmit however you prefer (e.g. as a follow-up to the tracker in #15168). No rush.

@cclauss

cclauss commented Sep 3, 2026

Copy link
Copy Markdown
Member

I want algorithms-keeper to keep flagging PRs that change .sh files because they are executable code.

I will rebuild the PR under my name (giving you credit) and get another maintainer to review it.

@priya-sundaram-dev

Copy link
Copy Markdown
Contributor Author

Sounds good — agree that keeping algorithms-keeper flagging .sh changes is the right call (they're executable code). Thanks for taking it over; credit isn't necessary but appreciated. The de-dup logic and the 5 hardening changes are all in the closed diff here for you to lift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants