-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move linting to a Github action for better integration #30985
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: golangci-lint | ||
on: | ||
#push: | ||
# branches: | ||
# - main | ||
# - 8.* | ||
# - 7.17 | ||
pull_request: | ||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
pull-requests: read | ||
jobs: | ||
golangci: | ||
strategy: | ||
matrix: | ||
include: | ||
- GOOS: windows | ||
- GOOS: linux | ||
- GOOS: darwin | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Echo details | ||
env: | ||
GOOS: ${{ matrix.GOOS }} | ||
run: echo Go GOOS=$GOOS | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
# Uses Go version from the repository. | ||
- name: Read .go-version file | ||
id: goversion | ||
run: echo "::set-output name=version::$(cat .go-version)" | ||
|
||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: "${{ steps.goversion.outputs.version }}" | ||
|
||
- name: golangci-lint | ||
env: | ||
GOOS: ${{ matrix.GOOS }} | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: v1.44.2 | ||
|
||
# Give the job more time to execute. | ||
# Regarding `--whole-files`, the linter is supposed to support linting of changed a patch only but, | ||
# for some reason, it's very unreliable this way - sometimes it does not report any or some | ||
# issues without linting the whole files, so we have to use `--whole-files` | ||
# which can lead to some frustration from developers who would like to | ||
# fix a single line in an existing codebase and the linter would force them | ||
# into fixing all linting issues in the whole file instead | ||
args: --timeout=30m --whole-files | ||
|
||
# Optional: if set to true then the action will use pre-installed Go. | ||
skip-go-installation: true | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
only-new-issues: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only. | |
- Add gcp firestore metricset. {pull}29918[29918] | ||
- Added TESTING_FILEBEAT_FILEPATTERN option for filebeat module pytests {pull}30103[30103] | ||
- Add gcp dataproc metricset. {pull}30008[30008] | ||
- Add Github action for linting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is needed, we have not been filled any details in the changelog related to the CI/CD, if it helps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I put it there the last time I changed the CI. Since it's just for developers, I think it would not hurt. |
||
|
||
==== Deprecated | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rdner, is there any specific platform dependency while running golang-lint on windows and darwin? If so, I see down below the
runs-on: ubuntu-latest
, is that expected while running on windows/darwin too? I wonder if this matrix could be reduced to one OS (linux) if the outcome is the same for the other two platformsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v1v We have to run the linter against every platform (GOOS) we have any Go code for, otherwise any platform-specific code is not inspected and issues are not reported.
It does not matter on which OS it's running physically (
ubuntu-latest
), it's just an environment variable that tells the Go compiler which files to compile.For Darwin we have these:
For Windows we have these:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification! It makes totally sense now :)