From 1c46c45692efc56b9f9d0eee257ba19ef68d16bc Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Thu, 14 Mar 2024 16:01:47 +0000 Subject: [PATCH 1/8] test: Add the unit tests to the github action --- .github/workflows/code-health-tools.yml | 21 +++++++++++++++++++++ .gitignore | 2 ++ tools/cli/Makefile | 8 ++++++++ 3 files changed, 31 insertions(+) diff --git a/.github/workflows/code-health-tools.yml b/.github/workflows/code-health-tools.yml index 14450fc..0c64595 100644 --- a/.github/workflows/code-health-tools.yml +++ b/.github/workflows/code-health-tools.yml @@ -25,6 +25,27 @@ jobs: run: | pushd tools/cli make build + unit-tests: + needs: build + env: + COVERAGE: coverage.out + TEST_CMD: gotestsum --junitfile unit-tests.xml --format standard-verbose -- + 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 CLI + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: Install Go + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 + with: + go-version-file: 'tools/cli/go.mod' + - run: go install gotest.tools/gotestsum@ec99a250836f069a524bb9d9b5de0a7a96334ea7 + - 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..c3d2e5b 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,12 @@ 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) ./... + + .PHONY: gen-mocks gen-mocks: ## Generate mocks @echo "==> Generating mocks" From 0dc10b87079dbc6beb64d087bcd7c4ee79b2982c Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Thu, 14 Mar 2024 16:03:18 +0000 Subject: [PATCH 2/8] Update code-health-tools.yml --- .github/workflows/code-health-tools.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-health-tools.yml b/.github/workflows/code-health-tools.yml index 0c64595..77b5502 100644 --- a/.github/workflows/code-health-tools.yml +++ b/.github/workflows/code-health-tools.yml @@ -42,8 +42,8 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: Install Go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 - with: - go-version-file: 'tools/cli/go.mod' + with: + go-version-file: 'tools/cli/go.mod' - run: go install gotest.tools/gotestsum@ec99a250836f069a524bb9d9b5de0a7a96334ea7 - run: make unit-test lint: From da7e8260e4c7a8ef177e4273c05e4a816a27b879 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Thu, 14 Mar 2024 16:06:36 +0000 Subject: [PATCH 3/8] Update code-health-tools.yml --- .github/workflows/code-health-tools.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-health-tools.yml b/.github/workflows/code-health-tools.yml index 77b5502..4b13341 100644 --- a/.github/workflows/code-health-tools.yml +++ b/.github/workflows/code-health-tools.yml @@ -38,14 +38,17 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - - name: Checkout CLI + - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: Install Go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version-file: 'tools/cli/go.mod' - run: go install gotest.tools/gotestsum@ec99a250836f069a524bb9d9b5de0a7a96334ea7 - - run: make unit-test + - name: Run unit tests + run: | + pushd tools/cli + make unit-test lint: runs-on: ubuntu-latest steps: From f187277483282022faeccc6c2641b9fbc6f3e0ed Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Thu, 14 Mar 2024 16:07:00 +0000 Subject: [PATCH 4/8] Update Makefile --- tools/cli/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/cli/Makefile b/tools/cli/Makefile index c3d2e5b..4ed8150 100644 --- a/tools/cli/Makefile +++ b/tools/cli/Makefile @@ -65,7 +65,6 @@ unit-test: ## Run unit-tests @echo "==> Running unit tests..." $(TEST_CMD) -race -cover -count=1 -coverprofile $(COVERAGE) ./... - .PHONY: gen-mocks gen-mocks: ## Generate mocks @echo "==> Generating mocks" From a08e8998a33815c8f2f9becf3b806fc19d58a17f Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Thu, 14 Mar 2024 16:08:52 +0000 Subject: [PATCH 5/8] Update code-health-tools.yml --- .github/workflows/code-health-tools.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-health-tools.yml b/.github/workflows/code-health-tools.yml index 4b13341..6238682 100644 --- a/.github/workflows/code-health-tools.yml +++ b/.github/workflows/code-health-tools.yml @@ -44,7 +44,8 @@ jobs: uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version-file: 'tools/cli/go.mod' - - run: go install gotest.tools/gotestsum@ec99a250836f069a524bb9d9b5de0a7a96334ea7 + - name: Install gotest + run: go install gotest.tools/gotestsum@ec99a250836f069a524bb9d9b5de0a7a96334ea7 - name: Run unit tests run: | pushd tools/cli From a493590de8499f0df41d48217358f909b412c6b1 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Thu, 14 Mar 2024 17:09:16 +0000 Subject: [PATCH 6/8] Update code-health-tools.yml --- .github/workflows/code-health-tools.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-health-tools.yml b/.github/workflows/code-health-tools.yml index 6238682..347cbeb 100644 --- a/.github/workflows/code-health-tools.yml +++ b/.github/workflows/code-health-tools.yml @@ -47,9 +47,8 @@ jobs: - name: Install gotest run: go install gotest.tools/gotestsum@ec99a250836f069a524bb9d9b5de0a7a96334ea7 - name: Run unit tests - run: | - pushd tools/cli - make unit-test + working-directory: tools/cli + run: make unit-test lint: runs-on: ubuntu-latest steps: From 20a53d4c52ae91c4781652c1aad5ba18590824ee Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Fri, 15 Mar 2024 10:02:35 +0000 Subject: [PATCH 7/8] Update code-health-tools.yml --- .github/workflows/code-health-tools.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code-health-tools.yml b/.github/workflows/code-health-tools.yml index 347cbeb..250eb01 100644 --- a/.github/workflows/code-health-tools.yml +++ b/.github/workflows/code-health-tools.yml @@ -22,14 +22,12 @@ 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 - TEST_CMD: gotestsum --junitfile unit-tests.xml --format standard-verbose -- UNIT_TAGS: unit INTEGRATION_TAGS: integration strategy: @@ -44,8 +42,6 @@ jobs: uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version-file: 'tools/cli/go.mod' - - name: Install gotest - run: go install gotest.tools/gotestsum@ec99a250836f069a524bb9d9b5de0a7a96334ea7 - name: Run unit tests working-directory: tools/cli run: make unit-test From acc6af578d48c5e42fa950e216e880a98d31d55f Mon Sep 17 00:00:00 2001 From: Andrea Angiolillo Date: Fri, 15 Mar 2024 10:21:57 +0000 Subject: [PATCH 8/8] Update tools/cli/Makefile Co-authored-by: Gustavo Bazan --- tools/cli/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cli/Makefile b/tools/cli/Makefile index 4ed8150..d7fb5ad 100644 --- a/tools/cli/Makefile +++ b/tools/cli/Makefile @@ -63,7 +63,7 @@ list: ## List all make targets .PHONY: unit-test unit-test: ## Run unit-tests @echo "==> Running unit tests..." - $(TEST_CMD) -race -cover -count=1 -coverprofile $(COVERAGE) ./... + $(TEST_CMD) -race ./... .PHONY: gen-mocks gen-mocks: ## Generate mocks