Skip to content

Commit

Permalink
github CI test runner, first attempt
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Bray <tbray@textuality.com>
  • Loading branch information
timbray committed Apr 8, 2024
1 parent 8024d43 commit e286224
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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

0 comments on commit e286224

Please sign in to comment.