Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 24 additions & 1 deletion dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103279,13 +103279,17 @@ module.exports = /*#__PURE__*/JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45
var __webpack_exports__ = {};
const fs = __nccwpck_require__(9896)
const { setTimeout: index_setTimeout } = __nccwpck_require__(6460)
const { exec } = __nccwpck_require__(5317)
const { promisify } = __nccwpck_require__(9023)
const core = __nccwpck_require__(7484)
const cache = __nccwpck_require__(5116)
const github = __nccwpck_require__(3228)
const glob = __nccwpck_require__(7206)
const tc = __nccwpck_require__(3472)
const config = __nccwpck_require__(700)

const execAsync = promisify(exec)

async function run() {
try {
await setupBazel()
Expand All @@ -103311,7 +103315,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 +103334,20 @@ async function setupBazelisk() {
core.endGroup()
}

async function isBazelAvailable() {
try {
await execAsync('bazelisk version')
return 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.

} 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}`)
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion index.js
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()
Expand All @@ -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'
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 +55,20 @@ async function setupBazelisk() {
core.endGroup()
}

async function isBazelAvailable() {
try {
await execAsync('bazelisk version')
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}`)
Expand Down