Compare commits

...

3 Commits

Author SHA1 Message Date
Ludovic Fernandez
82d40c283a feat: remove Go cache management (#1024) 2024-04-25 03:26:57 +02:00
Navneeth Jayendran
c683728f10 feat: add option to not save cache (#851) 2024-04-25 01:17:21 +00:00
Egor Kovetskiy
bf6479d5ec feat: add support for pull_request_target and only-new-issues (#506) 2024-04-25 03:03:53 +02:00
6 changed files with 22 additions and 79 deletions

View File

@@ -49,7 +49,7 @@ jobs:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54
version: v1.57
# Optional: working directory, useful for monorepos
# working-directory: somedir
@@ -67,11 +67,9 @@ jobs:
# takes precedence over all other caching options.
# skip-cache: true
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true
# Optional: if set to true, caches will not be saved, but they may still be restored,
# subject to other options
# skip-save-cache: true
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"

View File

@@ -29,12 +29,10 @@ inputs:
takes precedence over all other caching options.
default: 'false'
required: false
skip-pkg-cache:
description: "if set to true then the action doesn't cache or restore ~/go/pkg."
default: 'false'
required: false
skip-build-cache:
description: "if set to true then the action doesn't cache or restore ~/.cache/go-build."
skip-save-cache:
description: |
if set to true then the action will not save any caches, but it may still
restore existing caches, subject to other options.
default: 'false'
required: false
install-mode:

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

@@ -88813,25 +88813,6 @@ const pathExists = async (path) => !!(await fs.promises.stat(path).catch(() => f
const getLintCacheDir = () => {
return path_1.default.resolve(`${process.env.HOME}/.cache/golangci-lint`);
};
const getCacheDirs = () => {
// Not existing dirs are ok here: it works.
const skipPkgCache = core.getInput(`skip-pkg-cache`, { required: true }).trim();
const skipBuildCache = core.getInput(`skip-build-cache`, { required: true }).trim();
const dirs = [getLintCacheDir()];
if (skipBuildCache.toLowerCase() == "true") {
core.info(`Omitting ~/.cache/go-build from cache directories`);
}
else {
dirs.push(path_1.default.resolve(`${process.env.HOME}/.cache/go-build`));
}
if (skipPkgCache.toLowerCase() == "true") {
core.info(`Omitting ~/go/pkg from cache directories`);
}
else {
dirs.push(path_1.default.resolve(`${process.env.HOME}/go/pkg`));
}
return dirs;
};
const getIntervalKey = (invalidationIntervalDays) => {
const now = new Date();
const secondsSinceEpoch = now.getTime() / 1000;
@@ -88878,7 +88859,7 @@ async function restoreCache() {
}
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
try {
const cacheKey = await cache.restoreCache(getCacheDirs(), primaryKey, restoreKeys);
const cacheKey = await cache.restoreCache([getLintCacheDir()], primaryKey, restoreKeys);
if (!cacheKey) {
core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`);
return;
@@ -88900,13 +88881,15 @@ exports.restoreCache = restoreCache;
async function saveCache() {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true")
return;
if (core.getInput(`skip-save-cache`, { required: true }).trim() == "true")
return;
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
return;
}
const startedAt = Date.now();
const cacheDirs = getCacheDirs();
const cacheDirs = [getLintCacheDir()];
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
if (!primaryKey) {
utils.logWarning(`Error retrieving key from state.`);
@@ -89177,7 +89160,7 @@ async function fetchPatch() {
return ``;
}
const ctx = github.context;
if (ctx.eventName !== `pull_request`) {
if (ctx.eventName !== `pull_request` && ctx.eventName !== `pull_request_target`) {
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`);
return ``;
}

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

@@ -88813,25 +88813,6 @@ const pathExists = async (path) => !!(await fs.promises.stat(path).catch(() => f
const getLintCacheDir = () => {
return path_1.default.resolve(`${process.env.HOME}/.cache/golangci-lint`);
};
const getCacheDirs = () => {
// Not existing dirs are ok here: it works.
const skipPkgCache = core.getInput(`skip-pkg-cache`, { required: true }).trim();
const skipBuildCache = core.getInput(`skip-build-cache`, { required: true }).trim();
const dirs = [getLintCacheDir()];
if (skipBuildCache.toLowerCase() == "true") {
core.info(`Omitting ~/.cache/go-build from cache directories`);
}
else {
dirs.push(path_1.default.resolve(`${process.env.HOME}/.cache/go-build`));
}
if (skipPkgCache.toLowerCase() == "true") {
core.info(`Omitting ~/go/pkg from cache directories`);
}
else {
dirs.push(path_1.default.resolve(`${process.env.HOME}/go/pkg`));
}
return dirs;
};
const getIntervalKey = (invalidationIntervalDays) => {
const now = new Date();
const secondsSinceEpoch = now.getTime() / 1000;
@@ -88878,7 +88859,7 @@ async function restoreCache() {
}
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
try {
const cacheKey = await cache.restoreCache(getCacheDirs(), primaryKey, restoreKeys);
const cacheKey = await cache.restoreCache([getLintCacheDir()], primaryKey, restoreKeys);
if (!cacheKey) {
core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`);
return;
@@ -88900,13 +88881,15 @@ exports.restoreCache = restoreCache;
async function saveCache() {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true")
return;
if (core.getInput(`skip-save-cache`, { required: true }).trim() == "true")
return;
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
return;
}
const startedAt = Date.now();
const cacheDirs = getCacheDirs();
const cacheDirs = [getLintCacheDir()];
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
if (!primaryKey) {
utils.logWarning(`Error retrieving key from state.`);
@@ -89177,7 +89160,7 @@ async function fetchPatch() {
return ``;
}
const ctx = github.context;
if (ctx.eventName !== `pull_request`) {
if (ctx.eventName !== `pull_request` && ctx.eventName !== `pull_request_target`) {
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`);
return ``;
}

View File

@@ -23,26 +23,6 @@ const getLintCacheDir = (): string => {
return path.resolve(`${process.env.HOME}/.cache/golangci-lint`)
}
const getCacheDirs = (): string[] => {
// Not existing dirs are ok here: it works.
const skipPkgCache = core.getInput(`skip-pkg-cache`, { required: true }).trim()
const skipBuildCache = core.getInput(`skip-build-cache`, { required: true }).trim()
const dirs = [getLintCacheDir()]
if (skipBuildCache.toLowerCase() == "true") {
core.info(`Omitting ~/.cache/go-build from cache directories`)
} else {
dirs.push(path.resolve(`${process.env.HOME}/.cache/go-build`))
}
if (skipPkgCache.toLowerCase() == "true") {
core.info(`Omitting ~/go/pkg from cache directories`)
} else {
dirs.push(path.resolve(`${process.env.HOME}/go/pkg`))
}
return dirs
}
const getIntervalKey = (invalidationIntervalDays: number): string => {
const now = new Date()
const secondsSinceEpoch = now.getTime() / 1000
@@ -97,7 +77,7 @@ export async function restoreCache(): Promise<void> {
}
core.saveState(State.CachePrimaryKey, primaryKey)
try {
const cacheKey = await cache.restoreCache(getCacheDirs(), primaryKey, restoreKeys)
const cacheKey = await cache.restoreCache([getLintCacheDir()], primaryKey, restoreKeys)
if (!cacheKey) {
core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`)
return
@@ -116,6 +96,7 @@ export async function restoreCache(): Promise<void> {
export async function saveCache(): Promise<void> {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") return
if (core.getInput(`skip-save-cache`, { required: true }).trim() == "true") return
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
@@ -127,7 +108,7 @@ export async function saveCache(): Promise<void> {
const startedAt = Date.now()
const cacheDirs = getCacheDirs()
const cacheDirs = [getLintCacheDir()]
const primaryKey = core.getState(State.CachePrimaryKey)
if (!primaryKey) {
utils.logWarning(`Error retrieving key from state.`)

View File

@@ -32,7 +32,7 @@ async function fetchPatch(): Promise<string> {
}
const ctx = github.context
if (ctx.eventName !== `pull_request`) {
if (ctx.eventName !== `pull_request` && ctx.eventName !== `pull_request_target`) {
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`)
return ``
}