Release v1.0.0 #557
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code Coverage | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'src/**' | |
| - 'test/**' | |
| - 'sql/**' | |
| - 'Makefile' | |
| - '.github/workflows/coverage.yml' | |
| pull_request: | |
| paths: | |
| - 'src/**' | |
| - 'test/**' | |
| - 'sql/**' | |
| - 'Makefile' | |
| - '.github/workflows/coverage.yml' | |
| workflow_dispatch: | |
| jobs: | |
| coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install PostgreSQL 17 | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y wget ca-certificates gnupg | |
| wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list | |
| sudo apt-get update | |
| sudo apt-get install -y postgresql-17 postgresql-server-dev-17 | |
| - name: Install TimescaleDB | |
| run: | | |
| echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list | |
| wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add - | |
| sudo apt-get update | |
| sudo apt-get install -y timescaledb-2-postgresql-17 || echo "TimescaleDB installation failed, hypertable tests will be skipped" | |
| - name: Install coverage tools | |
| run: | | |
| sudo apt-get install -y lcov build-essential bc | |
| - name: Build extension with coverage instrumentation | |
| run: | | |
| export PATH="/usr/lib/postgresql/17/bin:$PATH" | |
| make clean | |
| # Build with coverage flags - disable optimization for accurate line counts | |
| make PG_CFLAGS="--coverage -O0 -g" SHLIB_LINK="--coverage" | |
| sudo env "PATH=$PATH" make install | |
| - name: Setup test database | |
| run: | | |
| export PATH="/usr/lib/postgresql/17/bin:$PATH" | |
| LIB_NAME="pg_textsearch" | |
| rm -rf tmp_check_shared | |
| mkdir -p tmp_check_shared | |
| initdb -D tmp_check_shared/data --auth-local=trust --auth-host=trust | |
| echo "port = 55433" >> tmp_check_shared/data/postgresql.conf | |
| echo "log_statement = 'all'" >> tmp_check_shared/data/postgresql.conf | |
| echo "shared_buffers = 256MB" >> tmp_check_shared/data/postgresql.conf | |
| echo "max_connections = 20" >> tmp_check_shared/data/postgresql.conf | |
| echo "shared_preload_libraries = '${LIB_NAME}'" >> tmp_check_shared/data/postgresql.conf | |
| echo "unix_socket_directories = '$PWD/tmp_check_shared'" >> tmp_check_shared/data/postgresql.conf | |
| pg_ctl start -D tmp_check_shared/data -l tmp_check_shared/data/logfile -w | |
| createdb -h $PWD/tmp_check_shared -p 55433 contrib_regression | |
| - name: Zero coverage counters | |
| run: | | |
| lcov --zerocounters --directory . | |
| - name: Run SQL regression tests | |
| run: | | |
| export PATH="/usr/lib/postgresql/17/bin:$PATH" | |
| make test PGHOST=$PWD/tmp_check_shared PGPORT=55433 || true | |
| # Stop and restart Postgres to flush coverage data from backend | |
| pg_ctl stop -D tmp_check_shared/data -l tmp_check_shared/data/logfile | |
| pg_ctl start -D tmp_check_shared/data -l tmp_check_shared/data/logfile -w | |
| - name: Run shell-based tests | |
| timeout-minutes: 10 | |
| run: | | |
| export PATH="/usr/lib/postgresql/17/bin:$PATH" | |
| # Run concurrency tests | |
| (cd test/scripts && ./concurrency.sh) || true | |
| # Run segment tests | |
| (cd test/scripts && ./segment.sh) || true | |
| # Run recovery tests (exercises tp_rebuild_index_from_disk) | |
| (cd test/scripts && ./recovery.sh) || true | |
| - name: Stop PostgreSQL and flush coverage | |
| run: | | |
| export PATH="/usr/lib/postgresql/17/bin:$PATH" | |
| pg_ctl stop -D tmp_check_shared/data -l tmp_check_shared/data/logfile || true | |
| - name: Run hypertable tests (exercises CustomScan code paths) | |
| timeout-minutes: 5 | |
| run: | | |
| export PATH="/usr/lib/postgresql/17/bin:$PATH" | |
| LIB_NAME="pg_textsearch" | |
| rm -rf tmp_hypertable_test | |
| mkdir -p tmp_hypertable_test | |
| initdb -D tmp_hypertable_test/data --auth-local=trust --auth-host=trust | |
| echo "port = 55434" >> tmp_hypertable_test/data/postgresql.conf | |
| echo "shared_buffers = 256MB" >> tmp_hypertable_test/data/postgresql.conf | |
| echo "shared_preload_libraries = 'timescaledb,${LIB_NAME}'" >> tmp_hypertable_test/data/postgresql.conf | |
| echo "unix_socket_directories = '$PWD/tmp_hypertable_test'" >> tmp_hypertable_test/data/postgresql.conf | |
| pg_ctl start -D tmp_hypertable_test/data -l tmp_hypertable_test/data/logfile -w | |
| export PGHOST=$PWD/tmp_hypertable_test | |
| export PGPORT=55434 | |
| (cd test/scripts && ./hypertable.sh) || true | |
| pg_ctl stop -D tmp_hypertable_test/data || true | |
| rm -rf tmp_hypertable_test | |
| - name: Capture coverage data | |
| run: | | |
| # Capture coverage from all .gcda files | |
| lcov --capture \ | |
| --directory . \ | |
| --output-file coverage.info \ | |
| --base-directory $PWD \ | |
| --no-external \ | |
| --rc branch_coverage=1 \ | |
| --ignore-errors mismatch | |
| # Remove test files from coverage report (we only care about src/) | |
| lcov --remove coverage.info \ | |
| '*/test/*' \ | |
| '*/tmp_check_shared/*' \ | |
| --output-file coverage.info \ | |
| --rc branch_coverage=1 \ | |
| --ignore-errors unused | |
| # Show summary | |
| lcov --list coverage.info --rc branch_coverage=1 | |
| - name: Restore coverage baseline | |
| if: github.event_name == 'pull_request' | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: coverage-baseline.txt | |
| key: coverage-baseline-never-matches | |
| restore-keys: | | |
| coverage-baseline- | |
| - name: Coverage gate | |
| id: coverage-gate | |
| run: | | |
| # Read old baseline if available (before we overwrite it) | |
| BASELINE="" | |
| if [ -f coverage-baseline.txt ]; then | |
| BASELINE=$(cat coverage-baseline.txt) | |
| fi | |
| # Extract current line coverage percentage | |
| CURRENT=$(lcov --summary coverage.info 2>&1 \ | |
| | grep "lines" | sed 's/.*: \([0-9.]*\)%.*/\1/') | |
| echo "Current line coverage: ${CURRENT}%" | |
| echo "line_coverage=$CURRENT" >> "$GITHUB_OUTPUT" | |
| # Save current value as baseline for future runs | |
| echo "$CURRENT" > coverage-baseline.txt | |
| # Enforce minimum coverage threshold | |
| MIN_COVERAGE=85 | |
| if (( $(echo "$CURRENT < $MIN_COVERAGE" | bc -l) )); then | |
| echo "::error::Line coverage ${CURRENT}% is below" \ | |
| "minimum ${MIN_COVERAGE}%" | |
| exit 1 | |
| fi | |
| echo "Coverage ${CURRENT}% meets minimum ${MIN_COVERAGE}%" | |
| # Check for coverage reduction on PRs | |
| if [ -n "$BASELINE" ]; then | |
| DIFF=$(echo "$CURRENT - $BASELINE" | bc -l) | |
| echo "Baseline: ${BASELINE}%, Change: ${DIFF}%" | |
| if (( $(echo "$DIFF < -1.0" | bc -l) )); then | |
| echo "::error::Coverage decreased by more than 1%:" \ | |
| "${BASELINE}% -> ${CURRENT}% (change: ${DIFF}%)" | |
| exit 1 | |
| fi | |
| echo "Coverage change (${DIFF}%) within threshold" | |
| else | |
| echo "No baseline found, skipping reduction check" | |
| fi | |
| - name: Save coverage baseline | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: coverage-baseline.txt | |
| key: coverage-baseline-${{ github.sha }} | |
| - name: Generate HTML report | |
| run: | | |
| genhtml coverage.info \ | |
| --output-directory coverage-html \ | |
| --title "pg_textsearch Coverage" \ | |
| --legend \ | |
| --show-details \ | |
| --rc branch_coverage=1 | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.info | |
| fail_ci_if_error: true | |
| verbose: true | |
| - name: Upload HTML coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage-html/ | |
| retention-days: 30 | |
| - name: Upload lcov info file | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-lcov | |
| path: coverage.info | |
| retention-days: 30 | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| export PATH="/usr/lib/postgresql/17/bin:$PATH" | |
| pg_ctl stop -D tmp_check_shared/data -l tmp_check_shared/data/logfile || true | |
| rm -rf tmp_check_shared | |
| - name: Coverage summary | |
| run: | | |
| echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Download the HTML report from the artifacts to see detailed line-by-line coverage." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Extract and display summary stats | |
| if [ -f coverage.info ]; then | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| lcov --summary coverage.info --rc branch_coverage=1 2>&1 | tail -10 >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| fi |