Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed May 30, 2024
1 parent 8883487 commit ef78fd9
Show file tree
Hide file tree
Showing 7 changed files with 82,000 additions and 5 deletions.
29 changes: 26 additions & 3 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ module.exports = {
name: 'repository',
paths: [bazelRepository]
},
remoteCacheServer: {
enabled: true,
url: 'http://localhost:8080/cache',
logPath: `${os.tmpdir()}/remote-cache-server.log`,
}
}


Expand Down Expand Up @@ -96867,6 +96872,8 @@ const github = __nccwpck_require__(5438)
const glob = __nccwpck_require__(8090)
const tc = __nccwpck_require__(7784)
const config = __nccwpck_require__(5532)
const { fork } = __nccwpck_require__(2081)
const path = __nccwpck_require__(1017)

async function run() {
try {
Expand All @@ -96889,6 +96896,7 @@ async function setupBazel() {
await restoreCache(config.diskCache)
await restoreCache(config.repositoryCache)
await restoreExternalCaches(config.externalCache)
await startRemoteCacheServer()
}

async function setupBazelisk() {
Expand Down Expand Up @@ -96953,8 +96961,8 @@ async function downloadBazelisk() {
core.debug(`Downloading from ${url}`)
const downloadPath = await tc.downloadTool(url, undefined, `token ${token}`)

core.debug('Adding to the cache...');
fs.chmodSync(downloadPath, '755');
core.debug('Adding to the cache...')
fs.chmodSync(downloadPath, '755')
const cachePath = await tc.cacheFile(downloadPath, 'bazel', 'bazelisk', version)
core.debug(`Successfully cached bazelisk to ${cachePath}`)

Expand All @@ -96968,6 +96976,7 @@ async function setupBazelrc() {
`startup --output_base=${config.paths.bazelOutputBase}\n`
)
fs.appendFileSync(bazelrcPath, config.bazelrc.join("\n"))
fs.appendFileSync(bazelrcPath, `build --remote_cache=${config.remoteCacheServer.url}\n`)
}
}

Expand Down Expand Up @@ -97035,7 +97044,21 @@ async function restoreCache(cacheConfig) {
}())
}

run()
async function startRemoteCacheServer() {
core.startGroup("Remote cache server")

core.debug(`Remote cache server log file path: ${config.remoteCacheServer.logPath}`)
const log = fs.openSync(config.remoteCacheServer.logPath, 'a')
const serverProcess = fork(path.join(__dirname, 'dist', 'remote-cache-server', 'index.js'), [], {
detached: true,
stdio: ['ignore', log, log, 'ipc']
})
serverProcess.unref()

core.info(`Started remote cache server (${serverProcess.pid}`)
core.saveState('remote-cache-server-pid', serverProcess.pid.toString())
core.endGroup()
}

})();

Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ module.exports = {
name: 'repository',
paths: [bazelRepository]
},
remoteCacheServer: {
enabled: true,
url: 'http://localhost:8080/cache',
logPath: `${os.tmpdir()}/remote-cache-server.log`,
}
}


Expand Down Expand Up @@ -95935,11 +95940,31 @@ const core = __nccwpck_require__(2186)
const glob = __nccwpck_require__(8090)
const config = __nccwpck_require__(5532)
const { getFolderSize } = __nccwpck_require__(4962)
const { execSync } = __nccwpck_require__(2081)

async function run() {
await stopRemoteCacheServer()
await saveCaches()
}

async function stopRemoteCacheServer() {
const pid = core.getState('remote-cache-server-pid')
if (pid) {
try {
process.kill(pid, 'SIGTERM')
core.debug(`Stopped remote cache server with PID: ${pid}`)
} catch (error) {
core.error(`Failed to stop remote cache server with PID: ${pid}. Error: ${error}`)
}
}

const logPath = config.remoteCacheServer.logPath
if (fs.existsSync(logPath)) {
const logContent = fs.readFileSync(logPath, 'utf8')
core.debug(`Remote cache server log:\n${logContent}`)
}
}

async function saveCaches() {
await saveCache(config.bazeliskCache)
await saveCache(config.diskCache)
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit ef78fd9

Please sign in to comment.