70 lines
1.7 KiB
YAML
70 lines
1.7 KiB
YAML
name: test
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
env:
|
|
build_path: _build
|
|
|
|
jobs:
|
|
go-test:
|
|
env:
|
|
RUNNER_TOOL_CACHE: /cache/tools
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.26.x"
|
|
|
|
- name: Get go-hashfiles
|
|
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
|
|
id: hash-go
|
|
with:
|
|
patterns: |-
|
|
go.mod
|
|
go.sum
|
|
|
|
- name: Echo hash
|
|
run: echo ${{ steps.hash-go.outputs.hash }}
|
|
|
|
- name: Cache go
|
|
id: cache-go
|
|
uses: https://github.com/actions/cache@v3 # Action cache
|
|
with: # specify with your GOMODCACHE and GOCACHE
|
|
path: |-
|
|
/root/go/pkg/mod
|
|
/root/.cache/go-build
|
|
key: go_cache-${{ steps.hash-go.outputs.hash }}
|
|
restore-keys: |-
|
|
go_cache-${{ steps.hash-go.outputs.hash }}
|
|
|
|
- name: Check Formatting
|
|
run: |
|
|
gofmt -l .
|
|
exit $(gofmt -l . | wc -l)
|
|
|
|
- name: Run tests
|
|
run: go test -v ./...
|
|
|
|
- name: Generate coverage
|
|
run: |
|
|
mkdir -p ${build_path}
|
|
go test -v -coverprofile=${build_path}/coverage.out ./...
|
|
|
|
- name: Code Coverage Report
|
|
uses: irongut/CodeCoverageSummary@v1.3.0
|
|
with:
|
|
filename: _build/coverage.out
|
|
badge: true
|
|
fail_below_min: true
|
|
format: markdown
|
|
hide_branch_rate: true
|
|
hide_complexity: false
|
|
indicators: true
|
|
output: both
|
|
thresholds: '60 80' |