Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions .github/workflows/ci-new-parser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ jobs:
id: pgdog-bin
uses: actions/cache/restore@v5
with:
path: |
target/debug/pgdog
target/release/pgdog
path: target/debug/pgdog
key: ${{ steps.cache-key.outputs.key }}
- uses: Swatinem/rust-cache@v2
if: steps.pgdog-bin.outputs.cache-hit != 'true'
Expand All @@ -36,16 +34,11 @@ jobs:
- name: Build (debug)
if: steps.pgdog-bin.outputs.cache-hit != 'true'
run: cargo build --no-default-features --features new_parser --bin pgdog
- name: Build (release)
if: steps.pgdog-bin.outputs.cache-hit != 'true'
run: cargo build --release --no-default-features --features new_parser --bin pgdog
- name: Save pgdog binaries
if: steps.pgdog-bin.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
target/debug/pgdog
target/release/pgdog
path: target/debug/pgdog
key: ${{ steps.cache-key.outputs.key }}

ci:
Expand Down Expand Up @@ -79,7 +72,7 @@ jobs:
# cached pgdog binary.
- { name: plugins, script: integration/plugins/run.sh, needs_rust_cache: true, continue_on_error: true }
env:
PGDOG_BIN: ${{ github.workspace }}/target/release/pgdog
PGDOG_BIN: ${{ github.workspace }}/target/debug/pgdog
PGDOG_PLUGIN_FEATURES: new_parser
steps:
- uses: actions/checkout@v6
Expand All @@ -89,8 +82,8 @@ jobs:
id: cache-key
run: echo "key=pgdog-bin-new-parser-${{ runner.os }}-$(bash integration/ci/cache-key.sh)" >> "$GITHUB_OUTPUT"
# rust-cache must run before the binary restore: it lays down a
# stale target/ that can otherwise wipe target/release/pgdog when
# cargo reconciles fingerprints during plugin builds.
# stale target/ that can otherwise wipe target binaries when cargo
# reconciles fingerprints during plugin builds.
- name: Restore Rust cache for plugin builds
if: matrix.needs_rust_cache
uses: Swatinem/rust-cache@v2
Expand All @@ -99,9 +92,7 @@ jobs:
- name: Restore pgdog binaries
uses: actions/cache/restore@v5
with:
path: |
target/debug/pgdog
target/release/pgdog
path: target/debug/pgdog
key: ${{ steps.cache-key.outputs.key }}
fail-on-cache-miss: true
- name: Setup dependencies
Expand Down
83 changes: 60 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,25 @@ on:
types: [opened, synchronize, reopened]

jobs:
# Build both pgdog artifacts in parallel:
# - release: plain release binary
# - coverage: llvm-cov instrumented debug binary used by the
# integration suites to produce line coverage for Codecov
build:
runs-on: blacksmith-4vcpu-ubuntu-2404
strategy:
fail-fast: false
matrix:
include:
- artifact: release
path: target/release/pgdog
rust_prefix: build-v1
- artifact: coverage
path: target/llvm-cov-target/debug/pgdog
# Separate prefix: instrumented artifacts live in
# target/llvm-cov-target and must not race with the plain
# build's cache.
rust_prefix: build-cov-debug-v1
steps:
- uses: actions/checkout@v6
- name: Install CI deps
Expand All @@ -17,35 +34,31 @@ jobs:
# target/ build outputs that would otherwise change the key. Use the
# split cache actions so pgdog binaries are saved immediately after the
# build, before rust-cache's post-job cleanup prunes workspace binaries
# from target/{debug,release}.
# from target/.
- name: Compute cache key
id: cache-key
run: echo "key=pgdog-bin-${{ runner.os }}-$(bash integration/ci/cache-key.sh)" >> "$GITHUB_OUTPUT"
- name: Restore pgdog binaries
run: echo "key=pgdog-bin-${{ runner.os }}-${{ matrix.artifact }}-$(bash integration/ci/cache-key.sh)" >> "$GITHUB_OUTPUT"
- name: Restore pgdog binary
id: pgdog-bin
uses: actions/cache/restore@v5
with:
path: |
target/debug/pgdog
target/release/pgdog
path: ${{ matrix.path }}
key: ${{ steps.cache-key.outputs.key }}
- uses: Swatinem/rust-cache@v2
if: steps.pgdog-bin.outputs.cache-hit != 'true'
with:
prefix-key: build-v1
- name: Build (debug)
if: steps.pgdog-bin.outputs.cache-hit != 'true'
run: cargo build --bin pgdog
prefix-key: ${{ matrix.rust_prefix }}
- name: Build (release)
if: steps.pgdog-bin.outputs.cache-hit != 'true'
if: steps.pgdog-bin.outputs.cache-hit != 'true' && matrix.artifact == 'release'
run: cargo build --release --bin pgdog
- name: Save pgdog binaries
- name: Build (instrumented debug, for coverage)
if: steps.pgdog-bin.outputs.cache-hit != 'true' && matrix.artifact == 'coverage'
run: bash integration/ci/prepare-instrumented-pgdog.sh debug
- name: Save pgdog binary
if: steps.pgdog-bin.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
target/debug/pgdog
target/release/pgdog
path: ${{ matrix.path }}
key: ${{ steps.cache-key.outputs.key }}

