-
-
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 1 commit
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 |
|---|---|---|
| @@ -1,12 +1,16 @@ | ||
| const fs = require('fs') | ||
| const { setTimeout } = require('timers/promises') | ||
| const { exec } = require('child_process') | ||
| const { promisify } = require('util') | ||
| const core = require('@actions/core') | ||
| const cache = require('@actions/cache') | ||
| const github = require('@actions/github') | ||
| const glob = require('@actions/glob') | ||
| const tc = require('@actions/tool-cache') | ||
| const config = require('./config') | ||
|
|
||
| const execAsync = promisify(exec) | ||
|
|
||
| async function run() { | ||
| try { | ||
| await setupBazel() | ||
|
|
@@ -32,7 +36,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 +55,20 @@ async function setupBazelisk() { | |
| core.endGroup() | ||
| } | ||
|
|
||
| async function isBazelAvailable() { | ||
| try { | ||
| await execAsync('bazelisk version') | ||
mikn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return true | ||
| } catch (error) { | ||
| try { | ||
| await execAsync('bazel version') | ||
| return true | ||
| } catch (error) { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async function downloadBazelisk() { | ||
| const version = config.bazeliskVersion | ||
| core.debug(`Attempting to download ${version}`) | ||
|
|
||
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.