Repository navigation
54 lines (46 loc) · 1.42 KB
/
Copy pathpush.yml
File metadata and controls
54 lines (46 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Build and Test
on:
push:
branches:
- "**"
jobs:
build:
name: Build
runs-on: ubuntu-latest
services:
# Lets the Postgres integration tests run (they skip when
# GOBLOG_TEST_POSTGRES_DSN is unset, e.g. locally).
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: goblog
POSTGRES_PASSWORD: goblog
POSTGRES_DB: goblog
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U goblog"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- name: Set up Go 1.22.2
uses: actions/setup-go@v6
with:
go-version: 1.26.1
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -ldflags="-X 'main.Version=$(git rev-parse HEAD)'" -v .
- name: Test
env:
GOBLOG_TEST_POSTGRES_DSN: host=localhost port=5432 user=goblog password=goblog dbname=goblog sslmode=disable
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...