Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add golang-ci-lint #402

wants to merge 1 commit into from

Conversation

outscale-hmi
Copy link
Contributor

No description provided.

Signed-off-by: hanenMizouni <[email protected]>
${{ runner.os }}-go-

# Step 4: Install golangci-lint (if not already cached)
- name: Install golangci-lint
Copy link

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

Copy link

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
Copy link

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

Copy link
Contributor Author

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:

Copy link

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'

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants