Rename root package: db -> dbkit #7
Workflow file for this run
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: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
test: | |
name: Test | |
strategy: | |
matrix: | |
go: [ '1.20' ] | |
os: [ ubuntu-latest ] | |
fail-fast: true | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Go ${{ matrix.go }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
cache: false | |
- name: Install dependencies | |
run: go mod download | |
- name: Run tests with coverage | |
run: go test -race -cover -coverprofile="coverage.out" -covermode=atomic -v --coverpkg=./... ./... | |
- name: Check coverage | |
run: | | |
real_coverage=$(go tool cover -func=coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}') | |
min_coverage=$(cat min-coverage.txt) | |
if (( $(echo "$real_coverage < $min_coverage" | bc -l) )); then | |
echo "Coverage check failed: $real_coverage% is lower than the required $min_coverage%" | |
exit 1 | |
else | |
echo "Coverage check passed: $real_coverage% meets the minimum requirement of $min_coverage%" | |
fi |