mirror of https://github.com/spf13/viper.git
chore: improve dev env
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
bec1fce61d
commit
bb60a768c5
45
Makefile
45
Makefile
|
@ -29,11 +29,6 @@ clear: ## Clear the working area and the project
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
check: test lint ## Run tests and linters
|
check: test lint ## Run tests and linters
|
||||||
|
|
||||||
bin/gotestsum: bin/gotestsum-${GOTESTSUM_VERSION}
|
|
||||||
@ln -sf gotestsum-${GOTESTSUM_VERSION} bin/gotestsum
|
|
||||||
bin/gotestsum-${GOTESTSUM_VERSION}:
|
|
||||||
@mkdir -p bin
|
|
||||||
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum-${GOTESTSUM_VERSION} && chmod +x ./bin/gotestsum-${GOTESTSUM_VERSION}
|
|
||||||
|
|
||||||
TEST_PKGS ?= ./...
|
TEST_PKGS ?= ./...
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
@ -44,20 +39,36 @@ test: bin/gotestsum ## Run tests
|
||||||
@mkdir -p ${BUILD_DIR}
|
@mkdir -p ${BUILD_DIR}
|
||||||
bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/coverage.xml --format ${TEST_FORMAT} -- -race -coverprofile=${BUILD_DIR}/coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...)
|
bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/coverage.xml --format ${TEST_FORMAT} -- -race -coverprofile=${BUILD_DIR}/coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...)
|
||||||
|
|
||||||
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
|
|
||||||
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
|
|
||||||
bin/golangci-lint-${GOLANGCI_VERSION}:
|
|
||||||
@mkdir -p bin
|
|
||||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION}
|
|
||||||
@mv bin/golangci-lint "$@"
|
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: bin/golangci-lint ## Run linter
|
lint: lint-go lint-yaml
|
||||||
bin/golangci-lint run
|
lint: ## Run linters
|
||||||
|
|
||||||
.PHONY: fix
|
.PHONY: lint-go
|
||||||
fix: bin/golangci-lint ## Fix lint violations
|
lint-go:
|
||||||
bin/golangci-lint run --fix
|
golangci-lint run $(if ${CI},--out-format github-actions,)
|
||||||
|
|
||||||
|
.PHONY: lint-yaml
|
||||||
|
lint-yaml:
|
||||||
|
yamllint $(if ${CI},-f github,) --no-warnings .
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt: ## Format code
|
||||||
|
golangci-lint run --fix
|
||||||
|
|
||||||
|
deps: bin/golangci-lint bin/gotestsum yamllint
|
||||||
|
deps: ## Install dependencies
|
||||||
|
|
||||||
|
bin/gotestsum:
|
||||||
|
@mkdir -p bin
|
||||||
|
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum && chmod +x ./bin/gotestsum
|
||||||
|
|
||||||
|
bin/golangci-lint:
|
||||||
|
@mkdir -p bin
|
||||||
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_VERSION}
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
yamllint:
|
||||||
|
pip install --user yamllint
|
||||||
|
|
||||||
# Add custom targets here
|
# Add custom targets here
|
||||||
-include custom.mk
|
-include custom.mk
|
||||||
|
|
28
README.md
28
README.md
|
@ -882,3 +882,31 @@ No, you will need to synchronize access to the viper yourself (for example by us
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
See [TROUBLESHOOTING.md](TROUBLESHOOTING.md).
|
See [TROUBLESHOOTING.md](TROUBLESHOOTING.md).
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
**For an optimal developer experience, it is recommended to install [Nix](https://nixos.org/download.html) and [direnv](https://direnv.net/docs/installation.html).**
|
||||||
|
|
||||||
|
_Alternatively, install [Go](https://go.dev/dl/) on your computer then run `make deps` to install the rest of the dependencies._
|
||||||
|
|
||||||
|
Run the test suite:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
make test
|
||||||
|
```
|
||||||
|
|
||||||
|
Run linters:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
make lint # pass -j option to run them in parallel
|
||||||
|
```
|
||||||
|
|
||||||
|
Some linter violations can automatically be fixed:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
make fmt
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The project is licensed under the [MIT License](LICENSE).
|
||||||
|
|
Loading…
Reference in New Issue