diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c91f19b7e..c226b5ae5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -220,6 +220,21 @@ jobs: - beta - nightly + services: + postgres: + image: docker.io/library/postgres:14.4 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - "5432:5432" + steps: - name: Checkout the code uses: actions/checkout@v3 @@ -259,12 +274,6 @@ jobs: target key: ${{ runner.os }}-cargo-build-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} - - name: Start PostgreSQL database - run: | - sudo systemctl start postgresql.service - pg_isready - sudo -u postgres psql --command="CREATE USER test PASSWORD 'test'" --command="\du" - - name: Test id: test uses: actions-rs/cargo@v1 @@ -272,7 +281,7 @@ jobs: command: test args: --offline --workspace env: - DATABASE_URL: postgresql://test:test@localhost/postgres + DATABASE_URL: postgresql://postgres:postgres@localhost/postgres SQLX_OFFLINE: '1' # Ignore errors on the nightly toolchain @@ -292,6 +301,21 @@ jobs: permissions: contents: read + services: + postgres: + image: docker.io/library/postgres:14.4 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - "5432:5432" + steps: - name: Checkout the code uses: actions/checkout@v3 @@ -337,12 +361,6 @@ jobs: curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.7/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Start PostgreSQL database - run: | - sudo systemctl start postgresql.service - pg_isready - sudo -u postgres psql --command="CREATE USER test PASSWORD 'test'" --command="\du" - - name: Run test suite with profiling enabled uses: actions-rs/cargo@v1 with: @@ -352,7 +370,7 @@ jobs: CARGO_INCREMENTAL: '0' RUSTFLAGS: '-Cinstrument-coverage' LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw" - DATABASE_URL: postgresql://test:test@localhost/postgres + DATABASE_URL: postgresql://postgres:postgres@localhost/postgres SQLX_OFFLINE: '1' - name: Build grcov report