-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updates - Update README - Update to go1.18 - Update to k8s v1.25.5 - Reworked vfstats collector - Implemented endpoint unit tests - Add netlink support detection - Add image building to Makefile - Remove deprecated references - Add Mellanox driver to drivers DB - Refactor code to enable testing - Support for NFD SR-IOV feature label - Changes to ensure more uniform Makefile - Implemented initial unit tests - Implemented vfstats package unit tests Co-Authored-By: Eoghan1232 <[email protected]> Co-Authored-By: eoghanlawless <[email protected]> Co-Authored-By: Ipawlikx <[email protected]> Co-Authored-By: nhennigan <[email protected]> * fixing incorrect flag * fixing typos * Adding in github action workflow * Addressed comments * Fixing vulnerability * Updating action workflow to run on ubuntu-latest * fixing go version in action * Fixing Hadolint scan in action * testing ginkgo issue in action * Revert "testing ginkgo issue in action" This reverts commit 6343cb8. * Updating Makefile to print coverage per function --------- Co-authored-by: Eoghan1232 <[email protected]> Co-authored-by: eoghanlawless <[email protected]> Co-authored-by: Ipawlikx <[email protected]> Co-authored-by: nhennigan <[email protected]>
- Loading branch information
1 parent
165b761
commit c6489eb
Showing
26 changed files
with
2,615 additions
and
1,082 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,106 @@ | ||
name: build-test-lint | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
name: build | ||
strategy: | ||
matrix: | ||
go-version: [1.18.x] | ||
goarch: [amd64] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Set up Go matrix | ||
uses: actions/setup-go@v3 | ||
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@v3 | ||
with: | ||
go-version: 1.18.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 | ||
|
||
test-coverage: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
name: test-coverage | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18.x | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Install hwdata | ||
run: sudo apt-get install hwdata -y | ||
|
||
- name: Go test with coverage | ||
run: make test-coverage | ||
|
||
golangci: | ||
name: Golangci-lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18.x | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
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.46.2 | ||
|
||
hadolint: | ||
runs-on: ubuntu-latest | ||
name: Hadolint | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: brpaz/[email protected] | ||
name: Run Hadolint | ||
with: | ||
dockerfile: ./Dockerfile | ||
ignore: DL3018 # DL3018: GH issue 368 | ||
|
||
go-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18.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
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 |
---|---|---|
@@ -1,10 +1,47 @@ | ||
IMAGE_REGISTRY?=localhost:5000/ | ||
IMAGE_VERSION?=latest | ||
|
||
IMAGE_NAME?=$(IMAGE_REGISTRY)sriov-metrics-exporter:$(IMAGE_VERSION) | ||
IMAGE_BUILDER?=docker | ||
|
||
DOCKERARGS?= | ||
ifdef HTTP_PROXY | ||
DOCKERARGS += --build-arg http_proxy=$(HTTP_PROXY) | ||
endif | ||
ifdef HTTPS_PROXY | ||
DOCKERARGS += --build-arg https_proxy=$(HTTPS_PROXY) | ||
endif | ||
|
||
all: build image-build test | ||
|
||
clean: | ||
rm -rf bin | ||
go clean --modcache | ||
|
||
go clean -modcache -testcache | ||
build: | ||
GO111MODULE=on go build -ldflags "-s -w" -buildmode=pie -o bin/sriov-exporter cmd/sriov-network-metrics-exporter.go | ||
|
||
image-build: | ||
@echo "Bulding container image $(IMAGE_NAME)" | ||
$(IMAGE_BUILDER) build -f Dockerfile -t $(IMAGE_NAME) $(DOCKERARGS) . | ||
|
||
image-push: | ||
$(IMAGE_BUILDER) push $(IMAGE_NAME) | ||
|
||
test: | ||
go test ./... -count=1 | ||
|
||
test-coverage: | ||
go test ./... -coverprofile cover.out | ||
go tool cover -func cover.out | ||
|
||
go-lint-install: | ||
go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
||
go-lint: go-lint-install | ||
go mod tidy | ||
go fmt ./... | ||
golangci-lint run | ||
GO111MODULE=on go build -ldflags "-s -w" -buildmode=pie -o bin/sriov-exporter cmd/sriov-network-metrics-exporter.go | ||
golangci-lint run --color always -v ./... | ||
|
||
go-lint-report: go-lint-install | ||
golangci-lint run --color always -v ./... &> golangci-lint.txt |
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.