Skip to content

Commit

Permalink
Merge pull request #50 from dl1998/add-coveralls-support
Browse files Browse the repository at this point in the history
Add support for the Coveralls
  • Loading branch information
dl1998 authored May 1, 2024
2 parents 1852b93 + 2d33fc7 commit f9ca275
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 50 deletions.
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."

0 comments on commit f9ca275

Please sign in to comment.