From 08479390ffe38999ea4e49192a3cf8ade0b56430 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 17 Jun 2022 12:03:34 +0200 Subject: [PATCH] Use editorconfig-checker (#982) --- .ecrc | 14 +++++++ .editorconfig | 1 + .woodpecker/docs.yml | 12 +++--- .woodpecker/test.yml | 4 ++ charts/woodpecker-server/templates/NOTES.txt | 4 +- docs/docs/91-migrations.md | 1 + docs/docs/92-development/06-guides.md | 11 +++--- server/api/build.go | 6 +-- server/store/datastore/config.go | 8 ++-- woodpecker-go/README.md | 40 ++++++++++---------- 10 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 .ecrc diff --git a/.ecrc b/.ecrc new file mode 100644 index 000000000..feef7e9da --- /dev/null +++ b/.ecrc @@ -0,0 +1,14 @@ +{ + "Exclude": [ + ".git", + "go.mod", "go.sum", + "vendor", + "fixtures", + "LICENSE", + "node_modules", + "server/store/datastore/migration/testfiles/sqlite.db", + "server/store/datastore/feed.go", + "_test.go", + "Makefile" + ] +} diff --git a/.editorconfig b/.editorconfig index 34f601514..2314f961a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,6 +14,7 @@ indent_style = tab [*.md] trim_trailing_whitespace = false +indent_size = 1 [Makefile] indent_style = tab diff --git a/.woodpecker/docs.yml b/.woodpecker/docs.yml index 9fe755da3..db28672ad 100644 --- a/.woodpecker/docs.yml +++ b/.woodpecker/docs.yml @@ -8,8 +8,8 @@ pipeline: when: event: [push, pull_request] path: - - "docs/**" - - ".woodpecker/docs.yml" + - "docs/**" + - ".woodpecker/docs.yml" deploy-preview: image: woodpeckerci/plugin-surge-preview:next @@ -24,8 +24,8 @@ pipeline: when: event: pull_request path: - - "docs/**" - - ".woodpecker/docs.yml" + - "docs/**" + - ".woodpecker/docs.yml" # TODO: add step to remove preview again after PR is closed (waiting for #286) deploy: @@ -53,6 +53,6 @@ pipeline: event: push branch: ${CI_REPO_DEFAULT_BRANCH} path: - - "docs/**" - - ".woodpecker/docs.yml" + - "docs/**" + - ".woodpecker/docs.yml" diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml index 8491ea0cc..3a699ed19 100644 --- a/.woodpecker/test.yml +++ b/.woodpecker/test.yml @@ -52,6 +52,10 @@ pipeline: - "**/*.go" - "go.*" + lint-editorconfig: + image: mstruebing/editorconfig-checker + group: test + test: image: golang:1.18 group: test diff --git a/charts/woodpecker-server/templates/NOTES.txt b/charts/woodpecker-server/templates/NOTES.txt index 085079337..a91031ee3 100644 --- a/charts/woodpecker-server/templates/NOTES.txt +++ b/charts/woodpecker-server/templates/NOTES.txt @@ -10,8 +10,8 @@ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "woodpecker-server.fullname" . }}' + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "woodpecker-server.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "woodpecker-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index f18cd51d7..6a9547462 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -60,6 +60,7 @@ Some versions need some changes to the server configuration or the pipeline conf - `drone.sqlite` -> `woodpecker.sqlite` - Plugin Settings moved into `settings` section: + ```diff pipline: something: diff --git a/docs/docs/92-development/06-guides.md b/docs/docs/92-development/06-guides.md index 8023b9c07..d9e863751 100644 --- a/docs/docs/92-development/06-guides.md +++ b/docs/docs/92-development/06-guides.md @@ -13,14 +13,14 @@ Woodpecker uses migrations to change the database schema if a database model has package migration import ( - "xorm.io/xorm" + "xorm.io/xorm" ) var alterTableReposDropCounter = task{ - name: "alter-table-drop-counter", - fn: func(sess *xorm.Session) error { - return dropTableColumns(sess, "repos", "repo_counter") - }, + name: "alter-table-drop-counter", + fn: func(sess *xorm.Session) error { + return dropTableColumns(sess, "repos", "repo_counter") + }, } ``` @@ -33,4 +33,3 @@ You should not use `sess.Begin()`, `sess.Commit()` or `sess.Close()` inside a mi ::: To automatically execute the migration after the start of the server, the new migration needs to be added to the end of `migrationTasks` in `server/store/datastore/migration/migration.go`. After a successful execution of that transaction the server will automatically add the migration to a list, so it won't be executed again on the next start. - diff --git a/server/api/build.go b/server/api/build.go index 7d7c0139e..ef0690c79 100644 --- a/server/api/build.go +++ b/server/api/build.go @@ -380,8 +380,8 @@ func DeleteBuildLogs(c *gin.Context) { var deleteStr = `[ { - "proc": %q, - "pos": 0, - "out": "logs purged by %s on %s\n" + "proc": %q, + "pos": 0, + "out": "logs purged by %s on %s\n" } ]` diff --git a/server/store/datastore/config.go b/server/store/datastore/config.go index 485831fc3..6de2dc24a 100644 --- a/server/store/datastore/config.go +++ b/server/store/datastore/config.go @@ -52,10 +52,10 @@ func (s storage) ConfigFindApproved(config *model.Config) (bool, error) { SELECT build_id FROM builds WHERE build_repo_id = ? AND build_id in ( - SELECT build_id - FROM build_config - WHERE build_config.config_id = ? - ) +SELECT build_id +FROM build_config +WHERE build_config.config_id = ? +) AND build_status NOT IN ('blocked', 'pending') LIMIT 1 `, config.RepoID, config.ID).Count() diff --git a/woodpecker-go/README.md b/woodpecker-go/README.md index ccb1ef3c2..bae98535b 100644 --- a/woodpecker-go/README.md +++ b/woodpecker-go/README.md @@ -2,34 +2,34 @@ ```Go import ( - "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" - "golang.org/x/oauth2" + "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" + "golang.org/x/oauth2" ) const ( - token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" - host = "http://woodpecker.company.tld" + token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" + host = "http://woodpecker.company.tld" ) func main() { - // create an http client with oauth authentication. - config := new(oauth2.Config) - authenticator := config.Client( - oauth2.NoContext, - &oauth2.Token{ - AccessToken: token, - }, - ) + // create an http client with oauth authentication. + config := new(oauth2.Config) + authenticator := config.Client( + oauth2.NoContext, + &oauth2.Token{ + AccessToken: token, + }, + ) - // create the woodpecker client with authenticator - client := woodpecker.NewClient(host, authenticator) + // create the woodpecker client with authenticator + client := woodpecker.NewClient(host, authenticator) - // gets the current user - user, err := client.Self() - fmt.Println(user, err) + // gets the current user + user, err := client.Self() + fmt.Println(user, err) - // gets the named repository information - repo, err := client.Repo("woodpecker-ci", "woodpecker") - fmt.Println(repo, err) + // gets the named repository information + repo, err := client.Repo("woodpecker-ci", "woodpecker") + fmt.Println(repo, err) } ```