Compare commits

...

8 commits

Author SHA1 Message Date
6c3a47fae1 add runner tool cache option
All checks were successful
Test / Test (push) Successful in 16s
2024-02-02 01:50:26 +01:00
ead2d54f03 specify Go version
All checks were successful
Test / Test (push) Successful in 32s
2024-02-02 01:45:45 +01:00
c94db9a2be Update .gitea/workflows/test.yaml
Some checks failed
Test / Test (push) Failing after 11s
2024-02-02 01:44:52 +01:00
e3a7c94402 add Gitea CI 2024-02-02 01:44:08 +01:00
35d90becc2 faster ci pipeline
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-14 10:32:30 +02:00
8a84c46ae3 Update pre-commit-config
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-14 08:04:49 +02:00
3d8f2d194e Add drone CI
All checks were successful
continuous-integration/drone Build is passing
2021-10-14 08:00:25 +02:00
badc3eb61e Add golangci 2021-10-14 07:55:28 +02:00
5 changed files with 75 additions and 7 deletions

10
.drone.yml Normal file
View file

@ -0,0 +1,10 @@
kind: pipeline
name: default
type: docker
steps:
- name: test
image: golangci/golangci-lint:latest
commands:
- golangci-lint run
- go test -v ./...

View file

@ -0,0 +1,18 @@
name: Test
on: [push]
jobs:
Test:
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '>=1.20.1'
- name: Build
run: go build -v .
- name: Test
run: go test -v ./...

30
.golangci.yaml Normal file
View file

@ -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

8
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,8 @@
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
name: Test

View file

@ -5,7 +5,7 @@ import (
"strings" "strings"
) )
// CI holds information about the current CI environment // CI holds information about the current CI environment.
type CI struct { type CI struct {
Name string Name string
Constant string Constant string
@ -25,7 +25,7 @@ type envMatcher interface {
matchEnv(env map[string]string) bool 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 { type simpleEnvMatcher struct {
envvar string envvar string
} }
@ -35,7 +35,7 @@ func (m simpleEnvMatcher) matchEnv(env map[string]string) bool {
return exists 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 { type anyEnvMatcher struct {
envvars []string envvars []string
} }
@ -49,7 +49,7 @@ func (m anyEnvMatcher) matchEnv(env map[string]string) bool {
return false 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 { type allEnvMatcher struct {
envvars []string 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 // kvEnvMatcher Test if all specified environment variables are set to the
// specified values // specified values.
type kvEnvMatcher struct { type kvEnvMatcher struct {
envvars map[string]string 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 // neEnvMatcher Test if the specified environment variable is set, but not
// to the specified value // to the specified value.
type neEnvMatcher struct { type neEnvMatcher struct {
envvar string envvar string
ne string ne string
@ -93,7 +93,9 @@ func (m neEnvMatcher) matchEnv(env map[string]string) bool {
} }
func getEnvironment() map[string]string { 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) items := make(map[string]string)
for _, item := range data { for _, item := range data {
key, val := getkeyval(item) key, val := getkeyval(item)