Skip to content

Commit

Permalink
feat: add combined coverage CI job
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneutt committed Aug 5, 2021
1 parent de9d902 commit 986435a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 15 deletions.
55 changes: 48 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ jobs:
- name: run unit tests
run: make test

integration-test-dbless:
- name: collect test coverage
uses: actions/[email protected]
with:
name: coverage.unit.out
path: coverage.unit.out

integration-tests-dbless:
runs-on: ubuntu-latest
steps:

Expand All @@ -125,13 +131,13 @@ jobs:
- name: run integration tests
run: make test.integration.dbless

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2.0.2
- name: collect test coverage
uses: actions/upload-artifact@v2.2.4
with:
flags: integration-test
fail_ci_if_error: true
name: coverage.dbless.out
path: coverage.dbless.out

integration-test-postgres:
integration-tests-postgres:
runs-on: ubuntu-latest
steps:

Expand All @@ -156,8 +162,43 @@ jobs:
- name: run integration tests
run: make test.integration.postgres

- name: collect test coverage
uses: actions/[email protected]
with:
name: coverage.postgres.out
path: coverage.postgres.out

coverage:
environment: "Configure ci"
needs:
- "unit-tests"
- "integration-tests-dbless"
- "integration-tests-postgres"
runs-on: ubuntu-latest
steps:
- name: collect unit test coverage artifacts
uses: actions/[email protected]
with:
name: coverage.unit.out
path: coverage.unit.out

- name: collect dbless test coverage artifacts
uses: actions/[email protected]
with:
name: coverage.dbless.out
path: coverage.dbless.out

- name: collect postgres test coverage artifacts
uses: actions/[email protected]
with:
name: coverage.postgres.out
path: coverage.postgres.out

- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
flags: integration-test
name: combined-coverage
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.unit.out,./coverage.dbless.out,./coverage.postgres.out
fail_ci_if_error: true
verbose: true
31 changes: 23 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ container:
# ------------------------------------------------------------------------------

PKG_LIST = ./pkg/...,./internal/...
COVERAGE_PROFILE=coverage.out
KIND_CLUSTER_NAME ?= "integration-tests"

.PHONY: test.all
Expand All @@ -168,23 +167,39 @@ test.integration: test.integration.dbless test.integration.postgres

.PHONY: test
test:
@go test -race -v ./...

.PHONY: test.integration.legacy
test.integration.legacy: container
KIC_IMAGE="${IMAGE}:${TAG}" KUBE_VERSION=${KUBE_VERSION} ./hack/legacy/test/test.sh
@go test -v -race \
-covermode=atomic \
-coverpkg=$(PKG_LIST) \
-coverprofile=coverage.unit.out \
./...

.PHONY: test.integration.dbless
test.integration.dbless:
@./scripts/check-container-environment.sh
@TEST_DATABASE_MODE="off" GOFLAGS="-tags=integration_tests" go test -parallel $(NCPU) -timeout 15m -race -v -covermode=atomic -coverpkg=$(PKG_LIST) -coverprofile=$(COVERAGE_PROFILE) ./test/integration/...
@TEST_DATABASE_MODE="off" GOFLAGS="-tags=integration_tests" go test -v -race \
-timeout 15m \
-parallel $(NCPU) \
-covermode=atomic \
-coverpkg=$(PKG_LIST) \
-coverprofile=coverage.dbless.out \
./test/integration

# TODO: race checking has been temporarily turned off because of race conditions found with deck. This will be resolved in an upcoming Alpha release of KIC 2.0.
# See: https:/Kong/kubernetes-ingress-controller/issues/1324
.PHONY: test.integration.postgres
test.integration.postgres:
@./scripts/check-container-environment.sh
@TEST_DATABASE_MODE="postgres" GOFLAGS="-tags=integration_tests" go test -parallel $(NCPU) -timeout 15m -v -covermode=atomic -coverpkg=$(PKG_LIST) -coverprofile=$(COVERAGE_PROFILE) ./test/integration/...
@TEST_DATABASE_MODE="postgres" GOFLAGS="-tags=integration_tests" go test -v \
-timeout 15m \
-parallel $(NCPU) \
-covermode=atomic \
-coverpkg=$(PKG_LIST) \
-coverprofile=coverage.postgres.out \
./test/integration

.PHONY: test.integration.legacy
test.integration.legacy: container
KIC_IMAGE="${IMAGE}:${TAG}" KUBE_VERSION=${KUBE_VERSION} ./hack/legacy/test/test.sh

# ------------------------------------------------------------------------------
# Operations
Expand Down

0 comments on commit 986435a

Please sign in to comment.