From bad2473fc38dfee174dc69346d2cb7a8c3a4aed0 Mon Sep 17 00:00:00 2001 From: Heathcliff Date: Tue, 7 Jan 2025 12:01:13 +0100 Subject: [PATCH] CI: Upload coverprofile to coveralls Upload the coverprofile results to coveralls. Add badges for ci to README.md. Signed-off-by: Heathcliff --- .github/workflows/ci.yaml | 2 ++ .github/workflows/go-testcover-report.yaml | 5 ++--- .gitignore | 1 + Makefile | 4 ++-- README.md | 6 ++++++ hack/coverprofile.sh | 11 +++++------ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 364231b9..38085d86 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/.github/workflows/go-testcover-report.yaml b/.github/workflows/go-testcover-report.yaml index 1f788eaf..939dc20b 100644 --- a/.github/workflows/go-testcover-report.yaml +++ b/.github/workflows/go-testcover-report.yaml @@ -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 diff --git a/.gitignore b/.gitignore index b07127ae..30015bf7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # Generated go-test coverage reports /coverprofiles +coverprofile.out # Ignore files created for testing test-config.yaml diff --git a/Makefile b/Makefile index b49898e3..ee785262 100644 --- a/Makefile +++ b/Makefile @@ -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/... @@ -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 diff --git a/README.md b/README.md index c07cae24..e8cb6f93 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/hack/coverprofile.sh b/hack/coverprofile.sh index 8c1c3efb..c50e658e 100755 --- a/hack/coverprofile.sh +++ b/hack/coverprofile.sh @@ -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