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

Install SBT on self-hosted gha runners V2 #11

Merged
merged 2 commits into from
Oct 23, 2024
Merged

Conversation

zarthross
Copy link
Contributor

  • Downloads the sbt tar file to $RUNNER_TEMP/_sbt
  • Extracts the sbt files to $RUNNER_TOOL_CACHE/sbt/version
  • Check the tool cache for sbt before bothering to pull it from the cache or download it.
  • Check the actions/cache if its not in the tool cache.

- Downloads the sbt tar file to `$RUNNER_TEMP/_sbt`
- Extracts the sbt files to `$RUNNER_TOOL_CACHE/sbt/version`
- Check the tool cache for sbt before bothering to pull it from the
  cache or download it.
- Check the actions/cache if its not in the tool cache.
Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Thanks!

action.yml Outdated Show resolved Hide resolved
action.yml Show resolved Hide resolved
@mzuehlke
Copy link
Contributor

As the logic here gets more complex, it may be less error prone to write an action Javascript and use (and not reimplement) the tool-cache library: https://docs.github.com/en/actions/sharing-automations/creating-actions/developing-a-third-party-cli-action

@eed3si9n
Copy link
Member

I would like to hold off on using JavaScript as much as possible because I don't understand it.

Instead of caching the download path, we cache directly the toolpath.
We continue first checking that the sbt installation is not already on
the toolpath where we would expect it to be.

Additionally, this combines the install and download phases since we
don't cache the download sbt dir, but the tooldir anymore anyways.
uses: actions/cache@v4
with:
path: ${{ steps.cache-paths.outputs.setupsbt_path }}
key: ${{ runner.os }}-sbt-${{ inputs.sbt-runner-version }}-1.1.1
path: ${{ steps.cache-paths.outputs.sbt_toolpath }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: because the $RUNNER_TOOL_CACHE path can be different between self-hosted and hosted runners, they may not be able to share this cache (actions/cache uses the paths in the cache key), but have separate caches. In practice I don't think this matters because of how fast the curl is, and how few different versions of sbt will need to be cached (its not like the cache between the build and test and publish on the typical sbt-typelevel project where its important to not rebuild the project).

Copy link
Contributor

@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.

Thanks for the detailed explanation, makes sense.

@eed3si9n eed3si9n merged commit 5fd9d0c into sbt:main Oct 23, 2024
6 checks passed
@zarthross zarthross deleted the cached branch October 23, 2024 13:03
@zarthross
Copy link
Contributor Author

Thank you!

@eed3si9n
Copy link
Member

@zarthross I pushed https://github.com/sbt/setup-sbt/releases/tag/v1.1.2. Let us know if it worked in your environment.

@zarthross
Copy link
Contributor Author

Worked perfectly, thanks for your help and feedback!

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.

3 participants