Skip to content

Commit ef5dc47

Browse files
committed
feat: use absolute paths by default when using working-directory option
1 parent 16ece5e commit ef5dc47

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
version:
5555
- ""
5656
- "latest"
57-
- "v2.0"
58-
- "v2.0.0"
57+
- "v2.1"
58+
- "v2.1.0"
5959
runs-on: ${{ matrix.os }}
6060
permissions:
6161
contents: read
@@ -83,8 +83,8 @@ jobs:
8383
version:
8484
- ""
8585
- "latest"
86-
- "v2.0.0"
87-
- "1f032fbc4b117e4247b19ff606cc847ab5383bc9"
86+
- "v2.1.0"
87+
- "f6c2e6c999dfae444d1fe7f1b0d49becdae44547"
8888
runs-on: ${{ matrix.os }}
8989
permissions:
9090
contents: read

README.md

Lines changed: 19 additions & 20 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:
@@ -147,11 +147,10 @@ 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 }}
154-
args: --path-mode=abs
155154
```
156155

157156
</details>
@@ -230,11 +229,10 @@ jobs:
230229
with:
231230
go-version: ${{ inputs.go-version }}
232231
- name: golangci-lint ${{ matrix.modules }}
233-
uses: golangci/golangci-lint-action@v7
232+
uses: golangci/golangci-lint-action@v8
234233
with:
235234
version: ${{ inputs.golangci-lint-version }}
236235
working-directory: ${{ matrix.modules }}
237-
args: --path-mode=abs
238236
```
239237

240238
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
@@ -247,6 +245,7 @@ You will also likely need to add the following `.gitattributes` file to ensure t
247245

248246
## Compatibility
249247

248+
* `v8.0.0` works with `golangci-lint` version >= `v2.1.0`
250249
* `v7.0.0` supports golangci-lint v2 only.
251250
* `v6.0.0+` removes `annotations` option, removes the default output format (`github-actions`).
252251
* `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`.
@@ -273,9 +272,9 @@ When `install-mode` is:
273272
<summary>Example</summary>
274273

275274
```yml
276-
uses: golangci/golangci-lint-action@v7
275+
uses: golangci/golangci-lint-action@v8
277276
with:
278-
version: v2.0
277+
version: v2.1
279278
# ...
280279
```
281280

@@ -293,7 +292,7 @@ The default value is `binary`.
293292
<summary>Example</summary>
294293

295294
```yml
296-
uses: golangci/golangci-lint-action@v7
295+
uses: golangci/golangci-lint-action@v8
297296
with:
298297
install-mode: "goinstall"
299298
# ...
@@ -313,7 +312,7 @@ By default, it uses the `github.token` from the action.
313312
<summary>Example</summary>
314313

315314
```yml
316-
uses: golangci/golangci-lint-action@v7
315+
uses: golangci/golangci-lint-action@v8
317316
with:
318317
github-token: xxx
319318
# ...
@@ -336,7 +335,7 @@ The JSON Schema used to validate the configuration depends on the version of gol
336335
<summary>Example</summary>
337336

338337
```yml
339-
uses: golangci/golangci-lint-action@v7
338+
uses: golangci/golangci-lint-action@v8
340339
with:
341340
verify: false
342341
# ...
@@ -361,7 +360,7 @@ The default value is `false`.
361360
<summary>Example</summary>
362361

363362
```yml
364-
uses: golangci/golangci-lint-action@v7
363+
uses: golangci/golangci-lint-action@v8
365364
with:
366365
only-new-issues: true
367366
# ...
@@ -379,7 +378,7 @@ Working directory, useful for monorepos.
379378
<summary>Example</summary>
380379

381380
```yml
382-
uses: golangci/golangci-lint-action@v7
381+
uses: golangci/golangci-lint-action@v8
383382
with:
384383
working-directory: somedir
385384
# ...
@@ -404,7 +403,7 @@ golangci-lint command line arguments.
404403
<summary>Example</summary>
405404

406405
```yml
407-
uses: golangci/golangci-lint-action@v7
406+
uses: golangci/golangci-lint-action@v8
408407
with:
409408
# In some rare cases,
410409
# you could have to use `${{ github.workspace }}` as base directory to reference your configuration file.
@@ -432,7 +431,7 @@ The default value is `false`.
432431
<summary>Example</summary>
433432

434433
```yml
435-
uses: golangci/golangci-lint-action@v7
434+
uses: golangci/golangci-lint-action@v8
436435
with:
437436
problem-matchers: true
438437
# ...
@@ -453,7 +452,7 @@ The default value is `false`.
453452
<summary>Example</summary>
454453

455454
```yml
456-
uses: golangci/golangci-lint-action@v7
455+
uses: golangci/golangci-lint-action@v8
457456
with:
458457
skip-cache: true
459458
# ...
@@ -473,7 +472,7 @@ The default value is `false`.
473472
<summary>Example</summary>
474473

475474
```yml
476-
uses: golangci/golangci-lint-action@v7
475+
uses: golangci/golangci-lint-action@v8
477476
with:
478477
skip-save-cache: true
479478
# ...
@@ -495,7 +494,7 @@ If the number is `<= 0`, the cache will always be invalidated (Not recommended).
495494
<summary>Example</summary>
496495

497496
```yml
498-
uses: golangci/golangci-lint-action@v7
497+
uses: golangci/golangci-lint-action@v8
499498
with:
500499
cache-invalidation-interval: 15
501500
# ...

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)