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.
Add clean and coverprofile commands to make.
Rename build commands for images to image.

Signed-off-by: Heathcliff <[email protected]>
  • Loading branch information
heathcliff26 committed Jan 7, 2025
1 parent b9dae60 commit b7233f3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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
Expand Up @@ -6,3 +6,4 @@ test-config.yaml

# Generated go-test coverage reports
coverprofiles/
coverprofile.out
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ CONTAINER_NAME ?= speedtest-exporter
SLIM_TAG ?= slim
CLI_TAG ?= cli

default: build

build:
hack/build.sh

build-slim:
image-slim:
podman build -t $(REPOSITORY)/$(CONTAINER_NAME):$(SLIM_TAG) .

build-cli:
image-cli:
podman build -f Dockerfile.cli -t $(REPOSITORY)/$(CONTAINER_NAME):$(CLI_TAG) .

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

coverprofile:
hack/coverprofile.sh

lint:
golangci-lint run -v
Expand All @@ -31,14 +32,19 @@ validate:
update-deps:
hack/update-deps.sh

clean:
rm -rf bin coverprofiles coverprofile.out

.PHONY: \
default \
build \
build-slim \
build-cli \
image-slim \
image-cli \
test \
coverprofile \
lint \
fmt \
validate \
update-deps \
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/speedtest-exporter/actions/workflows/ci.yaml/badge.svg?event=push)](https://github.com/heathcliff26/speedtest-exporter/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/heathcliff26/speedtest-exporter/badge.svg)](https://coveralls.io/github/heathcliff26/speedtest-exporter)
[![Editorconfig Check](https://github.com/heathcliff26/speedtest-exporter/actions/workflows/editorconfig-check.yaml/badge.svg?event=push)](https://github.com/heathcliff26/speedtest-exporter/actions/workflows/editorconfig-check.yaml)
[![Generate go test cover report](https://github.com/heathcliff26/speedtest-exporter/actions/workflows/go-testcover-report.yaml/badge.svg)](https://github.com/heathcliff26/speedtest-exporter/actions/workflows/go-testcover-report.yaml)
[![Renovate](https://github.com/heathcliff26/speedtest-exporter/actions/workflows/renovate.yaml/badge.svg)](https://github.com/heathcliff26/speedtest-exporter/actions/workflows/renovate.yaml)

# speedtest-exporter

This project is a prometheus exporter for speedtests implemented in go.
Expand Down
10 changes: 5 additions & 5 deletions hack/coverprofile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

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"
OUT_DIR="${base_dir}/coverprofiles"
APP="speedtest-exporter"

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"
make test
go tool cover -html "coverprofile.out" -o "${OUT_DIR}/index.html"

popd >/dev/null

0 comments on commit b7233f3

Please sign in to comment.