diff --git a/.github/.codecov.yml b/.github/.codecov.yml new file mode 100644 index 0000000000..b2b3d7d8aa --- /dev/null +++ b/.github/.codecov.yml @@ -0,0 +1,9 @@ +coverage: + status: + project: + default: false # disable the default status that measures entire project + pkg: # declare a new status context "pkg" + paths: + - pkg/* # only include coverage in "pkg/" folder + informational: true # Always pass check + patch: off # disable the commit only checks diff --git a/.github/workflows/unitcoverage.yaml b/.github/workflows/unitcoverage.yaml new file mode 100644 index 0000000000..d90885dacd --- /dev/null +++ b/.github/workflows/unitcoverage.yaml @@ -0,0 +1,27 @@ +name: Unit Test Coverage +on: [push, pull_request] +jobs: + test: + name: Unit Tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04, ubuntu-20.04] + timeout-minutes: 20 + steps: + - name: Install Go + uses: actions/setup-go@v2 + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Run Unit Tests + run: | + go test ./pkg/... -coverprofile coverage.out + go tool cover -func coverage.out + - name: Upload Results To Codecov + uses: codecov/codecov-action@v1 + with: + files: ./coverage.out + flags: unittests # optional + verbose: true # optional (default = false) diff --git a/scripts/test b/scripts/test index 57b9c88af3..7256c4b908 100755 --- a/scripts/test +++ b/scripts/test @@ -21,6 +21,7 @@ echo "Did test-run-basics $?" . ./scripts/test-run-compat echo "Did test-run-compat $?" + # --- [ "$ARCH" != 'amd64' ] && \ @@ -38,4 +39,6 @@ echo "Did test-run-sonobuoy $?" test-run-sonobuoy mysql test-run-sonobuoy postgres +. ./scripts/test-unit + exit 0 diff --git a/scripts/test-unit b/scripts/test-unit new file mode 100755 index 0000000000..730885c227 --- /dev/null +++ b/scripts/test-unit @@ -0,0 +1,2 @@ +#!/bin/bash +go test -cover -v ./pkg/... diff --git a/scripts/validate b/scripts/validate index cc96d8c689..098fc4e77b 100755 --- a/scripts/validate +++ b/scripts/validate @@ -32,5 +32,3 @@ if [ -n "$DIRTY" ]; then git diff exit 1 fi - -"${GO}" test -v ./pkg/...