From 108fdc174fa812297e8eb88bc51de18151535fa5 Mon Sep 17 00:00:00 2001 From: q1anx1 <55543743+qianxi0410@users.noreply.github.com> Date: Sat, 13 Aug 2022 10:57:13 +0800 Subject: [PATCH] chore(ci): add linter the check go code style (#991) * feat(ci): auto format go code * fix: fix #997 * chore(ci): add go code style linter * fix: fix cmd error * chore: add `linter` of needs * chore: modiy commnet style --- .github/workflows/build.yml | 21 ++++++++++++++++++++- .golangci.yml | 2 +- conf/conf_test.go | 1 + controllers/token.go | 9 +++++---- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65f57bb8..030fb2c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,11 +57,30 @@ jobs: go build -race -ldflags "-extldflags '-static'" working-directory: ./ + linter: + name: Go-Linter + runs-on: ubuntu-latest + needs: [ go-tests ] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: '^1.16.5' + + # gen a dummy config file + - run: touch dummy.yml + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + args: --disable-all -c dummy.yml -E=gofumpt --max-same-issues=0 --timeout 5m --modules-download-mode=mod + release-and-push: name: Release And Push runs-on: ubuntu-latest if: github.repository == 'casdoor/casdoor' && github.event_name == 'push' - needs: [ frontend, backend ] + needs: [ frontend, backend, linter ] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.golangci.yml b/.golangci.yml index fb731dbb..2b05d307 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,7 +31,7 @@ run: - api # skip-files: # - ".*_test\\.go$" - modules-download-mode: vendor + modules-download-mode: mod # all available settings of specific linters linters-settings: lll: diff --git a/conf/conf_test.go b/conf/conf_test.go index ed9f9a63..c7cc8a79 100644 --- a/conf/conf_test.go +++ b/conf/conf_test.go @@ -11,6 +11,7 @@ // 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. + package conf import ( diff --git a/controllers/token.go b/controllers/token.go index c859ec3b..abf46901 100644 --- a/controllers/token.go +++ b/controllers/token.go @@ -269,10 +269,11 @@ func (c *ApiController) TokenLogout() { // IntrospectToken // @Title IntrospectToken // @Description The introspection endpoint is an OAuth 2.0 endpoint that takes a -// parameter representing an OAuth 2.0 token and returns a JSON document -// representing the meta information surrounding the -// token, including whether this token is currently active. -// This endpoint only support Basic Authorization. +// parameter representing an OAuth 2.0 token and returns a JSON document +// representing the meta information surrounding the +// token, including whether this token is currently active. +// This endpoint only support Basic Authorization. +// // @Param token formData string true "access_token's value or refresh_token's value" // @Param token_type_hint formData string true "the token type access_token or refresh_token" // @Success 200 {object} object.IntrospectionResponse The Response object