Skip to content

Add caching for the Mill build tool #819

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

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

Conversation

clintval
Copy link

@clintval clintval commented May 5, 2025

Description:

Similar to Gradle, Maven, and sbt, I am hoping to see Mill cache support.

Mill is becoming a popular JVM build tool so I hope this is a welcome addition.

I have not contributed to this project before so please let me know if I missed anything!

Speaking of, how do I run automated tests on this branch?

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

@Copilot Copilot AI review requested due to automatic review settings May 5, 2025 22:38
@clintval clintval requested a review from a team as a code owner May 5, 2025 22:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds caching support for the Mill build tool, expanding the action’s compatibility with popular JVM build tools.

  • Adds Mill as a supported package manager with appropriate cache paths and file patterns in the source code.
  • Introduces tests for Mill caching behaviors (error throwing, cache restoration consistency, etc.).
  • Updates the documentation and end-to-end workflow to include examples and tests for Mill caching.

Reviewed Changes

Copilot reviewed 5 out of 9 changed files in this pull request and generated 1 comment.

File Description
src/cache.ts Adds Mill caching support to the PackageManager interface and supported array.
tests/cache.test.ts Implements unit tests to verify Mill caching behavior.
README.md Updates docs to include Mill as a supported package manager and usage examples.
.github/workflows/e2e-cache.yml Adds e2e test workflow steps for saving/restoring Mill cache across OSes.
Files not reviewed (4)
  • tests/cache/mill/.gitignore: Language not supported
  • tests/cache/mill/.mill-version: Language not supported
  • tests/cache/mill/build.sc: Language not supported
  • tests/cache/mill/mill: Language not supported

exit 1
fi
- name: Check files to cache on ubuntu-latest
if: matrix.os == 'ubuntu-latest'
Copy link
Author

Choose a reason for hiding this comment

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

I copied these patterns from above and notice a potential bug.

The matrix defines ubuntu-22.04 but the conditional here is still set to ubuntu-latest. I imagine this was not intentional. Is there a reason to pin to 22.04? If not, I'd vote reverting back to ubuntu-latest all over.

java-version: '11'
cache: mill
- name: Create files to cache
run: ./mill --disable-ticker _.compile
Copy link

Choose a reason for hiding this comment

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

_.compile is probably wrong (should be __.compile), but we should make this warmup command somethign the user passes in. Some users may want to cache jars, assemblies, or other artifacts beyond just plain compilation

Copy link
Author

@clintval clintval May 7, 2025

Choose a reason for hiding this comment

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

Thanks for reviewing @lihaoyi!

_.compile should be OK here since this is just an integration for a tiny test Scala project:

package build
import mill._, scalalib._
object MyProject extends ScalaModule {
def scalaVersion = "2.13.11"
def ivyDeps = Agg(ivy"com.lihaoyi::mainargs:0.6.2")
object test extends ScalaTests {
def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
}
}

I could change it to __.compile for safety-sake anyway, though.

And this isn't where the magic happens since these are just tests for this project.

The default caching behavior is set to:

setup-java/src/cache.ts

Lines 64 to 78 in 18d114c

{
id: 'mill',
path: [
join(os.homedir(), '.cache', 'mill')
],
pattern: [
// https://github.com/coursier/cache-action/blob/4e2615869d13561d626ed48655e1a39e5b192b3c/README.md?plain=1#L28-L38
'**/build.sc',
'**/*.sc',
'**/mill',
'**/.mill-version',
// https://github.com/com-lihaoyi/mill/blob/5b88d1e268e6264e44589c5ac82c0fdbd680fd63/mill#L6-L11
'**/.config/mill-version'
]
}

So that anything under ~/.cache/mill is cached.

The GitHub Action cache is rebuilt if anything in these patterns changes:

pattern: [
  // https://github.com/coursier/cache-action/blob/4e2615869d13561d626ed48655e1a39e5b192b3c/README.md?plain=1#L28-L38
  '**/build.sc',
  '**/*.sc',
  '**/mill',
  '**/.mill-version',
  // https://github.com/com-lihaoyi/mill/blob/5b88d1e268e6264e44589c5ac82c0fdbd680fd63/mill#L6-L11
  '**/.config/mill-version'
]

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.

2 participants