Skip to content

Commit b0c7c32

Browse files
committed
run tests in ci?
1 parent 79a61df commit b0c7c32

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Go Tests with Docker Compose
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Docker Compose
17+
run: docker compose version
18+
19+
- name: Build and run services
20+
run: docker compose up -d --build
21+
22+
- name: Wait for Postgres to be ready
23+
run: |
24+
until docker-compose exec -T db pg_isready -U testuser; do
25+
echo "Waiting for Postgres..."
26+
sleep 2
27+
done
28+
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version: '1.22'
34+
35+
- name: Install dependencies
36+
run: go mod tidy
37+
38+
- name: Run tests
39+
run: go test -cover ./...
40+
41+
42+
- name: Shutdown
43+
if: always()
44+
run: docker-compose down

0 commit comments

Comments
 (0)