Skip to content

Commit

Permalink
cleanup: add lint and editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mcavoyk committed Dec 21, 2020
1 parent d10ce31 commit 987d499
Show file tree
Hide file tree
Showing 24 changed files with 289 additions and 135 deletions.
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Go
# https://golang.org/cmd/gofmt/
[{go.mod,*.go}]
indent_style = tab

# Shell
# https://google.github.io/styleguide/shell.xml#Indentation
[*.{bash,sh,zsh}]
indent_size = 2
indent_style = space

# GNU make
# https://www.gnu.org/software/make/manual/html_node/Recipe-Syntax.html
[Makefile]
indent_style = tab

# YAML
# http://yaml.org/spec/1.2/2009-07-21/spec.html#id2576668
[*.{yaml,yml}]
indent_size = 2
indent_style = space
37 changes: 22 additions & 15 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,63 @@ name: all-ci

on:
push:
branches:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!main' # excludes main
pull_request:
branches: [ '!main' ]

env:
env:
KUBEBUILDER_VERSION: 2.3.1

jobs:

build:
name: Build
container:
container:
image: golang:1.15
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '~1.15'

- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
- name: Vet and Build
run: make manager
- name: Lint
run: |
make lint-install
make lint
- name: Build
run: make build

test:
name: Test
container:
container:
image: golang:1.15
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '~1.15'

- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
Expand All @@ -71,4 +78,4 @@ jobs:
file: ./cover.out
# flags: unittests # optional
name: external-secrets
fail_ci_if_error: false
fail_ci_if_error: false
43 changes: 25 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,55 @@ on:
pull_request:
branches: [ main ]

env:
env:
KUBEBUILDER_VERSION: 2.3.1

jobs:

build:
name: Build
container:
container:
image: golang:1.15
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '~1.15'

- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
- name: Vet and Build
run: make manager
- name: Lint
run: |
make lint-install
make lint
- name: Build
run: make build

test:
name: Test
container:
container:
image: golang:1.15
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '~1.15'

- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
Expand All @@ -66,7 +73,7 @@ jobs:
file: ./cover.out
# flags: unittests # optional
name: external-secrets
fail_ci_if_error: true
fail_ci_if_error: true

docker:
name: Docker
Expand Down Expand Up @@ -111,7 +118,7 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v2

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
Expand All @@ -121,7 +128,7 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Login to Github Packages
id: docker-login
uses: docker/login-action@v1
Expand All @@ -145,6 +152,6 @@ jobs:
org.opencontainers.image.source=${{ steps.prep.outputs.repo_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
run: echo ${{ steps.docker_build.outputs.digest }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ bin
*~

# Code test output
cover.out
cover.out
89 changes: 89 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
run:
timeout: 5m

linters-settings:
gci:
local-prefixes: github.com/external-secrets/external-secrets
goconst:
min-len: 3
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- importShadow
- unnamedResult
- unnecessaryBlock
settings:
rangeValCopy:
sizeThreshold: 512
hugeParam:
sizeThreshold: 512
gocyclo:
min-complexity: 16
golint:
min-confidence: 0
govet:
check-shadowing: false
lll:
line-length: 300
maligned:
suggest-new: true
misspell:
locale: US

linters:
disable-all: true
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- errorlint
- exhaustive
- exportloopref
- gci
- goconst
- gocritic
- godot
- gofmt
- golint
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
- maligned
- misspell
- nakedret
- nolintlint
- prealloc
- rowserrcheck
- scopelint
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace

service:
golangci-lint-version: 1.33.x
Loading

0 comments on commit 987d499

Please sign in to comment.