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

Add support for the Coveralls #50

Merged
merged 4 commits into from
May 1, 2024
Merged
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
18 changes: 11 additions & 7 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ jobs:
with:
go-version: '1.22'

- name: Run tests with coverage
run: go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...

- name: Check tests coverage
uses: vladopajic/go-test-coverage@v2
with:
config: ./.testcoverage.yml
- name: Run Unit tests
run: |
go test -race -covermode atomic -coverprofile=covprofile ./...
- name: Exclude paths from test coverage
run: ./exclude_from_tests.sh covprofile examples/* cmd/* internal/*
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: goveralls -coverprofile=covprofile -service=github
benchmark:
runs-on: ubuntu-latest
steps:
Expand Down
43 changes: 0 additions & 43 deletions .testcoverage.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Go Reference](https://pkg.go.dev/badge/github.com/dl1998/go-logging.svg)](https://pkg.go.dev/github.com/dl1998/go-logging)
[![Go Report Card](https://goreportcard.com/badge/github.com/dl1998/go-logging)](https://goreportcard.com/report/github.com/dl1998/go-logging)
[![Coverage Status](https://coveralls.io/repos/github/dl1998/go-logging/badge.svg)](https://coveralls.io/github/dl1998/go-logging)

Go logger implements logger for Golang, current implementation is majorly inspired by Python logger.

Expand Down
33 changes: 33 additions & 0 deletions exclude_from_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Usage: ./exclude_from_tests.sh [-v] file [paths...]
# -v: verbose mode

verbose=0
if [ "$1" == "-v" ]; then
verbose=1
shift
fi

file=$1
shift

tmpfile=$(mktemp)

while read -r line; do
exclude=0
for path in "$@"; do
if [[ $line == *"$path"* ]]; then
exclude=1
[ $verbose -eq 1 ] && echo "Excluding: $line"
break
fi
done
if [ $exclude -eq 0 ]; then
echo "$line" >> "$tmpfile"
fi
done < "$file"

mv "$tmpfile" "$file"

echo "Excluded paths from the file."
Loading