mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 10:00:11 +00:00
🌱 add a verify rule for golang files import order (#177)
* 🌱 add a verify rule for golang files import order This PR uses the [gci tool](https://github.com/daixiang0/gci) to make all go files' import section with a specific order, it will organize import with group with order: 1. standard library modules 2. 3rd party modules 3. modules in OCM org, like the `open-cluster-management.io/api` 4. current project `open-cluster-management.io/ocm` modules developers can use the `make fmt-imports` to format the import automatically and the `make verify-fmt-imports` to check for any violation. Signed-off-by: zhujian <jiazhu@redhat.com> * 🌱 format the go files import Signed-off-by: zhujian <jiazhu@redhat.com> --------- Signed-off-by: zhujian <jiazhu@redhat.com>
This commit is contained in:
15
Makefile
15
Makefile
@@ -68,6 +68,21 @@ verify-gocilint:
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
|
||||
golangci-lint run --timeout=3m --modules-download-mode vendor ./...
|
||||
|
||||
install-golang-gci:
|
||||
go install github.com/daixiang0/gci@v0.10.1
|
||||
|
||||
fmt-imports: install-golang-gci
|
||||
gci write --skip-generated -s standard -s default -s "prefix(open-cluster-management.io)" -s "prefix(open-cluster-management.io/ocm)" cmd pkg test dependencymagnet
|
||||
|
||||
verify-fmt-imports: install-golang-gci
|
||||
@output=$$(gci diff --skip-generated -s standard -s default -s "prefix(open-cluster-management.io)" -s "prefix(open-cluster-management.io/ocm)" cmd pkg test dependencymagnet); \
|
||||
if [ -n "$$output" ]; then \
|
||||
echo "Diff output is not empty: $$output"; \
|
||||
exit 1; \
|
||||
else \
|
||||
echo "Diff output is empty"; \
|
||||
fi
|
||||
|
||||
verify: verify-crds
|
||||
|
||||
ensure-operator-sdk:
|
||||
|
||||
Reference in New Issue
Block a user