add working-directory and build

This commit is contained in:
bbernays 2022-12-21 14:29:11 -05:00
parent 59f1813dc5
commit 58bce521b6
3 changed files with 21 additions and 7 deletions

View file

@ -67348,9 +67348,14 @@ function buildCacheKeys() {
// TODO: configure it via inputs. // TODO: configure it via inputs.
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`; let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`;
keys.push(cacheKey); keys.push(cacheKey);
if (yield pathExists(`go.mod`)) { // Get working directory from input
const workingDirectory = core.getInput(`working-directory`);
// create path to go.mod prepending the workingDirectory if it exists
const goModPath = path_1.default.join(workingDirectory, `go.mod`);
core.info(`Checking for go.mod: ${goModPath}`);
if (yield pathExists(goModPath)) {
// Add checksum to key to invalidate a cache when dependencies change. // Add checksum to key to invalidate a cache when dependencies change.
cacheKey += yield checksumFile(`sha1`, `go.mod`); cacheKey += yield checksumFile(`sha1`, goModPath);
} }
else { else {
cacheKey += `nogomod`; cacheKey += `nogomod`;

9
dist/run/index.js vendored
View file

@ -67348,9 +67348,14 @@ function buildCacheKeys() {
// TODO: configure it via inputs. // TODO: configure it via inputs.
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`; let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`;
keys.push(cacheKey); keys.push(cacheKey);
if (yield pathExists(`go.mod`)) { // Get working directory from input
const workingDirectory = core.getInput(`working-directory`);
// create path to go.mod prepending the workingDirectory if it exists
const goModPath = path_1.default.join(workingDirectory, `go.mod`);
core.info(`Checking for go.mod: ${goModPath}`);
if (yield pathExists(goModPath)) {
// Add checksum to key to invalidate a cache when dependencies change. // Add checksum to key to invalidate a cache when dependencies change.
cacheKey += yield checksumFile(`sha1`, `go.mod`); cacheKey += yield checksumFile(`sha1`, goModPath);
} }
else { else {
cacheKey += `nogomod`; cacheKey += `nogomod`;

View file

@ -56,10 +56,14 @@ async function buildCacheKeys(): Promise<string[]> {
// TODO: configure it via inputs. // TODO: configure it via inputs.
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-` let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`
keys.push(cacheKey) keys.push(cacheKey)
// Get working directory from input
if (await pathExists(`go.mod`)) { const workingDirectory = core.getInput(`working-directory`)
// create path to go.mod prepending the workingDirectory if it exists
const goModPath = path.join(workingDirectory, `go.mod`)
core.info(`Checking for go.mod: ${goModPath}`)
if (await pathExists(goModPath)) {
// Add checksum to key to invalidate a cache when dependencies change. // Add checksum to key to invalidate a cache when dependencies change.
cacheKey += await checksumFile(`sha1`, `go.mod`) cacheKey += await checksumFile(`sha1`, goModPath)
} else { } else {
cacheKey += `nogomod` cacheKey += `nogomod`
} }