Skip to content

Commit 37037d3

Browse files
authored
Add instructions for multi-os linting (#86)
* Add instructions for multi-os linting Added a matrix to show how to do multi-os lint builds. This is specifically needed if you have files like `_darwin.go` or `_windows.go`, etc. If you don't lint on that specific OS, then those files will NOT be linted. I also added a note about `.gitattributes` needing to have the line endings correctly checked out, otherwise linting will fail for formatting as well.
1 parent 9d250b4 commit 37037d3

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
steps:
3434
- uses: actions/checkout@v2
3535
- name: golangci-lint
36-
uses: golangci/golangci-lint-action@v1
36+
uses: golangci/golangci-lint-action@v2
3737
with:
3838
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
3939
version: v1.29
@@ -51,6 +51,50 @@ jobs:
5151
We recommend running this action in a job separate from other jobs (`go test`, etc)
5252
because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).
5353

54+
### Multiple OS Support
55+
56+
If you need to run linters for specific operating systems, you will need to use `v2` of the action. Here is a sample configuration file:
57+
58+
```yaml
59+
name: golangci-lint
60+
on:
61+
push:
62+
tags:
63+
- v*
64+
branches:
65+
- master
66+
pull_request:
67+
jobs:
68+
golangci:
69+
strategy:
70+
matrix:
71+
go-version: [1.15.x]
72+
os: [macos-latest, windows-latest]
73+
name: lint
74+
runs-on: ${{ matrix.os }}
75+
steps:
76+
- uses: actions/checkout@v2
77+
- name: golangci-lint
78+
uses: golangci/golangci-lint-action@v2
79+
with:
80+
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
81+
version: v1.29
82+
# Optional: working directory, useful for monorepos
83+
# working-directory: somedir
84+
85+
# Optional: golangci-lint command line arguments.
86+
# args: --issues-exit-code=0
87+
88+
# Optional: show only new issues if it's a pull request. The default value is `false`.
89+
# only-new-issues: true
90+
```
91+
92+
You will also likely need to add the following `.gitattributes` file to ensure that line endings for windows builds are properly formatted:
93+
94+
```.gitattributes
95+
*.go text eol=lf
96+
```
97+
5498
## Comments and Annotations
5599

56100
Currently, GitHub parses the action's output and creates [annotations](https://github.community/t5/GitHub-Actions/What-are-annotations/td-p/30770).

0 commit comments

Comments
 (0)