diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bf30a04c..b1525adc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,12 +1,11 @@ -name: Test Coverage +name: Go Test Coverage with Coveralls -on: - pull_request: - branches: [master] +on: [pull_request, push] jobs: - coverage: + build: runs-on: ubuntu-latest + steps: - name: Check out code uses: actions/checkout@v2 @@ -14,31 +13,20 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: '^1.21' + go-version: '^1.21' # Set this to your Go version - - name: Run tests and collect coverage + - name: Run tests with coverage run: | make test-coverage - - name: Generate coverage report + - name: Generate LCOV report run: | - go tool cover -func=network-operator.cover + go install github.com/jandelgado/gcov2lcov@latest + gcov2lcov -infile=network-operator.cover -outfile=coverage.lcov - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2.2.3 with: - token: ${{ secrets.CODECOV_TOKEN }} # Required only for private repos - file: ./network-operator.cover - flags: unittests - name: codecov-umbrella - fail_ci_if_error: true - verbose: true - -# - name: Post coverage comment to PR -# uses: machine-learning-apps/pr-comment@v1.0.0 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# path: coverage.txt -# regex: '^total:\\s*\\(statements\\)\\s*([0-9\\.]+)%' -# message: "Code coverage on this PR is **${{ match }}%**. Please ensure this meets the project standards." + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage.lcov + flag-name: run-flags-1 # Optional: Custom flag name for parallel builds