Skip to content

Commit

Permalink
CI: Upload coverprofile to coveralls
Browse files Browse the repository at this point in the history
Upload the coverprofile results to coveralls.
Add badges for ci to README.md.

Signed-off-by: Heathcliff <[email protected]>
  • Loading branch information
heathcliff26 committed Jan 4, 2025
1 parent 14ec3a3 commit a5a4d71
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

unit-tests:
uses: heathcliff26/ci/.github/workflows/golang-unit-tests.yaml@main
with:
coveralls: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}

validate:
uses: heathcliff26/ci/.github/workflows/golang-build.yaml@main
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/go-testcover-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ on:
workflow_dispatch:
push:
branches: ["main"]
paths:
- "*.go"
- "**/*.go"

jobs:
generate-reports:
uses: heathcliff26/ci/.github/workflows/golang-testcover-report.yaml@main
secrets: inherit
with:
coveralls: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated go-test coverage reports
coverprofiles/
coverprofile.out

# Generated artifacts
out/
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SHELL := bash
default:

test:
go test -v -race ./...
go test -v -race -coverprofile=coverprofile.out ./...

update-deps:
hack/update-deps.sh
Expand All @@ -20,6 +20,9 @@ fmt:
validate:
hack/validate.sh

clean:
rm -rf coverprofiles coverprofile.out

.PHONY: \
default \
test \
Expand All @@ -28,4 +31,5 @@ validate:
lint \
fmt \
validate \
clean \
$(NULL)
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[![CI](https://github.com/heathcliff26/promremote/actions/workflows/ci.yaml/badge.svg?event=push)](https://github.com/heathcliff26/promremote/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/heathcliff26/promremote/badge.svg)](https://coveralls.io/github/heathcliff26/promremote)
[![Editorconfig Check](https://github.com/heathcliff26/promremote/actions/workflows/editorconfig-check.yaml/badge.svg?event=push)](https://github.com/heathcliff26/promremote/actions/workflows/editorconfig-check.yaml)
[![Generate go test cover report](https://github.com/heathcliff26/promremote/actions/workflows/go-testcover-report.yaml/badge.svg)](https://github.com/heathcliff26/promremote/actions/workflows/go-testcover-report.yaml)
[![Renovate](https://github.com/heathcliff26/promremote/actions/workflows/renovate.yaml/badge.svg)](https://github.com/heathcliff26/promremote/actions/workflows/renovate.yaml)

# promremote

promremote is a golang API for pushing metrics collected from [client_golang](https://github.com/prometheus/client_golang) to prometheus via remote_write.
Expand Down
11 changes: 5 additions & 6 deletions hack/coverprofile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

set -e

script_dir="$(dirname "${BASH_SOURCE[0]}" | xargs realpath)/.."
base_dir="$(dirname "${BASH_SOURCE[0]}" | xargs realpath)/.."

pushd "${script_dir}" >/dev/null
pushd "${base_dir}" >/dev/null

OUT_DIR="${script_dir}/coverprofiles"
APP="promremote"
OUT_DIR="${base_dir}/coverprofiles"

if [ ! -d "${OUT_DIR}" ]; then
mkdir "${OUT_DIR}"
fi

go test -coverprofile="${OUT_DIR}/cover-${APP}.out" "./..."
go tool cover -html "${OUT_DIR}/cover-${APP}.out" -o "${OUT_DIR}/index.html"W
make test
go tool cover -html "coverprofile.out" -o "${OUT_DIR}/index.html"

popd >/dev/null

0 comments on commit a5a4d71

Please sign in to comment.