fix: standardize structured output #179
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run tests | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "*.go" | |
- ".github/workflows/*" | |
- "README.md" | |
pull_request: | |
paths: | |
- "*.go" | |
- ".github/workflows/*" | |
- "README.md" | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.21 | |
- uses: actions/checkout@v3 | |
- run: go build -v ./... | |
- run: go install github.com/jpoles1/gopherbadger@latest | |
- run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest | |
# Run tests with nice formatting. Save the original log in /tmp/gotest.log | |
- name: Run tests | |
run: | | |
set -euo pipefail | |
go test -p 1 -json -v -covermode atomic -coverprofile=cover.out ./... 2>&1 | tee /tmp/gotest.log | gotestfmt | |
- name: Upload original test log | |
uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: test-log | |
path: /tmp/gotest.log | |
if-no-files-found: error | |
- name: Generate coverage badge | |
run: gopherbadger -style=for-the-badge -covercmd "go tool cover -func=cover.out" | |
- name: Commit coverage badge | |
uses: EndBug/add-and-commit@v7 | |
with: | |
message: "ci: update coverage" | |
add: "coverage_badge.png" | |
author_name: "github-actions[bot]" | |
author_email: "github-actions[bot]@users.noreply.github.com" | |
- run: ./update-usage-readme.sh | |
- name: Commit README update | |
uses: EndBug/add-and-commit@v7 | |
with: | |
message: "ci: update binary usage in README" | |
add: "README.md" | |
author_name: "github-actions[bot]" | |
author_email: "github-actions[bot]@users.noreply.github.com" |