Amp-Thread-ID: https://ampcode.com/threads/T-056a25c4-ad39-4124-99b8-b459b3e21305 Co-authored-by: Amp <amp@ampcode.com>
63 lines
1.4 KiB
YAML
63 lines
1.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Build
|
|
run: go build -v ./cmd/bd
|
|
|
|
- name: Test
|
|
run: go test -v -race -coverprofile=coverage.out ./...
|
|
|
|
- name: Check coverage threshold
|
|
run: |
|
|
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
|
|
echo "Coverage: $COVERAGE%"
|
|
if (( $(echo "$COVERAGE < 50" | bc -l) )); then
|
|
echo "❌ Coverage is below 50% threshold"
|
|
exit 1
|
|
elif (( $(echo "$COVERAGE < 55" | bc -l) )); then
|
|
echo "⚠️ Coverage is below 55% (warning threshold)"
|
|
else
|
|
echo "✅ Coverage meets threshold"
|
|
fi
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
if: success()
|
|
with:
|
|
file: ./coverage.out
|
|
fail_ci_if_error: false
|
|
|
|
lint:
|
|
name: Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
version: v1.62.0
|
|
args: --timeout=5m
|