diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb94962..01c0c93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: strategy: fail-fast: false matrix: + postgresql-version: [14] toolchain: [ 'stable' ] nightly: [false] include: @@ -37,6 +38,14 @@ jobs: rustup run ${{ matrix.toolchain }} cargo --version --verbose rustup run ${{ matrix.toolchain }} cargo clippy --version rustup run ${{ matrix.toolchain }} cargo fmt --version + - name: Install PostgreSQL client version matching docker-compose + env: + POSTGRESQL_VERSION: ${{ matrix.postgresql-version }} + run: | + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + sudo apt-get update + sudo apt-get -y install --no-install-recommends "postgresql-client-${POSTGRESQL_VERSION}" - name: Cache cargo registry uses: actions/cache@v3 @@ -67,11 +76,19 @@ jobs: - name: Run test - mysql | sqlx | runtime-async-std run: rustup run ${{ matrix.toolchain }} cargo test --features mysql,sqlx,runtime-async-std --all-targets --verbose + - name: Run test - postgres | diesel + run: rustup run ${{ matrix.toolchain }} cargo test --features postgres,diesel --all-targets --verbose + + - name: Run test - postgres | sqlx | runtime-async-std + run: | + export PATH="/usr/lib/postgresql/${POSTGRESQL_VERSION}/bin:$PATH" + rustup run ${{ matrix.toolchain }} cargo test --features postgres,sqlx,runtime-async-std --all-targets --verbose + - name: Stop containers for database tests if: always() run: | docker compose -f "docker-compose.yml" down --volumes - sudo rm -rf .data/{postgresql-15,mysql-8} + sudo rm -rf .data/{postgresql-${POSTGRESQL_VERSION},mysql-8} - name: Run doc tests run: rustup run ${{ matrix.toolchain }} cargo test --features sqlite,sqlx,runtime-async-std,macros --doc --verbose diff --git a/docker-compose.yml b/docker-compose.yml index 1253e57..1f3bcf1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,15 @@ # IMPORTANT: if you change the data folders below, make sure you also change their cleanup # inside the `.github/workflows/ci.yml` file services: - postgres-15: - image: postgres:15-alpine + postgres-14: + image: postgres:14-alpine ports: - "127.0.0.1:5432:5432" environment: - POSTGRES_USER=root - POSTGRES_HOST_AUTH_METHOD=trust volumes: - - .data/postgresql-15/:/var/lib/postgresql + - .data/postgresql-14/:/var/lib/postgresql mysql-8: image: mysql:8 ports: diff --git a/fixtures/diesel/postgres/diesel-postgres-structure.sql b/fixtures/diesel/postgres/diesel-postgres-structure.sql index e9930db..46fae8b 100644 --- a/fixtures/diesel/postgres/diesel-postgres-structure.sql +++ b/fixtures/diesel/postgres/diesel-postgres-structure.sql @@ -1,10 +1,3 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 15.2 --- Dumped by pg_dump version 15.4 (Homebrew) - SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; diff --git a/fixtures/sqlx/postgres/sqlx-postgres-structure.sql b/fixtures/sqlx/postgres/sqlx-postgres-structure.sql index e9930db..46fae8b 100644 --- a/fixtures/sqlx/postgres/sqlx-postgres-structure.sql +++ b/fixtures/sqlx/postgres/sqlx-postgres-structure.sql @@ -1,10 +1,3 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 15.2 --- Dumped by pg_dump version 15.4 (Homebrew) - SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; diff --git a/src/postgres/mod.rs b/src/postgres/mod.rs index f357d30..2c074da 100644 --- a/src/postgres/mod.rs +++ b/src/postgres/mod.rs @@ -1,6 +1,6 @@ //! Implementation of the `postgres` feature -pub(crate) const DEFAULT_CONNECTION_URL: &str = "postgresql://root:@localhost:5432/postgres"; +pub(crate) const DEFAULT_CONNECTION_URL: &str = "postgresql://root:@127.0.0.1:5432/postgres"; use crate::error::Error; @@ -77,13 +77,15 @@ mod tests { &destination_path, ) .await?; - let expected = std::fs::read_to_string(dbg!(format!( + let expected = std::fs::read_to_string(format!( "./{}/{}", fixtures_path.as_ref(), destination_filename.as_ref() - )))?; + ))?; + dbg!(&expected); let contents = std::fs::read_to_string(destination_path)?; - assert_eq!(contents, expected); + dbg!(&contents); + assert!(contents.contains(&expected)); Ok(()) }