Skip to content

Commit

Permalink
feat: restrict action v6 on golangci-lint v1 (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic Fernandez authored and GitHub committed Mar 12, 2025
1 parent 7e7b516 commit 2ee514f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
17 changes: 12 additions & 5 deletions dist/post_run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions dist/run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 16 additions & 5 deletions src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/

const parseVersion = (s: string): Version => {
if (s == "latest" || s == "") {
// TODO(ldez): it should be replaced with an explicit version (ex: v1.64.0)
return null
// TODO(ldez): v2: it should be replaced with "return null"
return { major: 1, minor: 64, patch: 7 }
}

const match = s.match(versionRe)
if (!match) {
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 {
major: parseInt(match[1]),
minor: parseInt(match[2]),
Expand Down Expand Up @@ -115,7 +122,6 @@ const fetchVersionMapping = async (): Promise<VersionMapping> => {
maxRetries: 5,
})
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 response: httpm.HttpClientResponse = await http.get(url)
if (response.message.statusCode !== 200) {
Expand All @@ -134,8 +140,13 @@ export async function getVersion(mode: InstallMode): Promise<VersionInfo> {

if (mode == InstallMode.GoInstall) {
const v: string = core.getInput(`version`)
// TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0).
return { TargetVersion: v ? v : "latest" }
// TODO(ldez): v2: to remove.
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()
Expand Down

0 comments on commit 2ee514f

Please sign in to comment.