feat: add option to control cache invalidation interval (#1031)

This commit is contained in:
Ludovic Fernandez
2024-05-04 17:47:25 +02:00
committed by GitHub
parent ecb32920c6
commit dbb7ebcd4c
5 changed files with 45 additions and 6 deletions

7
dist/post_run/index.js generated vendored
View File

@ -88815,15 +88815,18 @@ const getLintCacheDir = () => {
};
const getIntervalKey = (invalidationIntervalDays) => {
const now = new Date();
if (invalidationIntervalDays <= 0) {
return `${now.getTime()}`;
}
const secondsSinceEpoch = now.getTime() / 1000;
const intervalNumber = Math.floor(secondsSinceEpoch / (invalidationIntervalDays * 86400));
return intervalNumber.toString();
};
async function buildCacheKeys() {
const keys = [];
const invalidationIntervalDays = parseInt(core.getInput(`cache-invalidation-interval`, { required: true }).trim());
// Periodically invalidate a cache because a new code being added.
// TODO: configure it via inputs.
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`;
let cacheKey = `golangci-lint.cache-${getIntervalKey(invalidationIntervalDays)}-`;
keys.push(cacheKey);
// Get working directory from input
const workingDirectory = core.getInput(`working-directory`);

7
dist/run/index.js generated vendored
View File

@ -88815,15 +88815,18 @@ const getLintCacheDir = () => {
};
const getIntervalKey = (invalidationIntervalDays) => {
const now = new Date();
if (invalidationIntervalDays <= 0) {
return `${now.getTime()}`;
}
const secondsSinceEpoch = now.getTime() / 1000;
const intervalNumber = Math.floor(secondsSinceEpoch / (invalidationIntervalDays * 86400));
return intervalNumber.toString();
};
async function buildCacheKeys() {
const keys = [];
const invalidationIntervalDays = parseInt(core.getInput(`cache-invalidation-interval`, { required: true }).trim());
// Periodically invalidate a cache because a new code being added.
// TODO: configure it via inputs.
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`;
let cacheKey = `golangci-lint.cache-${getIntervalKey(invalidationIntervalDays)}-`;
keys.push(cacheKey);
// Get working directory from input
const workingDirectory = core.getInput(`working-directory`);