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 7, 2025
1 parent 26ca5bb commit bad2473
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,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,6 +6,7 @@

# Generated go-test coverage reports
/coverprofiles
coverprofile.out

# Ignore files created for testing
test-config.yaml
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ image:
podman build -t $(REPOSITORY)/$(CONTAINER_NAME):$(TAG) .

test:
go test -v -race ./cmd/... ./pkg/... ./tests/storage/...
go test -v -race -coverprofile=coverprofile.out -coverpkg "./pkg/..." ./cmd/... ./pkg/... ./tests/storage/...

test-e2e:
go test -count=1 -v ./tests/e2e/...
Expand All @@ -40,7 +40,7 @@ validate:
hack/validate.sh

clean:
rm -rf bin manifests/release coverprofiles logs tmp_fleetlock_image_fleetlock-e2e-*.tar
rm -rf bin manifests/release coverprofiles coverprofile.out logs tmp_fleetlock_image_fleetlock-e2e-*.tar

golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
Expand Down
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/fleetlock/actions/workflows/ci.yaml/badge.svg?event=push)](https://github.com/heathcliff26/fleetlock/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/heathcliff26/fleetlock/badge.svg)](https://coveralls.io/github/heathcliff26/fleetlock)
[![Editorconfig Check](https://github.com/heathcliff26/fleetlock/actions/workflows/editorconfig-check.yaml/badge.svg?event=push)](https://github.com/heathcliff26/fleetlock/actions/workflows/editorconfig-check.yaml)
[![Generate go test cover report](https://github.com/heathcliff26/fleetlock/actions/workflows/go-testcover-report.yaml/badge.svg)](https://github.com/heathcliff26/fleetlock/actions/workflows/go-testcover-report.yaml)
[![Renovate](https://github.com/heathcliff26/fleetlock/actions/workflows/renovate.yaml/badge.svg)](https://github.com/heathcliff26/fleetlock/actions/workflows/renovate.yaml)

# FleetLock

Implements the [FleetLock protocol](https://coreos.github.io/zincati/development/fleetlock/protocol/) of [Zincati](https://coreos.github.io/zincati/) for coordinating upgrades of multiple [Fedora CoreOS](https://docs.fedoraproject.org/en-US/fedora-coreos/auto-updates/) nodes.
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"
OUT_DIR="${base_dir}/coverprofiles"

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

go test -coverprofile="${OUT_DIR}/cover.out" -coverpkg "./pkg/..." "./pkg/..." "./tests/storage/..."
go tool cover -html "${OUT_DIR}/cover.out" -o "${OUT_DIR}/index.html"
rm "${OUT_DIR}/cover.out"
make test
go tool cover -html "coverprofile.out" -o "${OUT_DIR}/index.html"

popd >/dev/null

0 comments on commit bad2473

Please sign in to comment.