Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103284,6 +103284,7 @@ const cache = __nccwpck_require__(5116)
const github = __nccwpck_require__(3228)
const glob = __nccwpck_require__(7206)
const tc = __nccwpck_require__(3472)
const exec = __nccwpck_require__(5236)
const config = __nccwpck_require__(700)

async function run() {
Expand Down Expand Up @@ -103311,7 +103312,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'
}

core.startGroup('Setup Bazelisk')
Expand All @@ -103325,6 +103331,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 })
Copy link
Member

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 bazel and Windows-equivalent to avoid expensive download/extract operations.

return true
} catch (error) {
return false
}
}
}

async function downloadBazelisk() {
const version = config.bazeliskVersion
core.debug(`Attempting to download ${version}`)
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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'
Copy link
Member

Choose a reason for hiding this comment

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

What do you think if we use 1.x instead?

Copy link
Author

Choose a reason for hiding this comment

The 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')
Expand All @@ -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}`)
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"@actions/cache": "^4.0.0",
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0",
"@actions/glob": "^0.5.0",
"@actions/tool-cache": "^2.0.1",
Expand Down