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

Skip abandoned repos #3559

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Skip abandoned repos #3559

wants to merge 1 commit into from

Conversation

fthomas
Copy link
Member

@fthomas fthomas commented Jan 21, 2025

This implements the idea proposed in #3554 to stop creating wasted PRs by skipping repos whose last commit is older than a configured threshold. The PR contains these changes:

  • a new GitAlg.getCommitDate which returns the commit date as Timestamp of a given SHA-1
  • a new RepoCache.commitDate: Timestamp field that contains the commit date that corresponds to RepoCache.sha1
  • a new RepoConfig.lastCommitMaxAge: Option[FiniteDuration] field that contains the threshold for deciding if a repo should be skipped. A repo is skipped, if the last commit is greater than this FiniteDuration.
  • a default lastCommitMaxAge is added to the default Scala Steward config. Other Scala Steward instances and every repo can override this with a greater value. It is not possible to unset it or override it with a smaller value.
  • RepoCache.checkCache is modified such that after retrieving a fresh cache, the commit date is compared to lastCommitMaxAge and an error is raised eventually

Notes:

  • The addition of a non optional field to RepoCache means that reading an old cache will log an error like this:
2025-01-20 21:16:44,985 ERROR Failed to parse or decode JSON from workspace/store/repo_cache/v1/github/scala-steward-org/test-repo-1/repo_cache.json
io.circe.DecodingFailure$DecodingFailureImpl: DecodingFailure at .commitDate: Missing required field

Fortunately this is only a log message so that Scala Steward will recompute the RepoCache and proceed as normal then. Adding this field is therefore effectively invalidating all RepoCaches out there.

  • A skipped repo looks like this in the log:
2025-01-21 08:35:25,033 INFO  ──────────── Steward scala-steward-org/test-repo-1:scala-cli-test ────────────
2025-01-21 08:35:25,033 INFO  Check cache of scala-steward-org/test-repo-1:scala-cli-test
2025-01-21 08:35:25,738 ERROR Steward scala-steward-org/test-repo-1:scala-cli-test failed
org.scalasteward.core.repocache.RepoCacheAlg$$anon$1: Skipping because last commit is older than 2d
2025-01-21 08:35:25,738 INFO  ──────────── Total time: Steward scala-steward-org/test-repo-1:scala-cli-test: 705ms ────────────

lastCommitMaxAge was set to 2 days in this case.

Closes: #3554

@fthomas fthomas added the enhancement New feature or request label Jan 21, 2025
@fthomas fthomas added this to the 0.33.0 milestone Jan 21, 2025
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.84%. Comparing base (f5a5a09) to head (fb06636).

Files with missing lines Patch % Lines
...org/scalasteward/core/repocache/RepoCacheAlg.scala 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3559      +/-   ##
==========================================
+ Coverage   89.81%   89.84%   +0.02%     
==========================================
  Files         171      171              
  Lines        4988     5011      +23     
  Branches      495      494       -1     
==========================================
+ Hits         4480     4502      +22     
- Misses        508      509       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fthomas fthomas force-pushed the topic/skip-abandoned-repos branch 3 times, most recently from 2ea5470 to 969d2e7 Compare January 22, 2025 20:07
@fthomas fthomas marked this pull request as ready for review January 22, 2025 20:15
@fthomas fthomas force-pushed the topic/skip-abandoned-repos branch from 969d2e7 to fb06636 Compare January 22, 2025 20:17
Copy link
Member

@mzuehlke mzuehlke left a comment

Choose a reason for hiding this comment

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

Only a small change to add such a valuable feature 👍
Not sure where, but would be good to add a note about this feature.
Maybe a short above the value in default.scala-steward.conf ?

And 18 month of inactivity ? I think I would have choosen at most 12 month. But I have no clue if this would be too short.

@mzuehlke
Copy link
Member

Just checked, the public instance check uses 24 month: https://github.com/VirtusLab/scala-steward-repos/blob/main/scripts/test-repos.scala#L32

Copy link
Contributor

@exoego exoego left a comment

Choose a reason for hiding this comment

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

This is awesome.

I feel 540 days is very tolerant but fine.
It is common not to touch repo in maintenance-mode for months in work😌

Dependabot: 90 days
https://docs.github.com/en/code-security/dependabot/working-with-dependabot/managing-pull-requests-for-dependency-updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skip repos if their last commit is older than n
3 participants