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

test: Add the unit tests to the github action #11

Merged
merged 9 commits into from Mar 15, 2024
Merged
26 changes: 23 additions & 3 deletions .github/workflows/code-health-tools.yml
Expand Up @@ -22,9 +22,29 @@ jobs:
with:
go-version-file: 'tools/cli/go.mod'
- name: Build CLI
run: |
pushd tools/cli
make build
working-directory: tools/cli
run: make build
unit-tests:
needs: build
env:
COVERAGE: coverage.out
UNIT_TAGS: unit
INTEGRATION_TAGS: integration
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version-file: 'tools/cli/go.mod'
- name: Run unit tests
working-directory: tools/cli
run: make unit-test
lint:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -13,3 +13,5 @@
# Tool generated files
*.idea
*.vscode

*.out
7 changes: 7 additions & 0 deletions tools/cli/Makefile
Expand Up @@ -11,6 +11,8 @@ LINKER_GH_SHA_FLAG=-s -w -X github.com/mongodb/openapi/tools/cli/internal/versio
LINKER_FLAGS=${LINKER_GH_SHA_FLAG} -X github.com/mongodb/openapi/tools/cli/internal/version.Version=${VERSION}

DEBUG_FLAGS=all=-N -l
TEST_CMD?=go test
COVERAGE=coverage.out

export TERM := linux-m
export GO111MODULE := on
Expand Down Expand Up @@ -58,6 +60,11 @@ fix-lint: ## Fix linting errors
list: ## List all make targets
@${MAKE} -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort

.PHONY: unit-test
unit-test: ## Run unit-tests
@echo "==> Running unit tests..."
$(TEST_CMD) -race -cover -count=1 -coverprofile $(COVERAGE) ./...
andreaangiolillo marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: gen-mocks
gen-mocks: ## Generate mocks
@echo "==> Generating mocks"
Expand Down