-
-
Notifications
You must be signed in to change notification settings - Fork 19
fix: automatic bazelisk installation when not available #84
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
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ const cache = require('@actions/cache') | |
| const github = require('@actions/github') | ||
| const glob = require('@actions/glob') | ||
| const tc = require('@actions/tool-cache') | ||
| const exec = require('@actions/exec') | ||
| const config = require('./config') | ||
|
|
||
| async function run() { | ||
|
|
@@ -32,7 +33,12 @@ async function setupBazel() { | |
|
|
||
| async function setupBazelisk() { | ||
| if (config.bazeliskVersion.length == 0) { | ||
| return | ||
| if (await isBazelAvailable()) { | ||
| core.info('Bazel or Bazelisk already available, skipping installation') | ||
| return | ||
| } | ||
| core.info('No bazelisk-version specified and bazel/bazelisk not found. Installing bazelisk v1.26.0.') | ||
| config.bazeliskVersion = 'v1.26.0' | ||
|
Member
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. What do you think if we use
Author
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 put in a specific version (the latest one) to avoid you getting potential bug reports for new behaviour if they release a new version that's broken or similar. They're usually very annoying to chase down. But if you trust upstream's release process enough to not land you in that situation, I can definitely change it. :) |
||
| } | ||
|
|
||
| core.startGroup('Setup Bazelisk') | ||
|
|
@@ -46,6 +52,20 @@ async function setupBazelisk() { | |
| core.endGroup() | ||
| } | ||
|
|
||
| async function isBazelAvailable() { | ||
| try { | ||
| await exec.exec('bazelisk', ['version'], { silent: true }) | ||
| return true | ||
| } catch (error) { | ||
| try { | ||
| await exec.exec('bazel', ['version'], { silent: true }) | ||
| return true | ||
| } catch (error) { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async function downloadBazelisk() { | ||
| const version = config.bazeliskVersion | ||
| core.debug(`Attempting to download ${version}`) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
I might be picky, but this would actually start downloading the bazel and extracting it. Maybe we should instead use
which bazeland Windows-equivalent to avoid expensive download/extract operations.