From fa32ff762e13b0509bb03ae0a1a4979ba1dfed62 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 13:52:55 +0300 Subject: [PATCH] Replace PostgreSQL service with several docker containers in ci.yml --- .github/workflows/ci.yml | 18 +++++------------- .github/workflows/init.sql | 4 ---- crates/teloxide/tests/postgres.rs | 12 +++++++----- 3 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/init.sql diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2d45f53..840d88ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,18 +74,6 @@ jobs: test: name: Test runs-on: ubuntu-latest - services: - # Setup Postgres for testing PostgresStorage - postgres: - image: postgres - - volumes: - - init.sql:/docker-entrypoint-initdb.d/init.sql - - env: - POSTGRES_USER: teloxide - POSTGRES_PASSWORD: rewrite_it_in_rust - strategy: matrix: rust: @@ -131,7 +119,11 @@ jobs: redis-server --port 7777 > /dev/null & redis-server --port 7778 > /dev/null & redis-server --port 7779 > /dev/null & - + - name: Start PostgreSQL servers + 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 - name: Test unit & integration tests run: | cargo +${{ matrix.toolchain }} test --tests --verbose ${{ matrix.features }} diff --git a/.github/workflows/init.sql b/.github/workflows/init.sql deleted file mode 100644 index f7da96c8..00000000 --- a/.github/workflows/init.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE ROLE teloxide WITH LOGIN SUPERUSER PASSWORD 'rewrite_it_in_rust' -CREATE DATABASE test_postgres_json; -CREATE DATABASE test_postgres_bincode; -CREATE_DATABASE test_postgres_cbor; \ No newline at end of file diff --git a/crates/teloxide/tests/postgres.rs b/crates/teloxide/tests/postgres.rs index cbcab064..12cc6ecc 100644 --- a/crates/teloxide/tests/postgres.rs +++ b/crates/teloxide/tests/postgres.rs @@ -7,12 +7,14 @@ use teloxide::{ types::ChatId, }; +// These examples are meant to run under the CI with the postgres service +// Were checked locally #[tokio::test] #[cfg_attr(not(CI_POSTGRES), ignore)] async fn test_postgres_json() { let storage = PostgresStorage::open( "postgres://teloxide:rewrite_it_in_rust@localhost:5432/test_postgres_json", - 4, + 1, teloxide::dispatching::dialogue::serializer::Json, ) .await @@ -25,8 +27,8 @@ 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:5432/test_postgres_bincode", - 4, + "postgres://teloxide:rewrite_it_in_rust@localhost:5433/test_postgres_bincode", + 1, teloxide::dispatching::dialogue::serializer::Bincode, ) .await @@ -39,8 +41,8 @@ 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:5432/test_postgres_cbor", - 4, + "postgres://teloxide:rewrite_it_in_rust@localhost:5434/test_postgres_cbor", + 1, teloxide::dispatching::dialogue::serializer::Cbor, ) .await