Skip to content

Commit

Permalink
Merge pull request #714 from twpayne/improve-contributing
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Apr 28, 2020
2 parents 81bfc76 + 30a2b81 commit 70c4eda
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* [ ] I have followed the [contributing changes
section](https://github.com/twpayne/chezmoi/blob/master/docs/CONTRIBUTING.md#contributing-changes)
in the [contributing
guide](https://github.com/twpayne/chezmoi/blob/master/docs/CONTRIBUTING.md).
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*coverage.out
/bin
/bin/gofumports
/bin/golangci-lint
/chezmoi
/chezmoi.exe
/dist
34 changes: 33 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
linters:
enable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- gocritic
- godot
- gofmt
- goimports
- golint
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- misspell
- nakedret
- prealloc
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
disable:
- funlen
- gochecknoglobals
Expand Down
52 changes: 32 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
.PHONY: smoketest
smoketest:
go run . --version
go test ./...
./bin/golangci-lint run
GOLANGCI_LINT_VERSION=1.25.0

all: generate
.PHONY: default
default: generate run test lint format

.PHONY: format
format:
find . -name \*.go | xargs $$(go env GOPATH)/bin/gofumports -w

.PHONY: generate
.PHONT: generate
generate:
go generate

.PHONY: install-tools
install-tools:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- v1.25.0
( cd $$(mktemp -d) && go mod init tmp && go get mvdan.cc/gofumpt/gofumports )
.PHONY: run
run:
go run . --version

.PHONY: test
test:
go test -race ./...

.PHONY: lint
lint:
lint: ensure-golangci-lint
./bin/golangci-lint run

.PHONY: format
format: ensure-gofumports
find . -name \*.go | xargs ./bin/gofumports -w

.PHONY: ensure-tools
ensure-tools: ensure-gofumports ensure-golangci-lint

.PHONY: ensure-gofumports
ensure-gofumports:
if [[ ! -x bin/gofumports ]] ; then \
mkdir -p bin ; \
( cd $$(mktemp -d) && go mod init tmp && GOBIN=${PWD}/bin go get mvdan.cc/gofumpt/gofumports ) ; \
fi

.PHONY: ensure-golangci-lint
ensure-golangci-lint:
if [[ ! -x bin/golangci-lint ]] || ( ./bin/golangci-lint --version | grep -Fqv "version ${GOLANGCI_LINT_VERSION}" ) ; then \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- v${GOLANGCI_LINT_VERSION} ; \
fi

.PHONY: release
release:
goreleaser release \
Expand All @@ -37,10 +53,6 @@ test-release:
--snapshot \
${GORELEASER_FLAGS}

.PHONY: test
test:
go test -race ./...

.PHONY: update-install.sh
update-install.sh:
# FIXME install.sh is generated by godownloader, but godownloader is
Expand Down
9 changes: 4 additions & 5 deletions cmd/docs.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func Execute() {
}
}

//nolint:interfacer
func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error {
if colored, err := strconv.ParseBool(c.Color); err == nil {
c.colored = colored
Expand Down
9 changes: 4 additions & 5 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ chezmoi requires Go 1.13 or later and Go modules enabled. Enable Go modules by
setting the environment variable `GO111MODULE=on`.

chezmoi is a standard Go project, using standard Go tooling, with a few extra
tools. Install these extra tools with:
tools. Ensure that these extra tools are installed with:

make install-tools
make ensure-tools

Build chezmoi:

Expand Down Expand Up @@ -87,9 +87,8 @@ that:
[`gofumports`](https://mvdan.cc/gofumpt/gofumports). You can ensure this by
running `make format`.

* The code passes [`go vet`](https://golang.org/cmd/vet/) and
[`golangci-lint`](https://github.com/golangci/golangci-lint). You can ensure
this by running `make lint`.
* The code passes [`golangci-lint`](https://github.com/golangci/golangci-lint).
You can ensure this by running `make lint`.

* The commit messages match chezmoi's convention, specifically that they begin
with a capitalized verb in the imperative and give a short description of what
Expand Down
1 change: 0 additions & 1 deletion internal/git/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ type Status struct {
Ignored []IgnoredStatus
}

//nolint:gochecknoglobals
var (
statusPorcelainV2ZOrdinaryRegexp = regexp.MustCompile(`` +
`^1 ` +
Expand Down

0 comments on commit 70c4eda

Please sign in to comment.