From 17c0940b262488c102c3435cba680564c6fd4a5a Mon Sep 17 00:00:00 2001 From: bbernays Date: Wed, 21 Dec 2022 11:06:38 -0500 Subject: [PATCH 1/7] Update cache.ts --- src/cache.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cache.ts b/src/cache.ts index a06f33f5e6..ee59512e6e 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -50,14 +50,23 @@ const getIntervalKey = (invalidationIntervalDays: number): string => { return intervalNumber.toString() } + async function buildCacheKeys(): Promise { const keys = [] // Periodically invalidate a cache because a new code being added. // TODO: configure it via inputs. let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-` keys.push(cacheKey) + // Get working directory from input + const workingDirectory = core.getInput(`working-directory`) - if (await pathExists(`go.mod`)) { + if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { + throw new Error(`working-directory (${workingDirectory}) was not a path`) + } + // create path to go.mod prepending the workingDirectory if it exists + const goModPath = path.join(workingDirectory, `go.mod`) + + if (await pathExists(goModPath)) { // Add checksum to key to invalidate a cache when dependencies change. cacheKey += await checksumFile(`sha1`, `go.mod`) } else { From 760a14f2e2fb5f7ca5f885b58c036ce6e5e21c94 Mon Sep 17 00:00:00 2001 From: bbernays Date: Wed, 21 Dec 2022 11:48:45 -0500 Subject: [PATCH 2/7] Update cache.ts --- src/cache.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cache.ts b/src/cache.ts index ee59512e6e..b72c6b4cbd 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -65,7 +65,7 @@ async function buildCacheKeys(): Promise { } // 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. cacheKey += await checksumFile(`sha1`, `go.mod`) From d0df19561044bb1d8007229bbf56445c6c5aff1d Mon Sep 17 00:00:00 2001 From: bbernays Date: Wed, 21 Dec 2022 11:49:16 -0500 Subject: [PATCH 3/7] update build --- dist/post_run/index.js | 10 +++++++++- dist/run/index.js | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 5935ee4b1e..abe9daef36 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -67348,7 +67348,15 @@ function buildCacheKeys() { // TODO: configure it via inputs. let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`; keys.push(cacheKey); - if (yield pathExists(`go.mod`)) { + // Get working directory from input + const workingDirectory = core.getInput(`working-directory`); + if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { + throw new Error(`working-directory (${workingDirectory}) was not a path`); + } + // 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. cacheKey += yield checksumFile(`sha1`, `go.mod`); } diff --git a/dist/run/index.js b/dist/run/index.js index 9b9267c6e1..62433df27d 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -67348,7 +67348,15 @@ function buildCacheKeys() { // TODO: configure it via inputs. let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`; keys.push(cacheKey); - if (yield pathExists(`go.mod`)) { + // Get working directory from input + const workingDirectory = core.getInput(`working-directory`); + if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { + throw new Error(`working-directory (${workingDirectory}) was not a path`); + } + // 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. cacheKey += yield checksumFile(`sha1`, `go.mod`); } From e8fd730659c0ec8b6cc439dd872573fb481f95e0 Mon Sep 17 00:00:00 2001 From: bbernays Date: Wed, 21 Dec 2022 11:56:32 -0500 Subject: [PATCH 4/7] debug --- dist/post_run/index.js | 1 + dist/run/index.js | 1 + src/cache.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index abe9daef36..dc2dfe4f50 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -67350,6 +67350,7 @@ function buildCacheKeys() { keys.push(cacheKey); // Get working directory from input const workingDirectory = core.getInput(`working-directory`); + core.info(`working directory: ${workingDirectory}`); if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { throw new Error(`working-directory (${workingDirectory}) was not a path`); } diff --git a/dist/run/index.js b/dist/run/index.js index 62433df27d..35cf7f9859 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -67350,6 +67350,7 @@ function buildCacheKeys() { keys.push(cacheKey); // Get working directory from input const workingDirectory = core.getInput(`working-directory`); + core.info(`working directory: ${workingDirectory}`); if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { throw new Error(`working-directory (${workingDirectory}) was not a path`); } diff --git a/src/cache.ts b/src/cache.ts index b72c6b4cbd..3ede107bef 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -59,6 +59,7 @@ async function buildCacheKeys(): Promise { keys.push(cacheKey) // Get working directory from input const workingDirectory = core.getInput(`working-directory`) + core.info(`working directory: ${workingDirectory}`) if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { throw new Error(`working-directory (${workingDirectory}) was not a path`) From 89515350f42d00b264542dbd1afc850294534388 Mon Sep 17 00:00:00 2001 From: bbernays Date: Wed, 21 Dec 2022 12:00:58 -0500 Subject: [PATCH 5/7] use actual path --- dist/post_run/index.js | 3 +-- dist/run/index.js | 3 +-- src/cache.ts | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index dc2dfe4f50..d70c3f3c74 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -67350,7 +67350,6 @@ function buildCacheKeys() { keys.push(cacheKey); // Get working directory from input const workingDirectory = core.getInput(`working-directory`); - core.info(`working directory: ${workingDirectory}`); if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { throw new Error(`working-directory (${workingDirectory}) was not a path`); } @@ -67359,7 +67358,7 @@ function buildCacheKeys() { core.info(`Checking for go.mod: ${goModPath}`); if (yield pathExists(goModPath)) { // Add checksum to key to invalidate a cache when dependencies change. - cacheKey += yield checksumFile(`sha1`, `go.mod`); + cacheKey += yield checksumFile(`sha1`, goModPath); } else { cacheKey += `nogomod`; diff --git a/dist/run/index.js b/dist/run/index.js index 35cf7f9859..e8a2a924eb 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -67350,7 +67350,6 @@ function buildCacheKeys() { keys.push(cacheKey); // Get working directory from input const workingDirectory = core.getInput(`working-directory`); - core.info(`working directory: ${workingDirectory}`); if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { throw new Error(`working-directory (${workingDirectory}) was not a path`); } @@ -67359,7 +67358,7 @@ function buildCacheKeys() { core.info(`Checking for go.mod: ${goModPath}`); if (yield pathExists(goModPath)) { // Add checksum to key to invalidate a cache when dependencies change. - cacheKey += yield checksumFile(`sha1`, `go.mod`); + cacheKey += yield checksumFile(`sha1`, goModPath); } else { cacheKey += `nogomod`; diff --git a/src/cache.ts b/src/cache.ts index 3ede107bef..5616af44ca 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -59,8 +59,6 @@ async function buildCacheKeys(): Promise { keys.push(cacheKey) // Get working directory from input const workingDirectory = core.getInput(`working-directory`) - core.info(`working directory: ${workingDirectory}`) - if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { throw new Error(`working-directory (${workingDirectory}) was not a path`) } @@ -69,7 +67,7 @@ async function buildCacheKeys(): Promise { core.info(`Checking for go.mod: ${goModPath}`) if (await pathExists(goModPath)) { // Add checksum to key to invalidate a cache when dependencies change. - cacheKey += await checksumFile(`sha1`, `go.mod`) + cacheKey += await checksumFile(`sha1`, goModPath) } else { cacheKey += `nogomod` } From 5bc61c20c44089c41dd95f7d4dc45bcf7e4d8d59 Mon Sep 17 00:00:00 2001 From: bbernays Date: Wed, 21 Dec 2022 12:13:59 -0500 Subject: [PATCH 6/7] Update cache.ts --- src/cache.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/cache.ts b/src/cache.ts index 5616af44ca..06c9528b1b 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -59,9 +59,6 @@ async function buildCacheKeys(): Promise { keys.push(cacheKey) // Get working directory from input const workingDirectory = core.getInput(`working-directory`) - if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { - throw new Error(`working-directory (${workingDirectory}) was not a path`) - } // 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}`) From c828b74e205ae1c0cc751a6d11d203a599d6bb47 Mon Sep 17 00:00:00 2001 From: bbernays Date: Wed, 21 Dec 2022 12:14:19 -0500 Subject: [PATCH 7/7] build --- dist/post_run/index.js | 3 --- dist/run/index.js | 3 --- 2 files changed, 6 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index d70c3f3c74..068e04d303 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -67350,9 +67350,6 @@ function buildCacheKeys() { keys.push(cacheKey); // Get working directory from input const workingDirectory = core.getInput(`working-directory`); - if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { - throw new Error(`working-directory (${workingDirectory}) was not a path`); - } // 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}`); diff --git a/dist/run/index.js b/dist/run/index.js index e8a2a924eb..0bf7f5f9d4 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -67350,9 +67350,6 @@ function buildCacheKeys() { keys.push(cacheKey); // Get working directory from input const workingDirectory = core.getInput(`working-directory`); - if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { - throw new Error(`working-directory (${workingDirectory}) was not a path`); - } // 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}`);