Skip to content

Commit

Permalink
Merge pull request #49 from moul/dev/moul/report-ci
Browse files Browse the repository at this point in the history
feat: add report-ci
  • Loading branch information
moul committed Jun 29, 2020
2 parents ed782a2 + 5493e06 commit e75a65e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ jobs:
restore-keys: |
${{ runner.os }}-go-${{ matrix.golang }}-
- name: Compile the project
run: make go.install
run: make go.install CI=true
- name: Check go.mod and go.sum
run: |
go mod tidy -v
git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum
- name: Run tests on Unix-like operating systems
run: make unittest
run: make unittest CI=true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand All @@ -149,3 +149,13 @@ jobs:
env_vars: OS,GOLANG
name: codecov-umbrella
fail_ci_if_error: true
- name: Upload to Report.ci
if: always() && matrix.golang == 1.14
env:
REPORT_CI_TOKEN: ${{ secrets.REPORT_CI_TOKEN }}
run: |
ls -la go-install.log go-build.log go-test.json || true
# merge build logs
(cat go-install.log go-build.log > go-annotate.log) || true
curl -s https://report.ci/annotate.py | python - --input="go-annotate.log" --tool=go || true
curl -s https://report.ci/upload.py | python - --include="go-test.json" --framework=go || true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
go-test.json

# Temporary files
*~
*#
.#*
coverage.txt

go-build.log
go-install.log
go-test.json

# Vendors
package-lock.json
node_modules/
Expand Down
28 changes: 27 additions & 1 deletion rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,26 @@ GO_INSTALL_OPTS ?=
GO_TEST_OPTS ?= -test.timeout=30s
GOMOD_DIR ?= .
GOCOVERAGE_FILE ?= ./coverage.txt
GOTESTJSON_FILE ?= ./go-test.json
GOBUILDLOG_FILE ?= ./go-build.log
GOINSTALLLOG_FILE ?= ./go-install.log

ifdef GOBINS
.PHONY: go.install
go.install:
ifeq ($(CI),true)
@rm -f /tmp/goinstall.log
@set -e; for dir in $(GOBINS); do ( set -xe; \
cd $$dir; \
$(GO) install -v $(GO_INSTALL_OPTS) .; \
); done 2>&1 | tee $(GOINSTALLLOG_FILE)

else
@set -e; for dir in $(GOBINS); do ( set -xe; \
cd $$dir; \
$(GO) install $(GO_INSTALL_OPTS) .; \
); done
endif
INSTALL_STEPS += go.install

.PHONY: go.release
Expand All @@ -92,15 +104,29 @@ endif

.PHONY: go.unittest
go.unittest:
ifeq ($(CI),true)
@echo "mode: atomic" > /tmp/gocoverage
@rm -f $(GOTESTJSON_FILE)
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do (set -e; (set -euf pipefail; \
cd $$dir; \
($(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race -json | tee -a $(GOTESTJSON_FILE) 3>&1 1>&2 2>&3 | tee -a $(GOBUILDLOG_FILE); \
); \
if [ -f /tmp/profile.out ]; then \
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
rm -f /tmp/profile.out; \
fi)); done
@mv /tmp/gocoverage $(GOCOVERAGE_FILE)
else
@echo "mode: atomic" > /tmp/gocoverage
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do (set -e; (set -xe; \
cd $$dir; \
$(GO) test $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race ./...); \
$(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race); \
if [ -f /tmp/profile.out ]; then \
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
rm -f /tmp/profile.out; \
fi); done
@mv /tmp/gocoverage $(GOCOVERAGE_FILE)
endif

.PHONY: go.checkdoc
go.checkdoc:
Expand Down

0 comments on commit e75a65e

Please sign in to comment.