ci: add lint, coverage check and proper deploy workflow
This commit is contained in:
@@ -2,10 +2,12 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [dev]
|
||||
branches-ignore: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
lint-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -17,11 +19,19 @@ jobs:
|
||||
- name: Tidy
|
||||
run: go mod tidy
|
||||
|
||||
- name: Vet
|
||||
run: go vet ./...
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Test
|
||||
run: go test ./... -v
|
||||
run: go test ./... -coverprofile=coverage.out -covermode=atomic
|
||||
|
||||
- name: Build
|
||||
run: CGO_ENABLED=0 go build -o main ./cmd/api
|
||||
- name: Coverage Check
|
||||
run: |
|
||||
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')
|
||||
echo "Coverage: ${COVERAGE}%"
|
||||
if (( $(echo "$COVERAGE < 85" | bc -l) )); then
|
||||
echo "::error::Coverage ${COVERAGE}% is below 85%"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user