mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2026-02-18 13:41:50 +00:00
feat: use absolute paths by default when using working-directory option
This commit is contained in:
parent
16ece5e01d
commit
ef5dc4758d
4 changed files with 30 additions and 29 deletions
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
|
|
@ -54,8 +54,8 @@ jobs:
|
||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v2.0"
|
- "v2.1"
|
||||||
- "v2.0.0"
|
- "v2.1.0"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
@ -83,8 +83,8 @@ jobs:
|
||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v2.0.0"
|
- "v2.1.0"
|
||||||
- "1f032fbc4b117e4247b19ff606cc847ab5383bc9"
|
- "f6c2e6c999dfae444d1fe7f1b0d49becdae44547"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
|
||||||
39
README.md
39
README.md
|
|
@ -54,9 +54,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: stable
|
go-version: stable
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
version: v2.0
|
version: v2.1
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
@ -92,9 +92,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
version: v2.0
|
version: v2.1
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
|
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:
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- name: golangci-lint ${{ matrix.modules }}
|
- name: golangci-lint ${{ matrix.modules }}
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
||||||
working-directory: ${{ matrix.modules }}
|
working-directory: ${{ matrix.modules }}
|
||||||
args: --path-mode=abs
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
@ -230,11 +229,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: ${{ inputs.go-version }}
|
go-version: ${{ inputs.go-version }}
|
||||||
- name: golangci-lint ${{ matrix.modules }}
|
- name: golangci-lint ${{ matrix.modules }}
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.golangci-lint-version }}
|
version: ${{ inputs.golangci-lint-version }}
|
||||||
working-directory: ${{ matrix.modules }}
|
working-directory: ${{ matrix.modules }}
|
||||||
args: --path-mode=abs
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
|
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
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
|
* `v8.0.0` works with `golangci-lint` version >= `v2.1.0`
|
||||||
* `v7.0.0` supports golangci-lint v2 only.
|
* `v7.0.0` supports golangci-lint v2 only.
|
||||||
* `v6.0.0+` removes `annotations` option, removes the default output format (`github-actions`).
|
* `v6.0.0+` removes `annotations` option, removes the default output format (`github-actions`).
|
||||||
* `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`.
|
* `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:
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
version: v2.0
|
version: v2.1
|
||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -293,7 +292,7 @@ The default value is `binary`.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
install-mode: "goinstall"
|
install-mode: "goinstall"
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -313,7 +312,7 @@ By default, it uses the `github.token` from the action.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
github-token: xxx
|
github-token: xxx
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -336,7 +335,7 @@ The JSON Schema used to validate the configuration depends on the version of gol
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
verify: false
|
verify: false
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -361,7 +360,7 @@ The default value is `false`.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -379,7 +378,7 @@ Working directory, useful for monorepos.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
working-directory: somedir
|
working-directory: somedir
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -404,7 +403,7 @@ golangci-lint command line arguments.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
# In some rare cases,
|
# In some rare cases,
|
||||||
# you could have to use `${{ github.workspace }}` as base directory to reference your configuration file.
|
# you could have to use `${{ github.workspace }}` as base directory to reference your configuration file.
|
||||||
|
|
@ -432,7 +431,7 @@ The default value is `false`.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
problem-matchers: true
|
problem-matchers: true
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -453,7 +452,7 @@ The default value is `false`.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
skip-cache: true
|
skip-cache: true
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -473,7 +472,7 @@ The default value is `false`.
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
skip-save-cache: true
|
skip-save-cache: true
|
||||||
# ...
|
# ...
|
||||||
|
|
@ -495,7 +494,7 @@ If the number is `<= 0`, the cache will always be invalidated (Not recommended).
|
||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
cache-invalidation-interval: 15
|
cache-invalidation-interval: 15
|
||||||
# ...
|
# ...
|
||||||
|
|
|
||||||
|
|
@ -123,9 +123,11 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
|
||||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||||
throw new Error(`working-directory (${workingDirectory}) was not a path`)
|
throw new Error(`working-directory (${workingDirectory}) was not a path`)
|
||||||
}
|
}
|
||||||
if (!userArgNames.has(`path-prefix`)) {
|
|
||||||
addedArgs.push(`--path-prefix=${workingDirectory}`)
|
if (!userArgNames.has(`path-prefix`) && !userArgNames.has(`path-mode`)) {
|
||||||
|
addedArgs.push(`--path-mode=abs`)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdArgs.cwd = path.resolve(workingDirectory)
|
cmdArgs.cwd = path.resolve(workingDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ const parseVersion = (s: string): Version => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(match[1]) !== 2) {
|
if (parseInt(match[1]) !== 2) {
|
||||||
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action v7.`)
|
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action >= v7.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -45,7 +45,7 @@ export const stringifyVersion = (v: Version): string => {
|
||||||
|
|
||||||
const minVersion = {
|
const minVersion = {
|
||||||
major: 2,
|
major: 2,
|
||||||
minor: 0,
|
minor: 1,
|
||||||
patch: 0,
|
patch: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ const isLessVersion = (a: Version, b: Version): boolean => {
|
||||||
return a.major < b.major
|
return a.major < b.major
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not compare patch parts because if the min version has a non zero value
|
// Do not compare patch parts because if the min version has a non-zero value
|
||||||
// then it returns false, since the patch version of requested is always zero
|
// then it returns false, since the patch version of requested is always zero
|
||||||
return a.minor < b.minor
|
return a.minor < b.minor
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue