Skip to content

Commit 2ee514f

Browse files
authored
feat: restrict action v6 on golangci-lint v1 (#1194)
1 parent 7e7b516 commit 2ee514f

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

dist/post_run/index.js

+12-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/run/index.js

+12-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/version.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/
1818

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

2525
const match = s.match(versionRe)
2626
if (!match) {
2727
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`)
2828
}
2929

30+
// TODO(ldez): v2: to remove.
31+
if (parseInt(match[1]) > 1) {
32+
throw new Error(
33+
`invalid version string '${s}', golangci-lint v2 is not supported by golangci-lint-action v6, you must update to golangci-lint-action v7.`
34+
)
35+
}
36+
3037
return {
3138
major: parseInt(match[1]),
3239
minor: parseInt(match[2]),
@@ -115,7 +122,6 @@ const fetchVersionMapping = async (): Promise<VersionMapping> => {
115122
maxRetries: 5,
116123
})
117124
try {
118-
// TODO(ldez): HEAD should be replaced with an explicit version (ex: v1.64.0).
119125
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`
120126
const response: httpm.HttpClientResponse = await http.get(url)
121127
if (response.message.statusCode !== 200) {
@@ -134,8 +140,13 @@ export async function getVersion(mode: InstallMode): Promise<VersionInfo> {
134140

135141
if (mode == InstallMode.GoInstall) {
136142
const v: string = core.getInput(`version`)
137-
// TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0).
138-
return { TargetVersion: v ? v : "latest" }
143+
// TODO(ldez): v2: to remove.
144+
if (v == "latest") {
145+
return { TargetVersion: "v1.64.7" }
146+
}
147+
148+
// TODO(ldez): v2: "v1.64.7" should be replaced with "latest".
149+
return { TargetVersion: v ? v : "v1.64.7" }
139150
}
140151

141152
const reqVersion = getRequestedVersion()

0 commit comments

Comments
 (0)