Skip to content

Commit

Permalink
1、check go imports order、check copyright、format go files imports (erd…
Browse files Browse the repository at this point in the history
…a-project#1387)

* 1、check go imports order
2、check copyright
3、fix go files imports order

* update ci

* update ci

* update ci job name

* update ci job name

* update job name
  • Loading branch information
recallsong authored Aug 10, 2021
1 parent 1d6f2f5 commit e89f751
Show file tree
Hide file tree
Showing 166 changed files with 762 additions and 477 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/ci-it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,6 @@ jobs:
fetch-depth: 0
- name: Go generate files
run: make prepare
- name: erda-cli
run: make cli
- name: Erda MySQL Lint
run: ./bin/erda-cli migrate lint --input=.erda/migrations --lint-config=.erda/migrations/config.yml
- name: Set up Go mod
run: go mod tidy
- name: Run Lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.29
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
args: --timeout=10m
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true then the action will use pre-installed Go.
skip-go-installation: true
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
skip-pkg-cache: true
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
skip-build-cache: true
- name: Run Build
run: make GO_BUILD_OPTIONS="-tags=musl"
- name: Run Test
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) 2021 Terminus, Inc.
#
# This program is free software: you can use, redistribute, and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# or later ("AGPL"), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

name: Code Check
on:
push:
tags:
- v*
branches:
- develop
- master
- release/*
pull_request:
jobs:
CODE-CHECK:
runs-on: ubuntu-latest
container:
image: letmein7788/letmein:golangci-lint
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Go generate files
run: make prepare
- name: Check Go Imports
run: make check-imports
- name: Build erda-cli
run: make cli
- name: Run SQL Lint
run: ./bin/erda-cli migrate lint --input=.erda/migrations --lint-config=.erda/migrations/config.yml
- name: Run Go Lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.29
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
args: --timeout=10m
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true then the action will use pre-installed Go.
skip-go-installation: true
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
skip-pkg-cache: true
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
skip-build-cache: true



25 changes: 21 additions & 4 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
name: LICENSE CHECK
# Copyright (c) 2021 Terminus, Inc.
#
# This program is free software: you can use, redistribute, and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# or later ("AGPL"), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

name: License Check
on:
push:
tags:
Expand All @@ -11,9 +24,13 @@ on:
jobs:
LICENSE-CHECK:
runs-on: ubuntu-latest
container:
image: letmein7788/letmein:golangci-lint
steps:
- uses: actions/checkout@v2
- name: Check License Lines
uses: kt3k/[email protected]
with:
args: -q
fetch-depth: 0
- name: Check Copyright Header
run: make check-copyright


5 changes: 0 additions & 5 deletions .licenserc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"**/*.go": [
"Copyright (c) 2021 Terminus, Inc.",
"This program is free software: you can use, redistribute, and/or modify",
"it under the terms of the GNU Affero General Public License, version 3"
],
"ignore": [
"vendor/",
"third_party/",
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ normalize:
done;

# check copyright header
copyright:
go run tools/gotools/copyright/main.go
check-copyright:
go run tools/gotools/go-copyright/main.go

# check go imports order
check-imports:
go run tools/gotools/go-imports-order/main.go

# docker image
build-image: prepare
Expand Down
4 changes: 2 additions & 2 deletions bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"os"
"testing"

"github.com/erda-project/erda/pkg/http/httpclient"

"github.com/stretchr/testify/assert"

"github.com/erda-project/erda/pkg/http/httpclient"
)

