49 lines
1.1 KiB
YAML
49 lines
1.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: 'go.mod'
|
|
cache: true
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
env:
|
|
GOPROXY: https://proxy.golang.org,direct
|
|
GOSUMDB: sum.golang.org
|
|
|
|
- name: Lint GitHub workflows
|
|
run: |
|
|
go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.8
|
|
"$(go env GOPATH)/bin/actionlint" -color
|
|
|
|
- name: Build
|
|
run: go build ./...
|
|
|
|
- name: Run tests
|
|
run: go test ./... -v -race
|
|
|
|
- name: Run tests with coverage
|
|
run: go test ./... -coverprofile=coverage.out -covermode=atomic
|
|
|
|
- name: Upload coverage to Codecov (optional)
|
|
uses: codecov/codecov-action@v4
|
|
if: github.event_name == 'push'
|
|
with:
|
|
files: ./coverage.out
|
|
fail_ci_if_error: false
|