diff --git a/.github/workflows/goimports-reviser.yml b/.github/workflows/goimports-reviser.yml new file mode 100644 index 0000000000..91ba6ebb6e --- /dev/null +++ b/.github/workflows/goimports-reviser.yml @@ -0,0 +1,77 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +name: goimports-reviser + +on: + push: + branches: + - master + pull_request: + branches: + - master + - v1.6.0 + type: [review_requested, ready_for_review] +jobs: + changes: + runs-on: ubuntu-latest + outputs: + docs: ${{ steps.filter.outputs.docs }} + go: ${{ steps.filter.outputs.go }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: ./.github/actions/paths-filter + id: filter + with: + token: ${{ secrets.GITHUB_TOKEN }} + filters: | + docs: + - 'docs/**/*' + - '*.md' + go: + - '*.go' + - '**/*.go' + - 'go.mod' + - 'go.sum' + - 'Makefile' + - 'Dockerfile' + - 'test/e2e/**/*' + - 'conf/**' + - 'utils/**' + - ".github/**" + goimports-reviser: + needs: changes + if: | + (needs.changes.outputs.go == 'true') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Go Env + uses: actions/setup-go@v3 + with: + go-version: "1.19" + - name: Make update-gofmt + working-directory: ./ + run: | + make update-gofmt + echo "*** Please make update-gofmt before creating a PR ***" + git diff --quiet -- . || (git diff | cat && false) diff --git a/pkg/providers/ingress/translation/annotations/plugins/http_method.go b/pkg/providers/ingress/translation/annotations/plugins/http_method.go index 1b4c96c580..77aa0a43a9 100644 --- a/pkg/providers/ingress/translation/annotations/plugins/http_method.go +++ b/pkg/providers/ingress/translation/annotations/plugins/http_method.go @@ -17,10 +17,10 @@ package plugins import ( "net/http" + "github.com/incubator4/go-resty-expr/expr" + "github.com/apache/apisix-ingress-controller/pkg/providers/ingress/translation/annotations" apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" - - "github.com/incubator4/go-resty-expr/expr" ) type HttpMethod struct{} diff --git a/pkg/providers/ingress/translation/annotations/plugins/http_method_test.go b/pkg/providers/ingress/translation/annotations/plugins/http_method_test.go index 7591ac19cb..21adcdee34 100644 --- a/pkg/providers/ingress/translation/annotations/plugins/http_method_test.go +++ b/pkg/providers/ingress/translation/annotations/plugins/http_method_test.go @@ -18,12 +18,11 @@ import ( "net/http" "testing" + "github.com/incubator4/go-resty-expr/expr" "github.com/stretchr/testify/assert" "github.com/apache/apisix-ingress-controller/pkg/providers/ingress/translation/annotations" apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" - - "github.com/incubator4/go-resty-expr/expr" ) // annotations: diff --git a/test/e2e/suite-chore/admin_api.go b/test/e2e/suite-chore/admin_api.go index 68ba711a8c..5bd8b56dd2 100644 --- a/test/e2e/suite-chore/admin_api.go +++ b/test/e2e/suite-chore/admin_api.go @@ -18,10 +18,10 @@ package chore import ( "context" + v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/assert" - v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" "github.com/apache/apisix-ingress-controller/test/e2e/scaffold" ) diff --git a/test/e2e/suite-features/external-sd.go b/test/e2e/suite-features/external-sd.go index aaa9bb035e..613a547ba6 100644 --- a/test/e2e/suite-features/external-sd.go +++ b/test/e2e/suite-features/external-sd.go @@ -23,10 +23,10 @@ import ( "os" "time" + "github.com/apache/apisix-ingress-controller/pkg/config" "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/assert" - "github.com/apache/apisix-ingress-controller/pkg/config" "github.com/apache/apisix-ingress-controller/test/e2e/scaffold" ) diff --git a/test/e2e/suite-plugins/suite-plugins-general/secret_ref.go b/test/e2e/suite-plugins/suite-plugins-general/secret_ref.go index 7fa16bc2a7..c8123890f8 100644 --- a/test/e2e/suite-plugins/suite-plugins-general/secret_ref.go +++ b/test/e2e/suite-plugins/suite-plugins-general/secret_ref.go @@ -16,9 +16,10 @@ package plugins import ( "fmt" + "net/http" + ginkgo "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/assert" - "net/http" "github.com/apache/apisix-ingress-controller/test/e2e/scaffold" )