forked from antrea-io/libOpenflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Github workflows for unit tests, go tidiness and code linters (#3)
The static code checkers revealed a lot of issues, some of them quite "interesting". I fixed them, even though there is still room for improvement in terms of code quality. Signed-off-by: Antonin Bas <[email protected]>
- Loading branch information
1 parent
d9bf657
commit bdd82da
Showing
20 changed files
with
431 additions
and
208 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Go | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: [ubuntu-latest] | ||
steps: | ||
- name: Set up Go 1.15 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.15 | ||
- name: Check-out code | ||
uses: actions/checkout@v2 | ||
- name: Run unit tests | ||
run: | | ||
make test | ||
tidy: | ||
runs-on: [ubuntu-latest] | ||
steps: | ||
- name: Set up Go 1.15 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.15 | ||
- name: Check-out code | ||
uses: actions/checkout@v2 | ||
- name: Check tidiness | ||
run: | | ||
./ci/check-tidy.sh | ||
golangci: | ||
runs-on: [ubuntu-latest] | ||
steps: | ||
- name: Check-out code | ||
uses: actions/checkout@v2 | ||
- name: Run code linters | ||
run: | | ||
make golangci |
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,13 @@ | ||
.cache | ||
.golangci-bin | ||
|
||
.DS_Store | ||
|
||
# VIM | ||
.*.swp | ||
|
||
# Emacs | ||
*~ | ||
|
||
.idea/ | ||
.vscode/ |
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,24 @@ | ||
run: | ||
tests: true | ||
timeout: 5m | ||
skip-files: | ||
- ".*\\.pb\\.go" | ||
skip-dirs-use-default: true | ||
|
||
linters-settings: | ||
goimports: | ||
local-prefixes: antrea-io/libOpenflow | ||
|
||
linters: | ||
disable-all: true | ||
enable: # see https://golangci-lint.run/usage/linters/ | ||
- deadcode | ||
- staticcheck | ||
- govet | ||
- gofmt | ||
- goimports | ||
- gosec | ||
- misspell | ||
|
||
run: | ||
deadline: 5m |
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,22 @@ | ||
GO ?= go | ||
|
||
all: test | ||
|
||
.PHONY: test | ||
test: | ||
$(GO) test -v ./... | ||
|
||
# code linting | ||
.golangci-bin: | ||
@echo "===> Installing Golangci-lint <===" | ||
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $@ v1.41.1 | ||
|
||
.PHONY: golangci | ||
golangci: .golangci-bin | ||
@echo "===> Running golangci <===" | ||
@GOOS=linux .golangci-bin/golangci-lint run -c .golangci.yml | ||
|
||
.PHONY: golangci-fix | ||
golangci-fix: .golangci-bin | ||
@echo "===> Running golangci-fix <===" | ||
@GOOS=linux .golangci-bin/golangci-lint run -c .golangci.yml --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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
: "${GO:=go}" | ||
|
||
goversion=$($GO version) | ||
|
||
$GO mod tidy | ||
|
||
rc=0 | ||
diff=$(git diff --exit-code -- go.mod go.sum) || rc=$? | ||
|
||
if [ $rc -ne 0 ]; then | ||
echo "Found some differences when running 'go mod tidy'" | ||
echo "**********" | ||
echo "$diff" | ||
echo "**********" | ||
echo "Please ensure you are using the correct version of go ($goversion), run 'go mod tidy', and commit the changes" | ||
fi | ||
|
||
exit $rc |
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.