Skip to content

Commit

Permalink
Create a separate module for our golangci-lint version (#80)
Browse files Browse the repository at this point in the history
## Summary:
In principle, it's not a problem to have test-only deps in your go.mod,
because they won't end up in your importers' builds (and in newer Go
versions may not even be downloaded.  (Which is why there's no
annotation to do so.)  In practice, that doesn't really work for
golangci-lint, because it doesn't really use semver (reasonably, in that
any updated linter may break lint in your codebase).  And we don't
really need it other than to run the binary at a particular version.

So now, I put it in its own go module.  This requires a bit more
throat-clearing to run it (we can't just `go run`), but it's not so bad
and avoids anyone getting annoyed at us because we upgraded their
golangci-lint for them.

We could do the same for `internal/integration`, which adds quite a lot,
including gqlgen, to our dependency tree, but it's not clear there's a
need.

Fixes #62.

Issue: #62

## Test plan:
make check


Author: benjaminjkraft

Reviewers: dnerdy, StevenACoffman, benjaminjkraft, aberkan, MiguelCastillo

Required Reviewers: 

Approved By: dnerdy, StevenACoffman

Checks: ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Test (1.13), ✅ Lint, ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Test (1.13), ✅ Lint

Pull Request URL: #80
  • Loading branch information
benjaminjkraft authored Sep 9, 2021
1 parent 6c86eed commit 1c061b1
Show file tree
Hide file tree
Showing 9 changed files with 1,231 additions and 1,161 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: Run lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.42 # should match go.mod
version: v1.42 # should match internal/lint/go.mod
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
generate/testdata/tmp
internal/lint/golangci-lint

## Go standard gitignore
# Binaries for programs and plugins
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ example:
go generate ./...
go run ./example/cmd/example/main.go

check:
go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./...
lint:
( cd internal/lint && go build -o golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint )
internal/lint/golangci-lint run ./...

check: lint
go test -cover ./...
go mod tidy

genqlient.png: genqlient.svg
convert -density 600 -background transparent "$<" "$@"
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ go 1.13
require (
github.com/99designs/gqlgen v0.13.0
github.com/bradleyjkemp/cupaloy/v2 v2.6.0
// Should match golangci-lint version in .github/workflows/go.yml
github.com/golangci/golangci-lint v1.42.0
github.com/stretchr/testify v1.7.0
github.com/vektah/gqlparser/v2 v2.1.0
golang.org/x/tools v0.1.5
Expand Down
1,150 changes: 7 additions & 1,143 deletions go.sum

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions internal/lint/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module github.com/Khan/genqlient/internal/lint

go 1.14

// Should match golangci-lint version in .github/workflows/go.yml
require github.com/golangci/golangci-lint v1.42.0
1,202 changes: 1,202 additions & 0 deletions internal/lint/go.sum

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions internal/lint/tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Package lint exists to pin a version of golangci-lint, but to keep it out of
// our main go.mod. This is useful because end-users typically want to pin
// their own version of golangci-lint (since any new lint check may fail on
// their codebase) but go mod doesn't really like doing that. Luckily, we only
// need it for lint, so we just put it in a separate module.
package lint

import _ "github.com/golangci/golangci-lint/cmd/golangci-lint"
13 changes: 0 additions & 13 deletions internal/testutil/tools.go

This file was deleted.

0 comments on commit 1c061b1

Please sign in to comment.