Try again with postgres service in ci.yml

This commit is contained in:
Сырцев Вадим Игоревич 2024-01-26 14:36:33 +03:00
parent fa32ff762e
commit 5a9bbf3f0b
2 changed files with 25 additions and 6 deletions

View file

@ -74,6 +74,20 @@ jobs:
test: test:
name: Test name: Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
services:
# Setup Postgres for testing PostgresStorage
postgres:
image: postgres
env:
POSTGRES_USER: teloxide
POSTGRES_PASSWORD: rewrite_it_in_rust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
strategy: strategy:
matrix: matrix:
rust: rust:
@ -119,11 +133,16 @@ jobs:
redis-server --port 7777 > /dev/null & redis-server --port 7777 > /dev/null &
redis-server --port 7778 > /dev/null & redis-server --port 7778 > /dev/null &
redis-server --port 7779 > /dev/null & redis-server --port 7779 > /dev/null &
- name: Start PostgreSQL servers - name: Install psql
run: | run: |
docker run -d -p 5432:5432 -e POSTGRES_USER=teloxide -e POSTGRES_PASSWORD=rewrite_it_in_rust -e POSTGRES_DB=test_postgres_json postgres apt install postgresql-client -y
docker run -d -p 5433:5432 -e POSTGRES_USER=teloxide -e POSTGRES_PASSWORD=rewrite_it_in_rust -e POSTGRES_DB=test_postgres_bincode postgres - name: Create PostgreSQL databases
docker run -d -p 5434:5432 -e POSTGRES_USER=teloxide -e POSTGRES_PASSWORD=rewrite_it_in_rust -e POSTGRES_DB=test_postgres_cbor postgres run: |
psql -h localhost -U teloxide -c "CREATE DATABASE test_postgres_json;"
psql -h localhost -U teloxide -c "CREATE DATABASE test_postgres_bincode;"
psql -h localhost -U teloxide -c "CREATE DATABASE test_postgres_cbor;"
env:
PGPASSWORD: rewrite_it_in_rust
- name: Test unit & integration tests - name: Test unit & integration tests
run: | run: |
cargo +${{ matrix.toolchain }} test --tests --verbose ${{ matrix.features }} cargo +${{ matrix.toolchain }} test --tests --verbose ${{ matrix.features }}

View file

@ -27,7 +27,7 @@ async fn test_postgres_json() {
#[cfg_attr(not(CI_POSTGRES), ignore)] #[cfg_attr(not(CI_POSTGRES), ignore)]
async fn test_postgres_bincode() { async fn test_postgres_bincode() {
let storage = PostgresStorage::open( let storage = PostgresStorage::open(
"postgres://teloxide:rewrite_it_in_rust@localhost:5433/test_postgres_bincode", "postgres://teloxide:rewrite_it_in_rust@localhost:5432/test_postgres_bincode",
1, 1,
teloxide::dispatching::dialogue::serializer::Bincode, teloxide::dispatching::dialogue::serializer::Bincode,
) )
@ -41,7 +41,7 @@ async fn test_postgres_bincode() {
#[cfg_attr(not(CI_POSTGRES), ignore)] #[cfg_attr(not(CI_POSTGRES), ignore)]
async fn test_postgres_cbor() { async fn test_postgres_cbor() {
let storage = PostgresStorage::open( let storage = PostgresStorage::open(
"postgres://teloxide:rewrite_it_in_rust@localhost:5434/test_postgres_cbor", "postgres://teloxide:rewrite_it_in_rust@localhost:5432/test_postgres_cbor",
1, 1,
teloxide::dispatching::dialogue::serializer::Cbor, teloxide::dispatching::dialogue::serializer::Cbor,
) )