Integrate remote cache server for Bazel

This commit is contained in:
Alex Rodionov 2024-05-30 12:14:52 -07:00
parent 363eb36ada
commit b5e7d0a8af
5 changed files with 92 additions and 4 deletions

20
post.js
View file

@ -5,11 +5,31 @@ const core = require('@actions/core')
const glob = require('@actions/glob')
const config = require('./config')
const { getFolderSize } = require('./util')
const { execSync } = require('child_process')
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)