func TestBundleOption(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions bundle/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import (
"fmt"
"strconv"

"github.com/erda-project/erda/pkg/http/httputil"

"github.com/pkg/errors"

"github.com/erda-project/erda/apistructs"
"github.com/erda-project/erda/bundle/apierrors"
"github.com/erda-project/erda/pkg/http/httpserver"
"github.com/erda-project/erda/pkg/http/httputil"
"github.com/erda-project/erda/pkg/parser/diceyml"
)

Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ require (
github.com/gogap/stack v0.0.0-20150131034635-fef68dddd4f8 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang-jwt/jwt v3.2.1+incompatible
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.2.0
github.com/googlecloudplatform/flink-operator v0.0.0-00010101000000-000000000000
github.com/gorilla/mux v1.8.0
Expand Down Expand Up @@ -99,6 +100,7 @@ require (
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
github.com/robfig/cron v1.2.0
github.com/russross/blackfriday/v2 v2.0.1
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f
github.com/satori/go.uuid v1.2.0
github.com/scylladb/gocqlx v1.5.0
github.com/shirou/gopsutil/v3 v3.21.3
Expand All @@ -125,6 +127,7 @@ require (
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/text v0.3.6
google.golang.org/genproto v0.0.0-20210729151513-df9385d47c1b
google.golang.org/grpc v1.39.0
google.golang.org/protobuf v1.27.1
gopkg.in/Knetic/govaluate.v3 v3.0.0
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ github.com/erda-project/elastic v0.0.1-ex/go.mod h1:iAVsas6fcmt9pxtge1+dErMhecv+
github.com/erda-project/erda-infra v0.0.0-20210706133120-0a742437972c/go.mod h1:TUQYSZ60w9dk7m0q3U3AVg7U74APj/sdEVvRWR3wYv8=
github.com/erda-project/erda-infra v0.0.0-20210729162038-a2e798d921de h1:jI4eyZ0bMf0UmEeZY8yJBnetcSICpH8M6+FEEKadTjc=
github.com/erda-project/erda-infra v0.0.0-20210729162038-a2e798d921de/go.mod h1:L+fFQghY2po2P3H9pzwEOufDLAhL+mRRhPGdZ7vFnAw=
github.com/erda-project/erda-proto-go v0.0.0-20210803124211-0d0ca1e699db h1:G560VTGWDmlt1peOBIblmlsliCYW1s7UnxArIQt5x08=
github.com/erda-project/erda-proto-go v0.0.0-20210803124211-0d0ca1e699db/go.mod h1:rSETXX3nKxxIhgrVn7fKDM3mla1nNlWcPz4AkepixaU=
github.com/erda-project/erda-proto-go v0.0.0-20210804030051-79c0be70a3ed h1:CQ20gYsNe+d9UoZ29Go0VSQGE2AY3+G4lor5UW2aUgM=
github.com/erda-project/erda-proto-go v0.0.0-20210804030051-79c0be70a3ed/go.mod h1:rSETXX3nKxxIhgrVn7fKDM3mla1nNlWcPz4AkepixaU=
github.com/erda-project/erda-proto-go v0.0.0-20210805063629-d4e8ac75e06d h1:6qHof6d0/OWdgKGGpdhvSWZGwtZNK6GXLLcXfn7W5UA=
github.com/erda-project/erda-proto-go v0.0.0-20210805063629-d4e8ac75e06d/go.mod h1:rSETXX3nKxxIhgrVn7fKDM3mla1nNlWcPz4AkepixaU=
github.com/erda-project/influxql v1.1.0-ex h1:NgP5+S5Qo234IVSIJ3N/egvzCNYJURfMAett3e8a9LE=
Expand Down Expand Up @@ -899,8 +895,6 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/influxdata/tdigest v0.0.1/go.mod h1:Z0kXnxzbTC2qrx4NaIzYkE1k66+6oEDQTvL95hQFh5Y=
github.com/innerpeacez/erda-proto-go v0.0.0-20210803085231-aed8cda2cfc1 h1:rCC/MKq2tL2gmNGN/sKsLkG5xksA5bxHFEFHloqpFgE=
github.com/innerpeacez/erda-proto-go v0.0.0-20210803085231-aed8cda2cfc1/go.mod h1:rSETXX3nKxxIhgrVn7fKDM3mla1nNlWcPz4AkepixaU=
github.com/ishidawataru/sctp v0.0.0-20190723014705-7c296d48a2b5/go.mod h1:DM4VvS+hD/kDi1U1QsX2fnZowwBhqD0Dk3bRPKF/Oc8=
github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o=
github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
Expand Down Expand Up @@ -1470,6 +1464,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f h1:8P2MkG70G76gnZBOPGwmMIgwBb/rESQuwsJ7K8ds4NE=
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4=
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
Expand Down
6 changes: 2 additions & 4 deletions modules/cmp/impl/aliyun-resources/oss/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import (
"fmt"
"sync"

"github.com/golang-collections/collections/set"

"github.com/erda-project/erda/apistructs"

"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/golang-collections/collections/set"
"github.com/sirupsen/logrus"

"github.com/erda-project/erda/apistructs"
aliyun_resources "github.com/erda-project/erda/modules/cmp/impl/aliyun-resources"
)

Expand Down
4 changes: 1 addition & 3 deletions modules/cmp/impl/aliyun-resources/redis/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ import (
"strings"
"time"

"github.com/erda-project/erda/pkg/strutil"

"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"

kvstore "github.com/aliyun/alibaba-cloud-sdk-go/services/r-kvstore"
"github.com/sirupsen/logrus"

aliyun_resources "github.com/erda-project/erda/modules/cmp/impl/aliyun-resources"
"github.com/erda-project/erda/pkg/strutil"
)

// list instance
Expand Down
3 changes: 1 addition & 2 deletions modules/cmp/impl/aliyun-resources/vpc/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import (
"strings"
"sync"

"github.com/erda-project/erda/apistructs"

"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
libvpc "github.com/aliyun/alibaba-cloud-sdk-go/services/vpc"
"github.com/golang-collections/collections/set"
"github.com/sirupsen/logrus"

"github.com/erda-project/erda/apistructs"
aliyun_resources "github.com/erda-project/erda/modules/cmp/impl/aliyun-resources"
)

Expand Down
3 changes: 2 additions & 1 deletion modules/core-services/services/mbox/mbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/erda-project/erda/apistructs"
"github.com/erda-project/erda/modules/core-services/model"
"github.com/stretchr/testify/assert"
)

func TestSetDuplicateMboxStatus(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions modules/core/monitor/alert/alert-apis/cql/cql.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ package cql
import (
"fmt"

"github.com/erda-project/erda-infra/base/logs"

"github.com/gocql/gocql"

"github.com/erda-project/erda-infra/base/logs"
)

// Cql .
Expand Down
4 changes: 2 additions & 2 deletions modules/core/monitor/alert/storage/alert-record/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"encoding/json"
"time"

"github.com/jinzhu/gorm"

"github.com/erda-project/erda/modules/core/monitor/alert/alert-apis/adapt"
"github.com/erda-project/erda/modules/core/monitor/alert/alert-apis/db"

"github.com/jinzhu/gorm"
)

func (p *provider) invoke(key []byte, value []byte, topic *string, timestamp time.Time) error {
Expand Down
6 changes: 3 additions & 3 deletions modules/core/monitor/alert/storage/alert-record/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
package alert_record

import (
"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"

"github.com/erda-project/erda-infra/base/logs"
"github.com/erda-project/erda-infra/base/servicehub"
"github.com/erda-project/erda-infra/providers/kafka"
"github.com/erda-project/erda-infra/providers/mysql"

"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"
)

type define struct{}
Expand Down
11 changes: 6 additions & 5 deletions modules/dicehub/extension/extention.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
package extension

import (
context "context"
servicehub "github.com/erda-project/erda-infra/base/servicehub"
pb "github.com/erda-project/erda-proto-go/core/dicehub/extension/pb"
reflect "reflect"
testing "testing"
"context"
"reflect"
"testing"

"github.com/erda-project/erda-infra/base/servicehub"
"github.com/erda-project/erda-proto-go/core/dicehub/extension/pb"
)

func Test_extensionService_SearchExtensions(t *testing.T) {
Expand Down
11 changes: 6 additions & 5 deletions modules/dicehub/release/release.get.dice.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
package release

import (
context "context"
servicehub "github.com/erda-project/erda-infra/base/servicehub"
pb "github.com/erda-project/erda-proto-go/core/dicehub/release/pb"
reflect "reflect"
testing "testing"
"context"
"reflect"
"testing"

"github.com/erda-project/erda-infra/base/servicehub"
"github.com/erda-project/erda-proto-go/core/dicehub/release/pb"
)

func Test_releaseGetDiceService_PullDiceYAML(t *testing.T) {
Expand Down
11 changes: 6 additions & 5 deletions modules/dicehub/release/release.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
package release

import (
context "context"
servicehub "github.com/erda-project/erda-infra/base/servicehub"
pb "github.com/erda-project/erda-proto-go/core/dicehub/release/pb"
reflect "reflect"
testing "testing"
"context"
"reflect"
"testing"

"github.com/erda-project/erda-infra/base/servicehub"
"github.com/erda-project/erda-proto-go/core/dicehub/release/pb"
)

func Test_releaseService_CreateRelease(t *testing.T) {
Expand Down
Loading

0 comments on commit e89f751

Please sign in to comment.