ministream/.gitea/workflows/go-test.yml
Torjus Håkestad 381523a2be
Some checks failed
release-nightly / release-image (push) Failing after 20s
Update test to only run on changed go files
2023-12-06 23:33:34 +01:00

75 lines
1.4 KiB
YAML

name: Run go tests
on:
push:
paths:
- '**.go'
pull_request:
paths:
- '**.go'
env:
GOPATH: /go_path
GOCACHE: /go_cache
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: https://github.com/actions/setup-go@v4
with:
go-version: 1.21
use-latest: true
- name: Hash go.mod and go.sum
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
id: hash-go
with:
patterns: |
go.mod
go.sum
- name: Cache go
uses: actions/cache@v3
id: cache-go
with:
path: |
/go_path
/go_cache
key: cache-go-${{ steps.hash-go.outputs.hash }}
- name: Go mod download
run: go mod download
- name: Go mod verify
run: go mod verify
- name: Go mod tidy
run: go mod tidy && git diff --exit-code
- name: Check gofmt
run: gofmt -s -w . && git diff --exit-code
- name: Check go vet
run: go vet ./...
- name: Build
run: go build -v ./...
- name: Test
run: go test -cover -coverprofile=/tmp/cov.out -v ./...
- name: Make coverage report
run: go tool cover -html=/tmp/cov.out -o /tmp/cov.html
- name: Publish coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: /tmp/cov.html