-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: more robust E2E tests Added a new test case for the COSIGN_REPOSITORY variable and made the e2e tests more robust by properly handling timeouts, which weren't working half the time. Signed-off-by: Bruno Bressi <[email protected]> * chore: added linting suggestions - Reduced complexity of Server - Reduce memory footprint for checking loops - Other minor renamings & fixes Signed-off-by: Bruno Bressi <[email protected]> * fix: E2E tests should work now Signed-off-by: Bruno Bressi <[email protected]> * chore: removed dead test & renamed slog back to log Signed-off-by: Bruno Bressi <[email protected]> * chore: removed comment Signed-off-by: Bruno Bressi <[email protected]> * chore: bumped deps & added some comments Signed-off-by: Bruno Bressi <[email protected]> * chore: install go version for e2e tests Signed-off-by: Bruno Bressi <[email protected]> * chore: moved back to placeholder logs in main Signed-off-by: Bruno Bressi <[email protected]> * chore: added godoc Signed-off-by: Bruno Bressi <[email protected]> * chore: unordered list formatting fixed Signed-off-by: Bruno Bressi <[email protected]> * fix: failure tests fail reliably now Signed-off-by: Bruno Bressi <[email protected]> --------- Signed-off-by: Bruno Bressi <[email protected]>
- Loading branch information
Showing
14 changed files
with
772 additions
and
1,148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
linters-settings: | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. | ||
statements: 58 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 3 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
gocyclo: | ||
min-complexity: 15 | ||
gofmt: | ||
rewrite-rules: | ||
- pattern: 'interface{}' | ||
replacement: 'any' | ||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
gomnd: | ||
# don't include the "operation" and "assign" | ||
checks: | ||
- argument | ||
- case | ||
- condition | ||
- return | ||
ignored-numbers: | ||
- '0' | ||
- '1' | ||
- '2' | ||
- '3' | ||
ignored-functions: | ||
- strings.SplitN | ||
|
||
govet: | ||
check-shadowing: true | ||
settings: | ||
printf: | ||
funcs: | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf | ||
lll: | ||
line-length: 140 | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-unused: false # report any unused nolint directives | ||
require-explanation: false # don't require an explanation for nolint directives | ||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||
revive: | ||
rules: | ||
- name: unexported-return | ||
disabled: true | ||
- name: unused-parameter | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- exportloopref | ||
- funlen | ||
- gocheckcompilerdirectives | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- gomnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- noctx | ||
- nolintlint | ||
- revive | ||
- staticcheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
run: | ||
timeout: 5m | ||
skip-files: | ||
- .*_test\.go | ||
skip-dirs: | ||
- test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: go-test | ||
name: go-unit-tests | ||
entry: make test-unit | ||
language: system | ||
types: [go] | ||
- repo: https://github.com/tekwizely/pre-commit-golang | ||
rev: v1.0.0-rc.1 | ||
hooks: | ||
- id: go-mod-tidy-repo | ||
- id: go-vet-repo-mod | ||
- id: go-fumpt-repo | ||
args: [ -l, -w ] | ||
- id: golangci-lint-repo-mod | ||
args: [ --config, .golangci.yaml, --, --fix ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,14 +131,15 @@ make test-e2e | |
The E2E tests require a running kubernetes cluster. Currently, the namespace and webhook are deployed via helper make | ||
targets. To run the tests the following is required: | ||
|
||
- docker | ||
- cosign (v2) | ||
* docker | ||
* cosign (v2) | ||
|
||
To run the E2E tests, the following steps are required (in order): | ||
|
||
- signing keys are generated (`make e2e-keys`) | ||
- a new `cosignwebhook` image is build and signed with a temp key (`make e2e-images`) | ||
- the image is pushed to a local registry & deployed to the test cluster (`make e2e-deploy`) | ||
* create a k3d local cluster for the tests and a local iamge registry (`make e2e-cluster`) | ||
* signing keys are generated (`make e2e-keys`) | ||
* a new `cosignwebhook` image is build and signed with a temp key (`make e2e-images`) | ||
* the image is pushed to a local registry & deployed to the test cluster (`make e2e-deploy`) | ||
|
||
To do all of the above, simply run `make e2e-prep`. Each step should also be able to be executed individually. To clean | ||
up the E2E setup, run `make e2e-cleanup`. This will delete everything created by the E2E preparation. | ||
|
@@ -157,8 +158,8 @@ CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cosignw | |
|
||
## Credits | ||
|
||
- Bruno Bressi <[email protected]> | ||
- Frank Kloeker <[email protected]> | ||
* Bruno Bressi <[email protected]> | ||
* Frank Kloeker <[email protected]> | ||
|
||
Life is for sharing. If you have an issue with the code or want to improve it, feel free to open an issue or an pull | ||
request. | ||
|
Oops, something went wrong.