Skip to content

Commit

Permalink
Added test Coverage Report that comments to the PR
Browse files Browse the repository at this point in the history
Signed-off-by: Tanner Jones <[email protected]>
  • Loading branch information
tannerjones4075 committed Oct 30, 2023
1 parent 161d933 commit ff25381
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/go-test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Go test coverage check
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3

- name: Generate test coverage
run: go test ./... -coverprofile=./cover.out

- name: Check test coverage
uses: vladopajic/go-test-coverage@v2
with:
# Configure action using config file (option 1)
config: ./.testcoverage.yml

# Configure action by specifying input parameters individually (option 2)
profile: cover.out
local-prefix: github.com/org/project
threshold-file: 80
threshold-package: 80
threshold-total: 95
26 changes: 17 additions & 9 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,32 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
with:
fetch-depth: 1
- uses: actions/setup-go@v3
with: { go-version: "${{ matrix.go }}" }
with:
go-version: "${{ matrix.go }}"
- run: go version
- run: make test-unit race=true
- uses: codecov/codecov-action@v1
- run: make test-unit-with-coverage
- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
file: tmp/unit.cov
flags: unit
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.out
- name: Comment coverage report
run: |
curl -sSfL https://codecov.io/bash | bash -s -- -Z -K -f coverage.out || echo "Codecov upload failed"
if: matrix.os == 'ubuntu-latest'

bench:
name: Benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
with:
fetch-depth: 1
- uses: actions/setup-go@v3
with: { go-version: '1.x' }
with:
go-version: '1.x'
- run: go version
- run: make test-bench
- run: make test-bench
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Updated Developer guide to include docker build instructions ([#385](https://github.com/opensearch-project/opensearch-go/pull/385)
- Test against version 2.9.0,2.10.0, run tests in all branches, change intergration tests to wait for OpenSearch to start ([#392](https://github.com/opensearch-project/opensearch-go/pull/392))
- Makefile: use docker golangci-lint, run integration test on `.` folder, change coverage generation ([#392](https://github.com/opensearch-project/opensearch-go/pull/392))
- test-unit.yaml: Added test Coverage Report that comments to the PR ([]())

### Deprecated

Expand Down

0 comments on commit ff25381

Please sign in to comment.