-
Notifications
You must be signed in to change notification settings - Fork 12
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
add golang-ci-lint #402
base: main
Are you sure you want to change the base?
add golang-ci-lint #402
Conversation
ed3ce32
to
996c7b8
Compare
996c7b8
to
118770c
Compare
Signed-off-by: hanenMizouni <[email protected]>
118770c
to
68f5991
Compare
${{ runner.os }}-go- | ||
|
||
# Step 4: Install golangci-lint (if not already cached) | ||
- name: Install golangci-lint |
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.
There is a golangci-lint action:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.62
# Optional: golangci-lint command line arguments.
args: --timeout=300s
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.
- add in the action:
only-new-issues: true
on: | ||
push: | ||
branches: | ||
- main |
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.
you can keep linting to pull requests
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.
the --new-from-rev=origin/main option in our golangci-lint command, which inherently limits linting to only the new changes since the main branch. This approach makes the linting process efficient regardless of whether the workflow is triggered by a push or a pull_request.
branches: | ||
- main | ||
pull_request: | ||
|
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.
You should add a filter to trigger the workflow on Go files
paths:
- 'go.mod'
- '**.go'
- '.github/workflows/golangci-lint.yaml'
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.
I am using the --new-from-rev=origin/main option in the golangci-lint workflow, which ensures that only changes introduced in the branch since origin/main are linted. This approach inherently limits linting to modified files, including Go files, without requiring an additional paths filter.
No description provided.