diff --git a/.github/workflows/code-health-tools.yml b/.github/workflows/code-health-tools.yml index 14450fc..250eb01 100644 --- a/.github/workflows/code-health-tools.yml +++ b/.github/workflows/code-health-tools.yml @@ -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: diff --git a/.gitignore b/.gitignore index 4a8a528..89d4366 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ # Tool generated files *.idea *.vscode + +*.out diff --git a/tools/cli/Makefile b/tools/cli/Makefile index 4453dda..d7fb5ad 100644 --- a/tools/cli/Makefile +++ b/tools/cli/Makefile @@ -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 @@ -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"