Skip to content

Commit

Permalink
Merge pull request #95 from davidovich/re-enable-coverage
Browse files Browse the repository at this point in the history
re-enable coverage publish
  • Loading branch information
davidovich committed Jan 2, 2024
2 parents 20f883e + 5132215 commit 4d6175d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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

0 comments on commit 4d6175d

Please sign in to comment.