diff --git a/.github/workflows/pre.yml b/.github/workflows/pre.yml index efb63158e..818112543 100644 --- a/.github/workflows/pre.yml +++ b/.github/workflows/pre.yml @@ -29,19 +29,10 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: verify run: make verify - - verify-deps: - name: verify-deps - runs-on: ubuntu-latest - steps: - - name: checkout code - uses: actions/checkout@v3 - - name: install Go - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - name: verify-deps run: make verify-deps + - name: verify-gofiles-import-format + run: make verify-gofiles-import-format build: name: build diff --git a/Makefile b/Makefile index b7e8faa5a..870d40fd3 100644 --- a/Makefile +++ b/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 + +format-gofiles-import: 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-gofiles-import-format: 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: