-
Notifications
You must be signed in to change notification settings - Fork 785
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,3 +207,93 @@ jobs: | |
exit 1 | ||
fi | ||
ls ~/.cache/coursier | ||
mill-save: | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: __tests__/cache/mill | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-13, windows-latest, ubuntu-22.04] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Run setup-java with the cache for mill | ||
uses: ./ | ||
id: setup-java | ||
with: | ||
distribution: 'adopt' | ||
java-version: '11' | ||
cache: mill | ||
- name: Create files to cache | ||
run: ./mill --disable-ticker _.compile | ||
|
||
- name: Check files to cache on macos-latest | ||
if: matrix.os == 'macos-13' | ||
run: | | ||
if [ ! -d ~/.cache/mill/download ]; then | ||
echo "::error::The ~/.cache/mill/download directory does not exist unexpectedly" | ||
exit 1 | ||
fi | ||
- name: Check files to cache on windows-latest | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
if [ ! -d %USERPROFILE%/.cache/mill/download ]; then | ||
echo "::error::The %USERPROFILE%/.cache/mill/download directory does not exist unexpectedly" | ||
exit 1 | ||
fi | ||
- name: Check files to cache on ubuntu-latest | ||
if: matrix.os == 'ubuntu-latest' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
run: | | ||
if [ ! -d ~/.cache/mill/download ]; then | ||
echo "::error::The ~/.cache/mill/download directory does not exist unexpectedly" | ||
exit 1 | ||
fi | ||
mill-restore: | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: __tests__/cache/mill | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-13, windows-latest, ubuntu-22.04] | ||
needs: mill-save | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Run setup-java with the cache for mill | ||
uses: ./ | ||
id: setup-java | ||
with: | ||
distribution: 'adopt' | ||
java-version: '11' | ||
cache: mill | ||
|
||
- name: Confirm that ~/.cache/mill/download directory has been made | ||
if: matrix.os == 'macos-13' | ||
run: | | ||
if [ ! -d ~/.cache/mill/download ]; then | ||
echo "::error::The ~/.cache/mill/download directory does not exist unexpectedly" | ||
exit 1 | ||
fi | ||
ls ~/.cache/mill/download | ||
- name: Confirm that %USERPROFILE%/.cache/mill/download directory has been made | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
if [ ! -d %USERPROFILE%/.cache/mill/download ]; then | ||
echo "::error::The %USERPROFILE%/.cache/mill/download directory does not exist unexpectedly" | ||
exit 1 | ||
fi | ||
ls %USERPROFILE%/.cache/mill/download | ||
- name: Confirm that ~/.cache/mill/download directory has been made | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
if [ ! -d ~/.cache/mill/download ]; then | ||
echo "::error::The ~/.cache/mill/download directory does not exist unexpectedly" | ||
exit 1 | ||
fi | ||
ls ~/.cache/mill/download |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
out/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.12.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env sh | ||
# This is a wrapper script that automatically downloads Mill from GitHub. | ||
set -e | ||
|
||
if [ -z "$MILL_VERSION" ] ; then | ||
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" | ||
fi | ||
|
||
MILL_DOWNLOAD_PATH="$HOME/.cache/mill/download" | ||
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION" | ||
|
||
if [ ! -x "$MILL_EXEC_PATH" ] ; then | ||
mkdir -p "${MILL_DOWNLOAD_PATH}" | ||
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download | ||
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION-assembly" | ||
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" | ||
chmod +x "$DOWNLOAD_FILE" | ||
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" | ||
unset DOWNLOAD_FILE | ||
unset MILL_DOWNLOAD_URL | ||
fi | ||
|
||
unset MILL_DOWNLOAD_PATH | ||
unset MILL_VERSION | ||
|
||
exec "${MILL_EXEC_PATH}" "$@" |
There was a problem hiding this comment.
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 compilationUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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:setup-java/__tests__/cache/mill/build.sc
Lines 1 to 12 in 18d114c
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
So that anything under
~/.cache/mill
is cached.The GitHub Action cache is rebuilt if anything in these patterns changes: