Skip to content

Commit 174eb2a

Browse files
committed
feat: use absolute paths by default when using working-directory option
1 parent a3942e2 commit 174eb2a

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ jobs:
5454
with:
5555
go-version: stable
5656
- name: golangci-lint
57-
uses: golangci/golangci-lint-action@v7
57+
uses: golangci/golangci-lint-action@v8
5858
with:
59-
version: v2.0
59+
version: v2.1
6060
```
6161
6262
</details>
@@ -92,9 +92,9 @@ jobs:
9292
with:
9393
go-version: ${{ matrix.go }}
9494
- name: golangci-lint
95-
uses: golangci/golangci-lint-action@v7
95+
uses: golangci/golangci-lint-action@v8
9696
with:
97-
version: v2.0
97+
version: v2.1
9898
```
9999
100100
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
@@ -120,7 +120,7 @@ on:
120120
121121
env:
122122
GO_VERSION: stable
123-
GOLANGCI_LINT_VERSION: v2.0
123+
GOLANGCI_LINT_VERSION: v2.1
124124
125125
jobs:
126126
detect-modules:
@@ -147,7 +147,7 @@ jobs:
147147
with:
148148
go-version: ${{ env.GO_VERSION }}
149149
- name: golangci-lint ${{ matrix.modules }}
150-
uses: golangci/golangci-lint-action@v7
150+
uses: golangci/golangci-lint-action@v8
151151
with:
152152
version: ${{ env.GOLANGCI_LINT_VERSION }}
153153
working-directory: ${{ matrix.modules }}
@@ -179,7 +179,7 @@ jobs:
179179
with:
180180
os: ${{ matrix.os }}
181181
go-version: ${{ matrix.go-version }}
182-
golangci-lint-version: v2.0
182+
golangci-lint-version: v2.1
183183
```
184184

185185
```yaml
@@ -201,7 +201,7 @@ on:
201201
golangci-lint-version:
202202
description: 'Golangci-lint version'
203203
type: string
204-
default: 'v2.0'
204+
default: 'v2.1'
205205
206206
jobs:
207207
detect-modules:
@@ -229,7 +229,7 @@ jobs:
229229
with:
230230
go-version: ${{ inputs.go-version }}
231231
- name: golangci-lint ${{ matrix.modules }}
232-
uses: golangci/golangci-lint-action@v7
232+
uses: golangci/golangci-lint-action@v8
233233
with:
234234
version: ${{ inputs.golangci-lint-version }}
235235
working-directory: ${{ matrix.modules }}
@@ -245,6 +245,7 @@ You will also likely need to add the following `.gitattributes` file to ensure t
245245

246246
## Compatibility
247247

248+
* `v8.0.0` works with `golangci-lint` version >= `v2.1.0`
248249
* `v7.0.0` supports golangci-lint v2 only.
249250
* `v6.0.0+` removes `annotations` option, removes the default output format (`github-actions`).
250251
* `v5.0.0+` removes `skip-pkg-cache` and `skip-build-cache` because the cache related to Go itself is already handled by `actions/setup-go`.
@@ -271,9 +272,9 @@ When `install-mode` is:
271272
<summary>Example</summary>
272273

273274
```yml
274-
uses: golangci/golangci-lint-action@v7
275+
uses: golangci/golangci-lint-action@v8
275276
with:
276-
version: v2.0
277+
version: v2.1
277278
# ...
278279
```
279280

@@ -291,7 +292,7 @@ The default value is `binary`.
291292
<summary>Example</summary>
292293

293294
```yml
294-
uses: golangci/golangci-lint-action@v7
295+
uses: golangci/golangci-lint-action@v8
295296
with:
296297
install-mode: "goinstall"
297298
# ...
@@ -311,7 +312,7 @@ By default, it uses the `github.token` from the action.
311312
<summary>Example</summary>
312313

313314
```yml
314-
uses: golangci/golangci-lint-action@v7
315+
uses: golangci/golangci-lint-action@v8
315316
with:
316317
github-token: xxx
317318
# ...
@@ -334,7 +335,7 @@ The JSON Schema used to validate the configuration depends on the version of gol
334335
<summary>Example</summary>
335336

336337
```yml
337-
uses: golangci/golangci-lint-action@v7
338+
uses: golangci/golangci-lint-action@v8
338339
with:
339340
verify: false
340341
# ...
@@ -359,7 +360,7 @@ The default value is `false`.
359360
<summary>Example</summary>
360361

361362
```yml
362-
uses: golangci/golangci-lint-action@v7
363+
uses: golangci/golangci-lint-action@v8
363364
with:
364365
only-new-issues: true
365366
# ...
@@ -377,7 +378,7 @@ Working directory, useful for monorepos.
377378
<summary>Example</summary>
378379

379380
```yml
380-
uses: golangci/golangci-lint-action@v7
381+
uses: golangci/golangci-lint-action@v8
381382
with:
382383
working-directory: somedir
383384
# ...
@@ -402,7 +403,7 @@ golangci-lint command line arguments.
402403
<summary>Example</summary>
403404

404405
```yml
405-
uses: golangci/golangci-lint-action@v7
406+
uses: golangci/golangci-lint-action@v8
406407
with:
407408
# In some rare cases,
408409
# you could have to use `${{ github.workspace }}` as base directory to reference your configuration file.
@@ -430,7 +431,7 @@ The default value is `false`.
430431
<summary>Example</summary>
431432

432433
```yml
433-
uses: golangci/golangci-lint-action@v7
434+
uses: golangci/golangci-lint-action@v8
434435
with:
435436
problem-matchers: true
436437
# ...
@@ -451,7 +452,7 @@ The default value is `false`.
451452
<summary>Example</summary>
452453

453454
```yml
454-
uses: golangci/golangci-lint-action@v7
455+
uses: golangci/golangci-lint-action@v8
455456
with:
456457
skip-cache: true
457458
# ...
@@ -471,7 +472,7 @@ The default value is `false`.
471472
<summary>Example</summary>
472473

473474
```yml
474-
uses: golangci/golangci-lint-action@v7
475+
uses: golangci/golangci-lint-action@v8
475476
with:
476477
skip-save-cache: true
477478
# ...
@@ -493,7 +494,7 @@ If the number is `<= 0`, the cache will always be invalidated (Not recommended).
493494
<summary>Example</summary>
494495

495496
```yml
496-
uses: golangci/golangci-lint-action@v7
497+
uses: golangci/golangci-lint-action@v8
497498
with:
498499
cache-invalidation-interval: 15
499500
# ...

src/run.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
123123
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
124124
throw new Error(`working-directory (${workingDirectory}) was not a path`)
125125
}
126-
if (!userArgNames.has(`path-prefix`)) {
127-
addedArgs.push(`--path-prefix=${workingDirectory}`)
126+
127+
if (!userArgNames.has(`path-prefix`) && !userArgNames.has(`path-mode`)) {
128+
addedArgs.push(`--path-mode=abs`)
128129
}
130+
129131
cmdArgs.cwd = path.resolve(workingDirectory)
130132
}
131133

src/version.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const parseVersion = (s: string): Version => {
2626
}
2727

2828
if (parseInt(match[1]) !== 2) {
29-
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action v7.`)
29+
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action >= v7.`)
3030
}
3131

3232
return {
@@ -45,7 +45,7 @@ export const stringifyVersion = (v: Version): string => {
4545

4646
const minVersion = {
4747
major: 2,
48-
minor: 0,
48+
minor: 1,
4949
patch: 0,
5050
}
5151

@@ -60,7 +60,7 @@ const isLessVersion = (a: Version, b: Version): boolean => {
6060
return a.major < b.major
6161
}
6262

63-
// Do not compare patch parts because if the min version has a non zero value
63+
// Do not compare patch parts because if the min version has a non-zero value
6464
// then it returns false, since the patch version of requested is always zero
6565
return a.minor < b.minor
6666
}

0 commit comments

Comments
 (0)