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

Unexpected error of golangci-lint by trunk check -a #869

Open
yu-iskw opened this issue Sep 12, 2024 · 2 comments
Open

Unexpected error of golangci-lint by trunk check -a #869

yu-iskw opened this issue Sep 12, 2024 · 2 comments

Comments

@yu-iskw
Copy link
Contributor

yu-iskw commented Sep 12, 2024

Overview

I got an unexpected violation of golangci-lint with a trunk check -a command.

Expected behavior

We don't the violation even with the -a option.

How to reproduce

I encountered the enexpected behavior, when I developed a terraform provider based on the scafolding framework.

https://github.com/hashicorp/terraform-provider-scaffolding-framework

Config file

version: 0.1
cli:
  version: 1.22.5
plugins:
  sources:
    - id: trunk
      ref: v1.6.2
      uri: https://github.com/trunk-io/plugins
runtimes:
  enabled:
    - [email protected]
    - [email protected]
    - [email protected]
lint:
  enabled:
    - [email protected]
actions:
  enabled:
    - trunk-announce
    - trunk-check-pre-push
    - trunk-fmt-pre-commit
    - trunk-upgrade-available

Commands

# Clone the 
git clone [email protected]:hashicorp/terraform-provider-scaffolding-framework.git

# Set up truk
trunk init

# Run trunk
## I got the violation with the `-a` option
$ trunk check -a
Checking 100% [=================================================================================================================>]  10/10  1.0s

  ISSUES

tools:0:0
 0:0  high  typechecking error: build constraints exclude all Go files in                                                    golangci-lint/error
            /Users/yu/local/src/github/terraform-provider-scaffolding-framework/tools

## I didn't get the violation by passing the root directly
$ trunk check .
Checking 100% [=================================================================================================================>]  10/10  1.0s

Checked 3 files
1 existing issue (use --show-existing to see it)
✔ No new issues

NOTE: behavior of golangci-lint

# I didn't get anything if passing the root directly
$ golangci-lint run .

# I got the same violation if speciflyng the 'tools' directory.
$ golangci-lint run tools/
ERRO [linters_context] typechecking error: build constraints exclude all Go files in /Users/yu/local/src/github/terraform-provider-scaffolding-framework/tools
@det
Copy link
Contributor

det commented Sep 12, 2024

Hi @yu-iskw,

I think you want to ignore the tools directory for go files by merging the following into your .trunk/trunk.yaml:

lint:
  ignore:
    - linters: [golangci-lint]
      paths: [tools/**]

@yu-iskw
Copy link
Contributor Author

yu-iskw commented Sep 13, 2024

@det Thank you for the advice. I tried that. But I encountered the violation as well. Is there anythong wrong I should fix?

Trunk command

I executed the subsequent trunk command with the config file below.

$ trunk check -a
Checking 100% [=================================================================================================================>]  10/10  0.9s

  ISSUES

tools:0:0
 0:0  high  typechecking error: build constraints exclude all Go files in                                                    golangci-lint/error
            /Users/yu/local/src/github/terraform-provider-scaffolding-framework/tools

Checked 3 files
✖ 1 lint issue

.trunk/trunk.yaml

version: 0.1
cli:
  version: 1.22.5
plugins:
  sources:
    - id: trunk
      ref: v1.6.2
      uri: https://github.com/trunk-io/plugins
runtimes:
  enabled:
    - [email protected]
    - [email protected]
    - [email protected]
lint:
  ignore:
    - linters: [golangci-lint]
      paths: [tools/**]
  enabled:
    - [email protected]
actions:
  enabled:
    - trunk-announce
    - trunk-check-pre-push
    - trunk-fmt-pre-commit
    - trunk-upgrade-available

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

No branches or pull requests

2 participants