Skip to content

Commit

Permalink
chore: enable code coverage (#44)
Browse files Browse the repository at this point in the history
Add a Makefile target that will run tests with coverage profiling
enabled. Upload coverage data as part of the various publish jobs.
  • Loading branch information
pgavlin authored Oct 5, 2023
1 parent ccb09b0 commit 5947f92
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish-prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
uses: ./.github/workflows/stage-lint.yml
test:
uses: ./.github/workflows/stage-test.yml
with:
enable-coverage: true
publish:
needs: [test, lint]
uses: ./.github/workflows/stage-publish.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
uses: ./.github/workflows/stage-lint.yml
test:
uses: ./.github/workflows/stage-test.yml
with:
enable-coverage: true
publish:
needs: [test, lint]
uses: ./.github/workflows/stage-publish.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
uses: ./.github/workflows/stage-lint.yml
test:
uses: ./.github/workflows/stage-test.yml
with:
enable-coverage: true
publish:
needs: [test, lint]
uses: ./.github/workflows/stage-publish.yml
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/stage-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
required: false
type: string

enable-coverage:
description: Collects coverage data from tests.
default: false
required: false
type: boolean

jobs:
test:
name: Test
Expand All @@ -25,8 +31,19 @@ jobs:
stable: ${{ matrix.go-stable }}
- name: Install Pulumi CLI
uses: pulumi/action-install-pulumi-cli@v2
- name: Test w/coverage
if: ${{ inputs.enable-coverage }}
run: make test_cover
- name: Test
if: ${{ ! inputs.enable-coverate }}
run: make test
- name: Upload code coverage
if: ${{ inputs.enable-coverage }}
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
strategy:
fail-fast: false
matrix:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ build_debug:: ensure

test:: build
${GO} test --timeout 30m -short -count 1 -parallel ${CONCURRENCY} ./...

test_cover:: build
${GO} test --timeout 30m -count 1 -coverpkg=github.com/pulumi/esc/... -race -coverprofile=coverage.out -parallel ${CONCURRENCY} ./...
23 changes: 23 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
coverage:
status:

# Project tracks and reports the project-level coverage.
project:
default:
informational: true

# Patch tracks the coverage of the changes in a single patch.
patch:
default:
informational: true

ignore:
# None of the test data should count against coverage.
- "**/testdata"

# Don't comment on PRs.
comment: false

# Don't post annotations to GitHub.
github_checks:
annotations: false

0 comments on commit 5947f92

Please sign in to comment.