From ad9b206acaa57e870f52a1a87dbf23806ca8a304 Mon Sep 17 00:00:00 2001 From: Jan Galek Date: Mon, 16 Dec 2024 19:22:23 +0100 Subject: [PATCH] [Add] codecov badge --- .github/workflows/tests.yml | 72 +++++++++++++++++++++++++++++++++++++ README.md | 8 ++++- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..4c3956d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,72 @@ +name: Run tests and upload coverage + +on: + pull_request: + types: [opened, synchronize, edited] + push: + +permissions: + id-token: write + contents: read + +#jobs: +# test: +# uses: gouef/github-lib-template/.github/workflows/shared_tests.yml@main +# with: +# slug: ${{ github.repository }} +jobs: + test: + name: Run tests and collect coverage + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.23.4 + + - name: Install dependencies + run: go mod tidy + + - name: Run tests + run: go test -covermode=set ./... -coverprofile=coverage.txt + + - name: Check coverage file + run: cat coverage.txt + - name: Debug info + run: | + echo "Repo: ${{ github.repository }}" + - name: Test if CODECOV_TOKEN is available + run: | + if [ -z "${{ secrets.CODECOV_TOKEN }}" ]; then + echo "CODECOV_TOKEN is NOT set" + else + echo "CODECOV_TOKEN is available" + fi + - name: Debug Codecov Token + run: | + echo "Codecov Token: ${{ secrets.CODECOV_TOKEN }}" + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Debug Codecov Upload + run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} -f coverage.txt -r github.com/${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload results to Codecov + uses: codecov/codecov-action@v5 + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.txt + name: ${{ github.workflow }} + fail_ci_if_error: true + verbose: true \ No newline at end of file diff --git a/README.md b/README.md index 1cc6ba8..523b24a 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,10 @@ Paginator [![GoDoc](https://pkg.go.dev/badge/github.com/gouef/paginator.svg)](https://pkg.go.dev/github.com/gouef/paginator) [![GitHub stars](https://img.shields.io/github/stars/gouef/paginator?style=social)](https://github.com/gouef/paginator/stargazers) -[![Go Report Card](https://goreportcard.com/badge/github.com/gouef/paginator)](https://goreportcard.com/report/github.com/gouef/paginator) \ No newline at end of file +[![Go Report Card](https://goreportcard.com/badge/github.com/gouef/paginator)](https://goreportcard.com/report/github.com/gouef/paginator) +[![codecov](https://codecov.io/github/gouef/paginator/branch/main/graph/badge.svg?token=YUG8EMH6Q8)](https://codecov.io/github/gouef/paginator) + +## Vesions +![Stable Version](https://img.shields.io/github/v/release/gouef/paginator?label=Stable&labelColor=green) +![GitHub Release](https://img.shields.io/github/v/release/gouef/paginator?label=RC&include_prereleases&filter=*rc*&logoSize=diago) +![GitHub Release](https://img.shields.io/github/v/release/gouef/paginator?label=Beta&include_prereleases&filter=*beta*&logoSize=diago)