Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable coverage publish #95

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SRCS = $(shell go list -buildvcs=false -f '{{ $$dir := .Dir}}{{range .GoFiles}}{

DOC_REPO_NAME := davidovich.github.io
DOC_REPO := [email protected]: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

Expand Down Expand Up @@ -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
Expand Down