From 5a9bbf3f0be0487963c79138e76801d0b2d55090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=8B=D1=80=D1=86=D0=B5=D0=B2=20=D0=92=D0=B0=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=98=D0=B3=D0=BE=D1=80=D0=B5=D0=B2=D0=B8=D1=87?= Date: Fri, 26 Jan 2024 14:36:33 +0300 Subject: [PATCH] Try again with postgres service in ci.yml --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++---- crates/teloxide/tests/postgres.rs | 4 ++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 840d88ec..d344add2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,20 @@ jobs: test: name: Test 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: matrix: rust: @@ -119,11 +133,16 @@ jobs: redis-server --port 7777 > /dev/null & redis-server --port 7778 > /dev/null & redis-server --port 7779 > /dev/null & - - name: Start PostgreSQL servers + - name: Install psql 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 - docker run -d -p 5433:5432 -e POSTGRES_USER=teloxide -e POSTGRES_PASSWORD=rewrite_it_in_rust -e POSTGRES_DB=test_postgres_bincode postgres - docker run -d -p 5434:5432 -e POSTGRES_USER=teloxide -e POSTGRES_PASSWORD=rewrite_it_in_rust -e POSTGRES_DB=test_postgres_cbor postgres + apt install postgresql-client -y + - name: Create PostgreSQL databases + 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 run: | cargo +${{ matrix.toolchain }} test --tests --verbose ${{ matrix.features }} diff --git a/crates/teloxide/tests/postgres.rs b/crates/teloxide/tests/postgres.rs index 12cc6ecc..37027484 100644 --- a/crates/teloxide/tests/postgres.rs +++ b/crates/teloxide/tests/postgres.rs @@ -27,7 +27,7 @@ async fn test_postgres_json() { #[cfg_attr(not(CI_POSTGRES), ignore)] async fn test_postgres_bincode() { 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, teloxide::dispatching::dialogue::serializer::Bincode, ) @@ -41,7 +41,7 @@ async fn test_postgres_bincode() { #[cfg_attr(not(CI_POSTGRES), ignore)] async fn test_postgres_cbor() { 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, teloxide::dispatching::dialogue::serializer::Cbor, )