-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (77 loc) · 2.04 KB
/
ci.yml
File metadata and controls
84 lines (77 loc) · 2.04 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Model Maker CI
# credit: https://github.com/pressly/goose/blob/main/.github/workflows/ci.yaml
on:
push:
branches:
- main
- develop
pull_request:
concurrency:
group: "pages"
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
jobs:
test:
name: Run unit tests
timeout-minutes: 10
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: changeme
POSTGRES_DB: appdb_test
options: >-
--health-cmd="pg_isready -U postgres -d appdb_test"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5.4.0
- name: Install Go Tools
run: |
go install github.com/joho/godotenv/cmd/godotenv@latest && \
go install github.com/nikolaydubina/go-cover-treemap@latest
- name: Wait for PostgreSQL to be ready
run: |
for i in {1..10}; do
if pg_isready -h localhost -p 5432 -U testuser -d testdb; then
echo "PostgreSQL is ready"
break
fi
echo "Waiting for PostgreSQL..."
sleep 5
done
- name: Check Go code formatting
run: |
cd app
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
gofmt -s -l .
echo "Please format Go code by running: go fmt ./..."
exit 1
fi
- name: Install tparse
run: go install github.com/mfridman/tparse@main
- name: Run tests
env:
DB_HOST: localhost
DB_NAME: appdb_test
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: changeme
DB_TIMEZONE: UTC
run: |
cd app
mkdir build
go vet ./...
go build ./...
make test