Skip to content

Add CI workflow for linting, tests, and coverage #1

Add CI workflow for linting, tests, and coverage

Add CI workflow for linting, tests, and coverage #1

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
- uses: golangci/golangci-lint-action@v6
with:
version: latest
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Run library tests with coverage
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Report coverage
run: |
go tool cover -func=coverage.out
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')
echo "Total coverage: ${COVERAGE}%"
if [ "$(echo "$COVERAGE < 40" | bc)" -eq 1 ]; then
echo "::error::Coverage ${COVERAGE}% is below 40% threshold"
exit 1
fi