feat: restrict action v6 on golangci-lint v1 (#1194)

This commit is contained in:
Ludovic Fernandez 2025-03-12 17:10:24 +01:00 committed by GitHub
parent 7e7b516e44
commit 2ee514f1f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 15 deletions

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

@ -93207,13 +93207,17 @@ const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/; const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/;
const parseVersion = (s) => { const parseVersion = (s) => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
// TODO(ldez): it should be replaced with an explicit version (ex: v1.64.0) // TODO(ldez): v2: it should be replaced with "return null"
return null; return { major: 1, minor: 64, patch: 7 };
} }
const match = s.match(versionRe); const match = s.match(versionRe);
if (!match) { if (!match) {
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`); throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`);
} }
// TODO(ldez): v2: to remove.
if (parseInt(match[1]) > 1) {
throw new Error(`invalid version string '${s}', golangci-lint v2 is not supported by golangci-lint-action v6, you must update to golangci-lint-action v7.`);
}
return { return {
major: parseInt(match[1]), major: parseInt(match[1]),
minor: parseInt(match[2]), minor: parseInt(match[2]),
@ -93277,7 +93281,6 @@ const fetchVersionMapping = async () => {
maxRetries: 5, maxRetries: 5,
}); });
try { try {
// TODO(ldez): HEAD should be replaced with an explicit version (ex: v1.64.0).
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`; const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`;
const response = await http.get(url); const response = await http.get(url);
if (response.message.statusCode !== 200) { if (response.message.statusCode !== 200) {
@ -93294,8 +93297,12 @@ async function getVersion(mode) {
core.info(`Finding needed golangci-lint version...`); core.info(`Finding needed golangci-lint version...`);
if (mode == install_1.InstallMode.GoInstall) { if (mode == install_1.InstallMode.GoInstall) {
const v = core.getInput(`version`); const v = core.getInput(`version`);
// TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0). // TODO(ldez): v2: to remove.
return { TargetVersion: v ? v : "latest" }; if (v == "latest") {
return { TargetVersion: "v1.64.7" };
}
// TODO(ldez): v2: "v1.64.7" should be replaced with "latest".
return { TargetVersion: v ? v : "v1.64.7" };
} }
const reqVersion = getRequestedVersion(); const reqVersion = getRequestedVersion();
// if the patched version is passed, just use it // if the patched version is passed, just use it

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

@ -93207,13 +93207,17 @@ const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/; const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/;
const parseVersion = (s) => { const parseVersion = (s) => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
// TODO(ldez): it should be replaced with an explicit version (ex: v1.64.0) // TODO(ldez): v2: it should be replaced with "return null"
return null; return { major: 1, minor: 64, patch: 7 };
} }
const match = s.match(versionRe); const match = s.match(versionRe);
if (!match) { if (!match) {
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`); throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`);
} }
// TODO(ldez): v2: to remove.
if (parseInt(match[1]) > 1) {
throw new Error(`invalid version string '${s}', golangci-lint v2 is not supported by golangci-lint-action v6, you must update to golangci-lint-action v7.`);
}
return { return {
major: parseInt(match[1]), major: parseInt(match[1]),
minor: parseInt(match[2]), minor: parseInt(match[2]),
@ -93277,7 +93281,6 @@ const fetchVersionMapping = async () => {
maxRetries: 5, maxRetries: 5,
}); });
try { try {
// TODO(ldez): HEAD should be replaced with an explicit version (ex: v1.64.0).
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`; const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`;
const response = await http.get(url); const response = await http.get(url);
if (response.message.statusCode !== 200) { if (response.message.statusCode !== 200) {
@ -93294,8 +93297,12 @@ async function getVersion(mode) {
core.info(`Finding needed golangci-lint version...`); core.info(`Finding needed golangci-lint version...`);
if (mode == install_1.InstallMode.GoInstall) { if (mode == install_1.InstallMode.GoInstall) {
const v = core.getInput(`version`); const v = core.getInput(`version`);
// TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0). // TODO(ldez): v2: to remove.
return { TargetVersion: v ? v : "latest" }; if (v == "latest") {
return { TargetVersion: "v1.64.7" };
}
// TODO(ldez): v2: "v1.64.7" should be replaced with "latest".
return { TargetVersion: v ? v : "v1.64.7" };
} }
const reqVersion = getRequestedVersion(); const reqVersion = getRequestedVersion();
// if the patched version is passed, just use it // if the patched version is passed, just use it

View File

@ -18,8 +18,8 @@ const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/
const parseVersion = (s: string): Version => { const parseVersion = (s: string): Version => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
// TODO(ldez): it should be replaced with an explicit version (ex: v1.64.0) // TODO(ldez): v2: it should be replaced with "return null"
return null return { major: 1, minor: 64, patch: 7 }
} }
const match = s.match(versionRe) const match = s.match(versionRe)
@ -27,6 +27,13 @@ const parseVersion = (s: string): Version => {
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`) throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`)
} }
// TODO(ldez): v2: to remove.
if (parseInt(match[1]) > 1) {
throw new Error(
`invalid version string '${s}', golangci-lint v2 is not supported by golangci-lint-action v6, you must update to golangci-lint-action v7.`
)
}
return { return {
major: parseInt(match[1]), major: parseInt(match[1]),
minor: parseInt(match[2]), minor: parseInt(match[2]),
@ -115,7 +122,6 @@ const fetchVersionMapping = async (): Promise<VersionMapping> => {
maxRetries: 5, maxRetries: 5,
}) })
try { try {
// TODO(ldez): HEAD should be replaced with an explicit version (ex: v1.64.0).
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json` const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`
const response: httpm.HttpClientResponse = await http.get(url) const response: httpm.HttpClientResponse = await http.get(url)
if (response.message.statusCode !== 200) { if (response.message.statusCode !== 200) {
@ -134,8 +140,13 @@ export async function getVersion(mode: InstallMode): Promise<VersionInfo> {
if (mode == InstallMode.GoInstall) { if (mode == InstallMode.GoInstall) {
const v: string = core.getInput(`version`) const v: string = core.getInput(`version`)
// TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0). // TODO(ldez): v2: to remove.
return { TargetVersion: v ? v : "latest" } if (v == "latest") {
return { TargetVersion: "v1.64.7" }
}
// TODO(ldez): v2: "v1.64.7" should be replaced with "latest".
return { TargetVersion: v ? v : "v1.64.7" }
} }
const reqVersion = getRequestedVersion() const reqVersion = getRequestedVersion()