From 5132215114395a2b494af89a3ce59c2c9dc74168 Mon Sep 17 00:00:00 2001 From: davidovich Date: Tue, 2 Jan 2024 14:30:02 -0500 Subject: [PATCH] re-enable coverage publish using actions, commit coverage file using summon. --- .github/workflows/go.yml | 6 ++++++ Makefile | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 12b8583..7462214 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,3 +19,9 @@ jobs: - name: Build and Test run: make + + - name: Update coverage + run: make update-coverage-badge + env: + COVERAGE_REPO_PAT: ${{secrets.COVERAGE_REPO_PAT}} + USER: automation diff --git a/Makefile b/Makefile index 22e58f7..86b3010 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ SRCS = $(shell go list -buildvcs=false -f '{{ $$dir := .Dir}}{{range .GoFiles}}{ DOC_REPO_NAME := davidovich.github.io DOC_REPO := git@github.com:davidovich/$(DOC_REPO_NAME).git +COVERAGE_REPO := github.com/davidovich/$(DOC_REPO_NAME).git SUMMON_BADGE_JSON_FILE := $(DOC_REPO_NAME)/shields/summon/summon.json TEST_TIMEOUT := 30s @@ -64,16 +65,15 @@ $(COVERAGE): .PHONY: update-coverage-badge update-coverage-badge: $(COVERAGE_PERCENT_FILE) -ifneq ("$(CIRCLE_BRANCH)","master") - @echo - @echo "On branch $(CIRCLE_BRANCH), not publishing this branch's $$(cat $(COVERAGE_PERCENT_FILE))% total coverage." +ifneq ("$(GITHUB_REF_NAME)","main") + @echo "On branch $(if $(GITHUB_REF_NAME),$(GITHUB_REF_NAME),$(shell git rev-parse --abbrev-ref HEAD)), not publishing this branch's $$(cat $(COVERAGE_PERCENT_FILE))% total coverage." else rm -rf /tmp/$(DOC_REPO_NAME) git -C /tmp clone $(DOC_REPO) cd /tmp/$(DOC_REPO_NAME) && \ - go run github.com/davidovich/summon-example-assets@3c2e66d7 shields.io/coverage.json.gotmpl --json "{\"Coverage\": \"$$(cat $(COVERAGE_PERCENT_FILE))\"}" -o- > /tmp/$(SUMMON_BADGE_JSON_FILE) - git -C /tmp/$(DOC_REPO_NAME) diff-index --quiet HEAD || git -C /tmp/$(DOC_REPO_NAME) -c user.email=automation@davidovich.com -c user.name=automation commit -am "automated coverage commit of $$(cat $(COVERAGE_PERCENT_FILE)) %" || true - git -C /tmp/$(DOC_REPO_NAME) push + go run github.com/davidovich/summon-example-assets@3c2e66d7 shields.io/coverage.json.gotmpl --json "{\"Coverage\": \"$$(cat $(ROOT_DIR)/$(COVERAGE_PERCENT_FILE))\"}" -o- > /tmp/$(SUMMON_BADGE_JSON_FILE) + git -C /tmp/$(DOC_REPO_NAME) diff-index --quiet HEAD || git -C /tmp/$(DOC_REPO_NAME) -c user.email=$(USER)@davidovich.com -c user.name=$(USER) commit -am "automated coverage commit of $$(cat $(COVERAGE_PERCENT_FILE)) %" || true + git -C /tmp/$(DOC_REPO_NAME) push https://$(USER):$(COVERAGE_REPO_PAT)@$(COVERAGE_REPO) endif .PHONY: clean