add workflow for tests #1
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: Go Tests | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres-test: | |
image: postgres:17.2 | |
ports: | |
- "5432:5432" | |
env: | |
POSTGRES_DB: maek_test | |
POSTGRES_USER: maek | |
POSTGRES_PASSWORD: passwd | |
options: >- | |
--health-cmd "pg_isready -U maek -d maek_test" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23.1' | |
- run: go version | |
- name: Install Go modules | |
run: go mod download | |
- name: Run Go tests with coverage | |
run: | | |
export SQL_CONN_TEST="postgres://maek:passwd@localhost:5432/maek_test?sslmode=disable" | |
export CGO_ENABLED=0 | |
go test -v -coverprofile=coverage.out -covermode=atomic $(go list ./... | grep -v /vendor/) |