From b16039ccc60bad6a0bcd233e3490772aae9fa8e3 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 29 Jun 2022 16:21:55 +0300 Subject: [PATCH 1/4] fix: Remove explicit coverpkg github.com/coder/coder/codersdk This package is already covered by ./... --- .github/workflows/coder.yaml | 2 +- .vscode/settings.json | 4 +++- Makefile | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index e67777ab46aaa..34754fbc5ae43 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -204,7 +204,7 @@ jobs: shell: bash run: gotestsum --junitfile="gotests.xml" --packages="./..." -- -covermode=atomic -coverprofile="gotests.coverage" - -coverpkg=./...,github.com/coder/coder/codersdk + -coverpkg=./... -timeout=5m -short -failfast - name: Upload DataDog Trace diff --git a/.vscode/settings.json b/.vscode/settings.json index 0d81d15cc32b5..74308369e644f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -117,7 +117,9 @@ "go.coverOnSave": true, // The codersdk is used by coderd another other packages extensively. // To reduce redundancy in tests, it's covered by other packages. - "go.testFlags": ["-short", "-coverpkg=./.,github.com/coder/coder/codersdk"], + // Since package coverage pairing can't be defined, all packages cover + // all other packages. + "go.testFlags": ["-short", "-coverpkg=./..."], "go.coverageDecorator": { "type": "gutter", "coveredHighlightColor": "rgba(64,128,128,0.5)", diff --git a/Makefile b/Makefile index 3cdc0b1bc2472..1f7219bafbd2b 100644 --- a/Makefile +++ b/Makefile @@ -174,7 +174,7 @@ test: test-clean test-postgres: test-clean test-postgres-docker DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." -- \ -covermode=atomic -coverprofile="gotests.coverage" -timeout=30m \ - -coverpkg=./...,github.com/coder/coder/codersdk \ + -coverpkg=./... \ -count=2 -race -failfast .PHONY: test-postgres From 92778c24a80bc479167109f38b041028d1eea47d Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 29 Jun 2022 16:22:44 +0300 Subject: [PATCH 2/4] fix: Stop uploading short / mock db test coverage --- .github/workflows/coder.yaml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index 34754fbc5ae43..fa3f1e9607ab5 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -216,15 +216,6 @@ jobs: GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} run: go run scripts/datadog-cireport/main.go gotests.xml - - uses: codecov/codecov-action@v3 - if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./gotests.coverage - flags: unittest-go-${{ matrix.os }} - # this flakes and sometimes fails the build - fail_ci_if_error: false - test-go-postgres: name: "test/go/postgres" runs-on: ubuntu-latest From 6592c17008d77127fe900ea563885a97e406ebcd Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 29 Jun 2022 16:23:14 +0300 Subject: [PATCH 3/4] fix: Ignore test utils in coverage (clitest, coderdtest, ptytest) --- .editorconfig | 2 +- .github/codecov.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index b54df526a6832..227be2a6df852 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ trim_trailing_whitespace = true insert_final_newline = true indent_style = tab -[*.{md,json,yaml,tf,tfvars}] +[*.{md,json,yaml,yml,tf,tfvars}] indent_style = space indent_size = 2 diff --git a/.github/codecov.yml b/.github/codecov.yml index 7a95f53c5d3f1..0e1cadd432fa5 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -34,3 +34,7 @@ ignore: - scripts - site/.storybook - rules.go + # Packages used for writing tests. + - cli/clitest + - coderd/coderdtest + - pty/ptytest From db39e469c0de90d9a7f3f3808aeb3f9651ce92e8 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 29 Jun 2022 16:56:10 +0300 Subject: [PATCH 4/4] Revert "fix: Stop uploading short / mock db test coverage" This reverts commit 92778c24a80bc479167109f38b041028d1eea47d. --- .github/workflows/coder.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index fa3f1e9607ab5..34754fbc5ae43 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -216,6 +216,15 @@ jobs: GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} run: go run scripts/datadog-cireport/main.go gotests.xml + - uses: codecov/codecov-action@v3 + if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./gotests.coverage + flags: unittest-go-${{ matrix.os }} + # this flakes and sometimes fails the build + fail_ci_if_error: false + test-go-postgres: name: "test/go/postgres" runs-on: ubuntu-latest