diff --git a/.github/workflows/go-test-coverage.yml b/.github/workflows/go-test-coverage.yml new file mode 100644 index 000000000..690520798 --- /dev/null +++ b/.github/workflows/go-test-coverage.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml new file mode 100644 index 000000000..def4cb37c --- /dev/null +++ b/.github/workflows/govulncheck.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index d09f8f376..2f3d45772 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -16,15 +16,21 @@ 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: @@ -32,8 +38,10 @@ jobs: 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 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 431e4b761..e566151ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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