ci:
Expand Down Expand Up @@ -79,34 +92,58 @@ jobs:
# cached pgdog binary.
- { name: plugins, script: integration/plugins/run.sh, needs_rust_cache: true, continue_on_error: true }
env:
PGDOG_BIN: ${{ github.workspace }}/target/release/pgdog
# All suites run against the llvm-cov instrumented debug binary so we
# get line coverage from integration tests, not just unit tests.
PGDOG_BIN: ${{ github.workspace }}/target/llvm-cov-target/debug/pgdog
# NB: cargo llvm-cov report only globs profraw files at the top of
# target/llvm-cov-target, so LLVM_PROFILE_FILE must point there.
LLVM_PROFILE_FILE: ${{ github.workspace }}/target/llvm-cov-target/${{ matrix.name }}-%p-%m.profraw
steps:
- uses: actions/checkout@v6
- name: Install CI deps
run: bash integration/ci/install-deps.sh
- name: Compute cache key
id: cache-key
run: echo "key=pgdog-bin-${{ runner.os }}-$(bash integration/ci/cache-key.sh)" >> "$GITHUB_OUTPUT"
run: echo "key=pgdog-bin-${{ runner.os }}-coverage-$(bash integration/ci/cache-key.sh)" >> "$GITHUB_OUTPUT"
# rust-cache must run before the binary restore: it lays down a
# stale target/ that can otherwise wipe target/release/pgdog when
# cargo reconciles fingerprints during plugin builds.
# stale target/ that can otherwise wipe target binaries when cargo
# reconciles fingerprints during plugin builds.
- name: Restore Rust cache for plugin builds
if: matrix.needs_rust_cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: build-v1
- name: Restore pgdog binaries
- name: Restore instrumented pgdog binary
uses: actions/cache/restore@v5
with:
path: |
target/debug/pgdog
target/release/pgdog
path: target/llvm-cov-target/debug/pgdog
key: ${{ steps.cache-key.outputs.key }}
fail-on-cache-miss: true
# The Rust cache (plugins job) can lay down stale .profraw files that
# don't match the restored instrumented binary; start clean.
- name: Prepare coverage profile dir
run: |
mkdir -p target/llvm-cov-target
rm -f target/llvm-cov-target/*.profraw target/llvm-cov-target/*.profdata
- name: Setup dependencies
run: bash integration/ci/setup.sh --with-toxi
- name: Run ${{ matrix.name }}
run: bash ${{ matrix.script }}
- name: Ensure PgDog stopped
if: always()
run: bash integration/ci/ensure-pgdog-stopped.sh
- name: Generate coverage report
if: always()
run: cargo llvm-cov report --package pgdog --lcov --output-path ${{ matrix.name }}.lcov
# Codecov merges uploads per flag server-side, so each suite uploads
# its own lcov under the shared "integration" flag.
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ${{ matrix.name }}.lcov
flags: integration
name: integration-${{ matrix.name }}
fail_ci_if_error: false
7 changes: 7 additions & 0 deletions integration/ci/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ if ! command -v cargo-llvm-cov >/dev/null; then
curl -LsSf "https://github.com/taiki-e/cargo-llvm-cov/releases/download/v${LLVM_COV_VERSION}/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz" \
| tar zxf - -C "$CARGO_BIN"
fi

# cargo llvm-cov report needs llvm-profdata/llvm-cov from llvm-tools-preview.
if command -v rustup >/dev/null 2>&1; then
if ! rustup component list --installed 2>/dev/null | grep -q llvm-tools; then
rustup component add llvm-tools-preview || true
fi
fi
24 changes: 20 additions & 4 deletions integration/ci/prepare-instrumented-pgdog.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
#!/usr/bin/env bash
# Build an llvm-cov-instrumented pgdog binary for the integration job and
# export its path via $GITHUB_ENV so later steps can invoke it.
#
# Usage: prepare-instrumented-pgdog.sh [debug|release] (default: release)
set -euo pipefail

export RUSTFLAGS="-C link-dead-code"
PROFILE="${1:-release}"
if [[ "${PROFILE}" != "debug" && "${PROFILE}" != "release" ]]; then
echo "Usage: $0 [debug|release]" >&2
exit 1
fi

PROFILE_FLAG=""
if [[ "${PROFILE}" == "release" ]]; then
PROFILE_FLAG="--release"
fi

# RUSTFLAGS overrides .cargo/config.toml rustflags entirely, so
# tokio_unstable (set there) must be repeated here.
export RUSTFLAGS="--cfg tokio_unstable -C link-dead-code"

cargo llvm-cov clean --workspace
mkdir -p target/llvm-cov-target/profiles
cargo llvm-cov run --no-report --release --package pgdog --bin pgdog -- --help
# shellcheck disable=SC2086
cargo llvm-cov run --no-report ${PROFILE_FLAG} --package pgdog --bin pgdog -- --help
rm -f target/llvm-cov-target/profiles/*.profraw
rm -f target/llvm-cov-target/profiles/.last_snapshot
rm -rf target/llvm-cov-target/reports

BIN_PATH=$(find target/llvm-cov-target -type f -path '*/release/pgdog' | head -n 1)
BIN_PATH=$(find target/llvm-cov-target -type f -path "*/${PROFILE}/pgdog" | head -n 1)
if [ -z "$BIN_PATH" ]; then
echo "Instrumented PgDog binary not found" >&2
echo "Instrumented PgDog binary (${PROFILE}) not found" >&2
exit 1
fi
echo "Using instrumented binary at $BIN_PATH"
Expand Down
3 changes: 3 additions & 0 deletions pgdog/src/backend/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ impl Databases {
cluster.user(),
cluster.name()
);
// No boot-time maintenance will run, don't block
// readiness waiters. Checkouts will fail instead.
cluster.mark_ready();
} else {
cluster.launch();
}
Expand Down
Loading
Loading