Skip to content

Commit

Permalink
[Add] codecov badge
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Dec 16, 2024
1 parent 1826ab3 commit 3d0c762
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
70 changes: 66 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,72 @@
name: Run tests and upload coverage

on:
push
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:
uses: gouef/github-lib-template/.github/workflows/shared_tests.yml@main
with:
slug: gouef/mode
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Mode of project
[![GoDoc](https://pkg.go.dev/badge/github.com/gouef/mode.svg)](https://pkg.go.dev/github.com/gouef/mode)
[![GitHub stars](https://img.shields.io/github/stars/gouef/mode?style=social)](https://github.com/gouef/mode/stargazers)
[![Go Report Card](https://goreportcard.com/badge/github.com/gouef/mode)](https://goreportcard.com/report/github.com/gouef/mode)
[![codecov](https://codecov.io/github/gouef/mode/branch/main/graph/badge.svg?token=YUG8EMH6Q8)](https://codecov.io/github/gouef/mode)


## Vesions
Expand Down
4 changes: 2 additions & 2 deletions mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func NewBasicMode() (*Mode, error) {
// NewMode create Mode
// Example:
//
// modes := []string{"staging"}
// mode, err := mode.NewMode(modes)
// modes := []string{"staging"}
// mode, err := mode.NewMode(modes)
func NewMode(additionalModes []string) (*Mode, error) {
mode := os.Getenv(EnvMode)
modes := []string{
Expand Down

0 comments on commit 3d0c762

Please sign in to comment.