From badc3eb61ea8db17dad1f869ccb63f2378e841ac Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Thu, 14 Oct 2021 07:55:28 +0200 Subject: [PATCH 1/8] Add golangci --- .golangci.yaml | 30 ++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 7 +++++++ ci_ingo.go | 16 +++++++++------- 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 .golangci.yaml create mode 100644 .pre-commit-config.yaml diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..feddee3 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,30 @@ +run: + modules-download-mode: readonly + +linters: + presets: + - bugs + - unused + - import + - module + + enable: + - gofumpt + - godot + - lll + - predeclared + - gocognit + - nestif + + disable: + - scopelint + +linters-settings: + godot: + capital: true + lll: + line-length: 88 + gocognit: + min-complexity: 10 + nestif: + min-complexity: 3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..648c12e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +repos: +- repo: https://github.com/tekwizely/pre-commit-golang + rev: v1.0.0-beta.4 + hooks: + - id: golangci-lint-repo-mod + name: GolangCI Lint + - id: go-test-repo-mod diff --git a/ci_ingo.go b/ci_ingo.go index 71379cb..ed0028c 100644 --- a/ci_ingo.go +++ b/ci_ingo.go @@ -5,7 +5,7 @@ import ( "strings" ) -// CI holds information about the current CI environment +// CI holds information about the current CI environment. type CI struct { Name string Constant string @@ -25,7 +25,7 @@ type envMatcher interface { matchEnv(env map[string]string) bool } -// simpleEnvMatcher Test if the specified environment variable is set +// simpleEnvMatcher Test if the specified environment variable is set. type simpleEnvMatcher struct { envvar string } @@ -35,7 +35,7 @@ func (m simpleEnvMatcher) matchEnv(env map[string]string) bool { return exists } -// anyEnvMatcher Test if any of the specified environment variables is set +// anyEnvMatcher Test if any of the specified environment variables is set. type anyEnvMatcher struct { envvars []string } @@ -49,7 +49,7 @@ func (m anyEnvMatcher) matchEnv(env map[string]string) bool { return false } -// allEnvMatcher Test if all of the specified environment variables are set +// allEnvMatcher Test if all of the specified environment variables are set. type allEnvMatcher struct { envvars []string } @@ -64,7 +64,7 @@ func (m allEnvMatcher) matchEnv(env map[string]string) bool { } // kvEnvMatcher Test if all specified environment variables are set to the -// specified values +// specified values. type kvEnvMatcher struct { envvars map[string]string } @@ -79,7 +79,7 @@ func (m kvEnvMatcher) matchEnv(env map[string]string) bool { } // neEnvMatcher Test if the specified environment variable is set, but not -// to the specified value +// to the specified value. type neEnvMatcher struct { envvar string ne string @@ -93,7 +93,9 @@ func (m neEnvMatcher) matchEnv(env map[string]string) bool { } func getEnvironment() map[string]string { - getenvironment := func(data []string, getkeyval func(item string) (key, val string)) map[string]string { + getenvironment := func( + data []string, getkeyval func(item string) (key, val string)) map[string]string { + items := make(map[string]string) for _, item := range data { key, val := getkeyval(item) From 3d8f2d194e0aee968d2501d0772706ba2d84e22b Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Thu, 14 Oct 2021 08:00:25 +0200 Subject: [PATCH 2/8] Add drone CI --- .drone.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..04ff24d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,13 @@ +kind: pipeline +name: default +type: docker + +steps: +- name: lint + image: golangci/golangci-lint:latest + commands: + - golangci-lint run +- name: test + image: golangci/golangci-lint:latest + commands: + - go test -v ./... From 8a84c46ae392aa47479985bcbe0bcce1e716ba8b Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Thu, 14 Oct 2021 08:04:49 +0200 Subject: [PATCH 3/8] Update pre-commit-config --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 648c12e..03c9e76 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,3 +5,4 @@ repos: - id: golangci-lint-repo-mod name: GolangCI Lint - id: go-test-repo-mod + name: Test From 35d90becc2a2e3478bcfb3a45f665a61c2208089 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Thu, 14 Oct 2021 10:32:30 +0200 Subject: [PATCH 4/8] faster ci pipeline --- .drone.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 04ff24d..370eabb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,11 +3,8 @@ name: default type: docker steps: -- name: lint - image: golangci/golangci-lint:latest - commands: - - golangci-lint run - name: test image: golangci/golangci-lint:latest commands: + - golangci-lint run - go test -v ./... From e3a7c944021f4c7f25812daff302f981310b9330 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Fri, 2 Feb 2024 01:44:08 +0100 Subject: [PATCH 5/8] add Gitea CI --- .gitea/workflows/test.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .gitea/workflows/test.yaml diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 0000000..e609f68 --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,13 @@ +name: Test +on: [push] + +jobs: + Test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + - name: Build + run: go build -v . + - name: Test + run: go test -v ./... From c94db9a2bea9cc5d0e23595aba3315918e2fb036 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Fri, 2 Feb 2024 01:44:52 +0100 Subject: [PATCH 6/8] Update .gitea/workflows/test.yaml --- .gitea/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index e609f68..35763e4 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -7,6 +7,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 + - name: Build run: go build -v . - name: Test From ead2d54f03360c51672dd0a73bd280fd01bc17ea Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Fri, 2 Feb 2024 01:45:45 +0100 Subject: [PATCH 7/8] specify Go version --- .gitea/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 35763e4..90b9aea 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -7,6 +7,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 + with: + go-version: '>=1.20.1' - name: Build run: go build -v . From 6c3a47fae1d776bd5bf6ff48dcfa106d5ee99cbe Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Fri, 2 Feb 2024 01:50:26 +0100 Subject: [PATCH 8/8] add runner tool cache option --- .gitea/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 90b9aea..8d64550 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -4,6 +4,8 @@ on: [push] jobs: Test: runs-on: ubuntu-latest + env: + RUNNER_TOOL_CACHE: /toolcache steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3