-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Build/Test/Lint/go mod/vendor consistency workflow #328
Merged
adrianchiris
merged 16 commits into
k8snetworkplumbingwg:master
from
martinkennelly:static_ga
Aug 3, 2021
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7631f66
Add build/test/lint workflow
martinkennelly b1ed30c
Add workflow to check go mod and vendor are consistent
martinkennelly aa3d514
Partial fix for static analysis errors
37d9a4a
Update vendor directory
martinkennelly 2deb0c0
Shellcheck will ignore vendor directory
martinkennelly bda5e69
Fix readability of multi-line comment
martinkennelly af73445
Remove legacy backticks & prevent globbing/splitting
martinkennelly 581d77c
Prevent globbing/splitting in entrypoint
martinkennelly f3249a5
Disable shellcheck echo flag warning
martinkennelly 1099fa1
Correct shellcheck ignore env option
martinkennelly 997d565
Revert needless memory optimization to aid readability
martinkennelly 250c8f1
Increase gocritic huge param / range copy limit
martinkennelly 0690c55
Ignore hadolint warning for pinning apk pkg versions
martinkennelly cff7a34
Bump hadolint action to enable ignore option
martinkennelly b0447c3
Fix hadolint issues in RHEL7 dockerfile
martinkennelly 49e7741
Fix passing args to binary via exec
martinkennelly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: build-test-lint | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
name: build | ||
strategy: | ||
matrix: | ||
go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x] | ||
goarch: [amd64] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Set up Go 1.13 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build | ||
env: | ||
GOARCH: ${{ matrix.goarch }} | ||
GOOS: ${{ matrix.goos }} | ||
run: make build | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
name: test | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install hwdata | ||
run: sudo apt-get install hwdata -y | ||
|
||
- name: Go test | ||
run: make test | ||
|
||
golangci: | ||
name: Golangci-lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | ||
version: v1.37 | ||
shellcheck: | ||
name: Shellcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run ShellCheck | ||
uses: ludeeus/action-shellcheck@master | ||
with: | ||
ignore: vendor | ||
|
||
hadolint: | ||
runs-on: ubuntu-latest | ||
name: Hadolint | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: brpaz/hadolint-action@v1.2.1 | ||
name: Run Hadolint | ||
with: | ||
dockerfile: ./images/Dockerfile | ||
- uses: brpaz/hadolint-action@v1.2.1 | ||
with: | ||
dockerfile: Dockerfile.rhel7 | ||
|
||
go-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
# if this fails, run go mod tidy | ||
- name: Check if module files are consistent with code | ||
run: go mod tidy && git diff --exit-code | ||
|
||
# if this fails, run go mod vendor | ||
- name: Check if vendor directory is consistent with go modules | ||
run: go mod vendor && git diff --exit-code |
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,113 @@ | ||
# Tested with golangci-lint ver. 1.37 | ||
linters-settings: | ||
depguard: | ||
list-type: blacklist | ||
packages: | ||
# logging is allowed only by logutils.Log, logrus | ||
# is allowed to use only in logutils package | ||
- github.com/sirupsen/logrus | ||
packages-with-error-message: | ||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log" | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
- wrapperFunc | ||
- unnamedResult | ||
gocyclo: | ||
min-complexity: 15 | ||
goimports: | ||
local-prefixes: github.com/k8snetworkplumbingwg/sriov-network-device-plugin | ||
gomnd: | ||
settings: | ||
mnd: | ||
# don't include the "operation" and "assign" | ||
checks: argument,case,condition,return | ||
lll: | ||
line-length: 140 | ||
misspell: | ||
locale: US | ||
prealloc: | ||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. | ||
# True by default. | ||
simple: true | ||
range-loops: true # Report preallocation suggestions on range loops, true by default | ||
for-loops: false # Report preallocation suggestions on for loops, false by default | ||
|
||
linters: | ||
# please, do not use `enable-all`: it's deprecated and will be removed soon. | ||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- exportloopref | ||
- exhaustive | ||
- funlen | ||
#- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- gomnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
#- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- prealloc | ||
- rowserrcheck | ||
#- scopelint | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
|
||
issues: | ||
# Excluding configuration per-path, per-linter, per-text and per-source | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- gomnd | ||
- gosec | ||
- dupl | ||
- lll | ||
- stylecheck | ||
- goconst | ||
|
||
run: | ||
skip-dirs: | ||
- vendor/ | ||
- .github/ | ||
- deployments/ | ||
- docs/ | ||
- images/ |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just ignore
DL3018
for now ?alternative is to just fix the packages we install to whatever is being installed today.
(this has its downside though...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should ignore it because it will reduce the need for a discussion and outcome. I will create an issue following this PR to get consensus for this issue. We may just want to ignore it..
Pros for setting it to a version:
We get a version we know that works - more deterministic.
Cons for settings it to a version:
We need to update the version before its no longer available in the package managers repo or it will break our builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes +1 on opening an issue and meanwhile ignore so check passes with current state of things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Ignored following community response on the issue.