Skip to content

Clean up ephemeral files before saving sbt/ivy2 cache#806

Merged
alexarchambault merged 3 commits intomainfrom
copilot/avoid-unnecessary-cache-updates
Mar 16, 2026
Merged

Clean up ephemeral files before saving sbt/ivy2 cache#806
alexarchambault merged 3 commits intomainfrom
copilot/avoid-unnecessary-cache-updates

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

ivydata-*.properties and *.lock files are regenerated on every build and should not be included in the cached archive — their presence causes spurious cache misses and unnecessary cache uploads on every run.

Changes

  • src/save.ts: Before saving sbt-ivy2-cache, delete:
    • ~/.ivy2/cache/**/ivydata-*.properties — Ivy metadata files written on each resolution
    • ~/.sbt/**/*.lock — transient sbt lock files

The cleanup is implemented via a small deleteGlobMatches(pattern) helper (errors silently ignored) and a cleanupSbtIvy2Cache() function called in run() immediately before saveCache('sbt-ivy2-cache'):

async function cleanupSbtIvy2Cache(): Promise<void> {
  // Regenerated on every build — must not be part of the cached archive.
  await deleteGlobMatches('~/.ivy2/cache/**/ivydata-*.properties')
  await deleteGlobMatches('~/.sbt/**/*.lock')
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Avoid unnecessary cache updates</issue_title>
<issue_description>Currently in my workflows, I have the line below to remove various files which are not actually helpful to cache. It would be great if this could be integrated into the action directly to avoid unnecessary cache updates.

    rm -rf "$HOME/.ivy2/local" || true
    find $HOME/Library/Caches/Coursier/v1        -name "ivydata-*.properties" -delete || true
    find $HOME/.ivy2/cache                       -name "ivydata-*.properties" -delete || true
    find $HOME/.cache/coursier/v1                -name "ivydata-*.properties" -delete || true
    find $HOME/.sbt                              -name "*.lock"               -delete || true</issue_description>

<agent_instructions>Do this (clean-up some files) for ~/.ivy2/cache and ~/.sbt. If the tests do test one of these directories, look into checking that these files are not there after having unpacked the cache.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: alexarchambault <7063723+alexarchambault@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unnecessary cache updates in workflows Clean up ephemeral files before saving sbt/ivy2 cache Mar 16, 2026
Copilot AI requested a review from alexarchambault March 16, 2026 18:26
Copy link
Member

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

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

Delete the stuff under dist/

Copy link
Member

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

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

Delete the stuff under dist/

Co-authored-by: alexarchambault <7063723+alexarchambault@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 16, 2026

Delete the stuff under dist/

Done — reverted the dist/ changes in cec41ec. The dist/ files should be updated by CI, not committed in PRs.

Delete the stuff under dist/

Done — reverted the dist/ changes in cec41ec.

@alexarchambault alexarchambault marked this pull request as ready for review March 16, 2026 23:31
@alexarchambault alexarchambault merged commit 34d69e0 into main Mar 16, 2026
4 checks passed
@alexarchambault alexarchambault deleted the copilot/avoid-unnecessary-cache-updates branch March 16, 2026 23:36
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.

Avoid unnecessary cache updates

2 participants