Skip to content

Commit f3afa83

Browse files
author
Kroner
committed
add pipeline | fix postgres.go
1 parent 8ef482e commit f3afa83

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

.github/workflows/main.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: ci-cd
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Запускать пайплайн при пуше в ветку main
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest # или `self-hosted`, если свой раннер
12+
container:
13+
image: docker/compose:latest # Готовый образ с docker-compose
14+
options: --privileged --network host # Важно для работы Docker-in-Docker
15+
env:
16+
POSTGRES_USER: postgres # Тестовые значения, реальные в secret или .env (локально)
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: test
19+
POSTGRES_HOST: postgres
20+
POSTGRES_PORT: 5432
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Launch containers
26+
run: docker-compose up -d
27+
28+
- name: Wait for PostgreSQL
29+
run: |
30+
until docker-compose exec db pg_isready -U postgres; do
31+
sleep 2
32+
done
33+
34+
- name: Test data flow
35+
run: |
36+
# Отправляем данные в Go-сервис
37+
echo "Sending test message..."
38+
curl -X POST "http://localhost:5000/submit-text" \
39+
-H "Content-Type: application/json" \
40+
-d '{"text": "github_actions_test"}'
41+
42+
# Проверка БД
43+
echo "Checking database..."
44+
docker-compose exec postgres psql -U $POSTGRES_USER -d $POSTGRES_DB -c "SELECT * FROM messages;" # Для дебага
45+
docker-compose exec postgres psql -U $POSTGRES_USER -d $POSTGRES_DB -c "SELECT * FROM messages WHERE text = 'github_actions_test';" | grep "github_actions_test" || exit 1
46+
47+
- name: Stop containers
48+
if: always()
49+
run: docker-compose down

app_go/pkg/postgres/postgres.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ func CheckConnection(connStr string) error {
8989
}
9090

9191
return nil
92-
}
92+
}

0 commit comments

Comments
 (0)