github CI test runner, second attempt #2
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: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
tests: | |
name: Tests and coverage | |
strategy: | |
matrix: | |
go-version: [ "1.19" ] | |
platform: [ "ubuntu-latest" ] | |
goflags: [ "-v -count=1 -json" ] | |
coveropts: [ "-coverprofile=coverage.txt -covermode=atomic" ] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 1 | |
- name: Set up Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ matrix.go-version }} | |
id: go | |
- name: Restore Go cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum', 'testdata/**') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ matrix.go-version }}- | |
- name: Install tparse | |
run: go install github.com/mfridman/tparse@latest | |
- name: Check for .codecov.yaml | |
id: codecov-enabled | |
uses: andstor/file-existence-action@latest | |
with: | |
files: .codecov.yaml | |
- name: Test | |
env: | |
COVER_OPTS: ${{ matrix.coveropts }} | |
GOFLAGS: ${{ matrix.goflags }} | |
run: go test $COVER_OPTS ./... | tparse -all -notests -format markdown >> $GITHUB_STEP_SUMMARY | |
- if: steps.codecov-enabled.outputs.files_exists == 'true' | |
name: Upload Codecov Report | |
uses: codecov/codecov-action@latest | |
- name: Verify git clean | |
shell: bash | |
run: | | |
if [[ -z "$(git status --porcelain)" ]]; then | |
echo "${{ github.repository }} up to date." | |
else | |
echo "${{ github.repository }} is dirty." | |
echo "::error:: $(git status)" | |
exit 1 | |
fi | |