Skip to content

Commit

Permalink
test: Add the unit tests to the github action (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaangiolillo committed Mar 15, 2024
1 parent f1c5c21 commit c4782c8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
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 ./...

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

0 comments on commit c4782c8

Please sign in to comment.