Skip to content
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

Makefile: Add unit-tests target to makefile and github actions #8

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR check
run-name: "PR #${{ github.event.number }} check (${{ github.sha }})"
on: [pull_request]
jobs:
build-and-unit-test:
static-checks-and-build:
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
Expand All @@ -25,3 +25,23 @@ jobs:
version: v1.54.2
- name: Build binaries
run: make build
unit-tests:
needs: static-checks-and-build
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.20']
steps:
- name: set up go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: setup tparse
run: go install github.com/mfridman/tparse@latest
- name: checkout
uses: actions/checkout@v3
- name: run build
run: make build
- name: run unit tests
run: make unit-tests

9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ clean: ; $(info $(M) cleaning...) @
prereqs: ## Verify that required utilities are installed
@echo -- $@ for MBG Project--
@go version || (echo "Please install GOLANG: https://go.dev/doc/install" && exit 1)
# @which goimports || (echo "Please install goimports: https://pkg.go.dev/golang.org/x/tools/cmd/goimports" && exit 1)

test-prereqs: prereqs
@which goimports || (echo "Please install goimports: https://pkg.go.dev/golang.org/x/tools/cmd/goimports" && exit 1)
$(GO) install github.com/mfridman/tparse@latest
@kubectl version --client || (echo "Please install kubectl: https://kubernetes.io/docs/tasks/tools/" && exit 1)
@docker version --format 'Docker v{{.Server.Version}}' || (echo "Please install Docker Engine: https://docs.docker.com/engine/install" && exit 1)
@kind --version || (echo "Please install kind: https://kind.sigs.k8s.io/docs/user/quick-start/#installation" && exit 1)
Expand Down Expand Up @@ -79,6 +82,10 @@ clean-tests:
#------------------------------------------------------
# Run Targets
#------------------------------------------------------
unit-tests:
@echo "Running unit tests..."
$(GO) test -v -count=1 ./pkg/... -json -cover | tparse --all
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

tests-e2e: clean-tests docker-build
$(GO) test -p 1 -timeout 30m -v -tags e2e ./tests/e2e/connectivity/...

Expand Down
Loading