parent
67f0a68f0e
commit
06441bbdcd
2 changed files with 16 additions and 15 deletions
27
index.js
27
index.js
|
|
@ -17,8 +17,8 @@ async function run() {
|
||||||
|
|
||||||
async function setupBazel() {
|
async function setupBazel() {
|
||||||
core.startGroup('Configure Bazel')
|
core.startGroup('Configure Bazel')
|
||||||
console.log('Configuration:')
|
core.info('Configuration:')
|
||||||
console.log(JSON.stringify(config, null, 2))
|
core.info(JSON.stringify(config, null, 2))
|
||||||
|
|
||||||
await setupBazelrc()
|
await setupBazelrc()
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
@ -36,18 +36,19 @@ async function setupBazelisk() {
|
||||||
}
|
}
|
||||||
|
|
||||||
core.startGroup('Setup Bazelisk')
|
core.startGroup('Setup Bazelisk')
|
||||||
const toolPath = tc.find('bazelisk', config.bazeliskVersion)
|
let toolPath = tc.find('bazelisk', config.bazeliskVersion)
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
console.log(`Found in cache @ ${toolPath}`)
|
core.debug(`Found in cache @ ${toolPath}`)
|
||||||
} else {
|
} else {
|
||||||
await downloadBazelisk()
|
toolPath = await downloadBazelisk()
|
||||||
}
|
}
|
||||||
|
core.addPath(toolPath)
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadBazelisk() {
|
async function downloadBazelisk() {
|
||||||
const version = config.bazeliskVersion
|
const version = config.bazeliskVersion
|
||||||
console.log(`Attempting to download ${version}`)
|
core.debug(`Attempting to download ${version}`)
|
||||||
|
|
||||||
// Possible values are 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x' and 'x64'.
|
// Possible values are 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x' and 'x64'.
|
||||||
// Bazelisk filenames use 'amd64' and 'arm64'.
|
// Bazelisk filenames use 'amd64' and 'arm64'.
|
||||||
|
|
@ -88,15 +89,15 @@ async function downloadBazelisk() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = asset.browser_download_url
|
const url = asset.browser_download_url
|
||||||
console.log(`Downloading from ${url}`)
|
core.debug(`Downloading from ${url}`)
|
||||||
const downloadPath = await tc.downloadTool(url, undefined, `token ${token}`)
|
const downloadPath = await tc.downloadTool(url, undefined, `token ${token}`)
|
||||||
|
|
||||||
console.log('Adding to the cache...');
|
core.debug('Adding to the cache...');
|
||||||
fs.chmodSync(downloadPath, '755');
|
fs.chmodSync(downloadPath, '755');
|
||||||
const cachePath = await tc.cacheFile(downloadPath, 'bazel', 'bazelisk', version)
|
const cachePath = await tc.cacheFile(downloadPath, 'bazel', 'bazelisk', version)
|
||||||
console.log(`Successfully cached bazelisk to ${cachePath}`)
|
core.debug(`Successfully cached bazelisk to ${cachePath}`)
|
||||||
|
|
||||||
core.addPath(cachePath)
|
return cachePath
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupBazelrc() {
|
async function setupBazelrc() {
|
||||||
|
|
@ -152,7 +153,7 @@ async function restoreCache(cacheConfig) {
|
||||||
const restoreKey = `${config.baseCacheKey}-${name}-`
|
const restoreKey = `${config.baseCacheKey}-${name}-`
|
||||||
const key = `${restoreKey}${hash}`
|
const key = `${restoreKey}${hash}`
|
||||||
|
|
||||||
console.log(`Attempting to restore ${name} cache from ${key}`)
|
core.debug(`Attempting to restore ${name} cache from ${key}`)
|
||||||
|
|
||||||
const restoredKey = await cache.restoreCache(
|
const restoredKey = await cache.restoreCache(
|
||||||
paths, key, [restoreKey],
|
paths, key, [restoreKey],
|
||||||
|
|
@ -160,13 +161,13 @@ async function restoreCache(cacheConfig) {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (restoredKey) {
|
if (restoredKey) {
|
||||||
console.log(`Successfully restored cache from ${restoredKey}`)
|
core.info(`Successfully restored cache from ${restoredKey}`)
|
||||||
|
|
||||||
if (restoredKey === key) {
|
if (restoredKey === key) {
|
||||||
core.saveState(`${name}-cache-hit`, 'true')
|
core.saveState(`${name}-cache-hit`, 'true')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`Failed to restore ${name} cache`)
|
core.info(`Failed to restore ${name} cache`)
|
||||||
}
|
}
|
||||||
|
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
|
||||||
4
post.js
4
post.js
|
|
@ -79,9 +79,9 @@ async function saveCache(cacheConfig) {
|
||||||
{ followSymbolicLinks: false }
|
{ followSymbolicLinks: false }
|
||||||
)
|
)
|
||||||
const key = `${config.baseCacheKey}-${cacheConfig.name}-${hash}`
|
const key = `${config.baseCacheKey}-${cacheConfig.name}-${hash}`
|
||||||
console.log(`Attempting to save ${paths} cache to ${key}`)
|
core.debug(`Attempting to save ${paths} cache to ${key}`)
|
||||||
await cache.saveCache(paths, key)
|
await cache.saveCache(paths, key)
|
||||||
console.log('Successfully saved cache')
|
core.info('Successfully saved cache')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.warning(error.stack)
|
core.warning(error.stack)
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue