Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go test coverage #406

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 14 additions & 0 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Run govulncheck

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run govulncheck
uses: golang/govulncheck-action@v1
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Adds additional timeout after cluster start ([#303](https://github.com/opensearch-project/opensearch-go/pull/303))
- Adds docker healthcheck to auto restart the container ([#315](https://github.com/opensearch-project/opensearch-go/pull/315))
- Adds golangci-lint as code analysis tool ([#313](https://github.com/opensearch-project/opensearch-go/pull/313))
- Adds govulncheck to check for go vulnerablities ([#405](https://github.com/opensearch-project/opensearch-go/pull/405))

### Changed

Expand All @@ -47,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 for unit testing([#406](https://github.com/opensearch-project/opensearch-go/pull/406))

### Deprecated

Expand Down
Loading