Skip to content

Releases: Eiley2/postgres-branching

v1.0.5

Choose a tag to compare

@Eiley2 Eiley2 released this 09 Feb 06:03
v1.0.5
b9daff6

Release Notes - v1.0.5

Highlights

  • Fixed leaked advisory lock-holder sessions that could block subsequent CI runs.
  • Hardened stale-lock recovery for create with safer targeting and retry behavior.
  • Added stronger regression coverage, including real grant-permission verification for app users.

What Changed

  • Lock reliability in scripts/preview-branch.sh:

    • Track and terminate the exact PostgreSQL backend PID used by the lock-holder session.
    • Keep stale-lock cleanup scoped to application_name=postgres-branching-lock-holder.
    • Preserve timeout recovery flow (cleanup + retry) for lock acquisition.
  • Regression tests for lock behavior:

    • tests/test_create_action_integration.sh
      • run create twice and assert no lingering lock-holder session
      • inject synthetic stale lock-holder and verify auto-cleanup + retry path
      • strengthen cleanup for lock-holder backends
    • tests/test_create_action.sh
      • make mock psql counter concurrency-safe with file locking
      • align negative-path env setup consistency
  • Grant-permission coverage improvements:

    • tests/test_reset_action.sh
      • add grant SQL coverage for reset flow with APP_DB_USER
    • tests/test_create_action_integration.sh
      • validate effective read/write privileges for APP_DB_USER
      • validate default privileges on new tables/sequences created after grant
    • tests/test_reset_action_integration.sh
      • same effective-permission and default-privilege validation after reset

Validation

Executed locally and in integration Docker PostgreSQL 18:

  • bash tests/test_create_action.sh
  • bash tests/test_reset_action.sh
  • bash tests/test_delete_action.sh
  • bash tests/test_create_action_integration.sh
  • bash tests/test_reset_action_integration.sh
  • bash tests/test_delete_action_integration.sh

Compatibility

  • No breaking input/output changes.
  • Existing workflows remain compatible.

What's Changed

  • fix: prevent leaked advisory lock holders and add regression tests by @Eiley2 in #2

Full Changelog: v1.0.4...v1.0.5

v1.0.4

Choose a tag to compare

@Eiley2 Eiley2 released this 09 Feb 05:34
v1.0.4
cae0cb5

Release Notes - v1.0.4

Highlights

  • Added robust stale-lock self-healing to avoid manual unlocks after interrupted runners.
  • Reduced default advisory lock wait timeout from 300s to 180s.
  • Added integration coverage for double-create runs to catch lock-leak/deadlock regressions.

What Changed

  • Lock acquisition hardening:
    • Added lock-holder app name: postgres-branching-lock-holder.
    • Added lock-holder keepalive tuning for faster dead-session detection:
      • LOCK_TCP_KEEPALIVES_IDLE_SEC (default 30)
      • LOCK_TCP_KEEPALIVES_INTERVAL_SEC (default 10)
      • LOCK_TCP_KEEPALIVES_COUNT (default 3)
    • Added stale-lock cleanup on timeout with one retry:
      • LOCK_STALE_AFTER_SEC (default 1800)
  • Reduced default lock wait timeout:
    • LOCK_WAIT_TIMEOUT_SEC default changed from 300 to 180.
  • Expanded docs:
    • Added lock behavior details and lock tuning environment variables.
  • New integration safety test:
    • create run twice in sequence on the same branch.
    • Verifies second run is no-op and no lingering lock-holder query remains.

Validation

  • Unit tests:
    • tests/test_create_action.sh
    • tests/test_delete_action.sh
    • tests/test_reset_action.sh
  • Integration script syntax:
    • tests/test_create_action_integration.sh

Compatibility

  • No breaking input/output changes.
  • Existing workflows remain compatible.

Full Changelog: v1.0.3...v1.0.4

v1.0.3

Choose a tag to compare

@Eiley2 Eiley2 released this 09 Feb 05:12
v1.0.3
8b2d9d4

Release Notes - v1.0.3

Highlights

  • create is now retry-safe in CI/CD when a previous run left the operation lock active.
  • Action logs were expanded to make GitHub Actions output much easier to follow.
  • Docker/client-version fallback now explains exactly why Docker is being used.

What Changed

  • Added create fallback behavior:
    • If lock wait times out and preview DB already exists, create exits successfully as a no-op.
  • Added more operational logs across the workflow:
    • command start context (command, branch, lock/clone settings)
    • lock behavior (disabled, waiting, acquired, timeout fallback)
    • create/reset/delete intent
    • clone strategy decisions and completion (local vs docker)
    • grant step skipped when APP_DB_USER is not provided
  • Improved Docker messaging:
    • explicit mismatch reason (local client major vs server major)
    • clearer guidance to install Docker when required

Tests

  • Added/updated create-action tests to cover:
    • timeout + existing preview DB no-op path
    • docker-switch log visibility on version mismatch
  • Existing create/delete/reset test suites continue passing.

Compatibility

  • No breaking input/output changes.
  • Existing workflows remain compatible.

v1.0.2

Choose a tag to compare

@Eiley2 Eiley2 released this 09 Feb 01:57
3217533

Highlights in v1.0.2

  • Stable create, reset, and delete flows
  • Safer behavior for concurrent operations targeting the same preview DB
  • Lock wait timeout behavior documented and enforced
  • Flexible cloning strategy (auto, local, docker)
  • Better Docker + SSL environment compatibility in clone paths
  • Improved app-user grant behavior for preview DB access
  • README improvements, including clear with field explanations

Compatibility

  • Validated with PostgreSQL versions 13 to 18
  • Unit and integration tests included in CI

Quick usage examples

Create

- uses: Eiley2/postgres-branching/create@v1
  with:
    branch_name: pr_${{ github.event.number }}
    parent_branch: app_main
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}

Reset

- uses: Eiley2/postgres-branching/reset@v1
  with:
    branch_name: pr_${{ github.event.number }}
    parent_branch: app_main
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}

Delete

- uses: Eiley2/postgres-branching/delete@v1
  with:
    branch_name: pr_${{ github.event.number }}
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}

Tags

  • v1.0.2 published
  • v1 and latest updated to point to v1.0.2

Postgres Branching v1.0.0

Choose a tag to compare

@Eiley2 Eiley2 released this 09 Feb 00:52
bead720

Project Goal

Postgres Branching aims to replicate Neon-style branching workflows on standard PostgreSQL, mainly for QA and preview environments in GitHub pull requests.

This project is vibe coded: it started as fast AI-assisted development, then was hardened through real CI feedback, unit tests, and integration tests.


What It Does

This action automates preview database lifecycle with 3 actions:

  • create -> Create a preview DB from a parent/source DB
  • reset -> Rebuild a preview DB from the parent/source DB
  • delete -> Remove a preview DB when no longer needed

In short: Neon-like DB branching behavior for regular PostgreSQL, designed for GitHub workflows.


GitHub Actions Examples

1. Create Preview DB

- name: Create preview database
  uses: Eiley2/postgres-branching/create@v1
  with:
    branch_name: pr_${{ github.event.number }}
    parent_branch: app_main
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}
    pg_database: postgres
    clone_strategy: auto

2. Reset Preview DB

- name: Reset preview database
  uses: Eiley2/postgres-branching/reset@v1
  with:
    branch_name: pr_${{ github.event.number }}
    parent_branch: app_main
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}
    pg_database: postgres
    clone_strategy: auto

3. Delete Preview DB

- name: Delete preview database
  uses: Eiley2/postgres-branching/delete@v1
  with:
    branch_name: pr_${{ github.event.number }}
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}
    pg_database: postgres

Full PR Workflow Example

name: Preview Database Lifecycle

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]

jobs:
  preview-db:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Create preview DB on open/update
        if: github.event.action != 'closed'
        uses: Eiley2/postgres-branching/create@v1
        with:
          branch_name: pr_${{ github.event.number }}
          parent_branch: app_main
          pg_host: ${{ secrets.PGHOST }}
          pg_port: ${{ secrets.PGPORT }}
          pg_user: ${{ secrets.PGUSER }}
          pg_password: ${{ secrets.PGPASSWORD }}

      - name: Delete preview DB on close
        if: github.event.action == 'closed'
        uses: Eiley2/postgres-branching/delete@v1
        with:
          branch_name: pr_${{ github.event.number }}
          pg_host: ${{ secrets.PGHOST }}
          pg_port: ${{ secrets.PGPORT }}
          pg_user: ${{ secrets.PGUSER }}
          pg_password: ${{ secrets.PGPASSWORD }}

Required GitHub Secrets

  • PGHOST
  • PGPORT
  • PGUSER
  • PGPASSWORD

Postgres Branching for GitHub Actions (Create, Reset, Delete Preview DBs)

Choose a tag to compare

@Eiley2 Eiley2 released this 09 Feb 02:14
v1
b9daff6

Project Goal

Postgres Branching aims to replicate Neon-style branching workflows on standard PostgreSQL, mainly for QA and preview environments in GitHub pull requests.

This project is vibe coded: it started as fast AI-assisted development, then was hardened through real CI feedback, unit tests, and integration tests.


What It Does

This action automates preview database lifecycle with 3 actions:

  • create -> Create a preview DB from a parent/source DB
  • reset -> Rebuild a preview DB from the parent/source DB
  • delete -> Remove a preview DB when no longer needed

In short: Neon-like DB branching behavior for regular PostgreSQL, designed for GitHub workflows.


GitHub Actions Examples

1. Create Preview DB

- name: Create preview database
  uses: Eiley2/postgres-branching/create@v1
  with:
    branch_name: pr_${{ github.event.number }}
    parent_branch: app_main
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}
    pg_database: postgres
    clone_strategy: auto

2. Reset Preview DB

- name: Reset preview database
  uses: Eiley2/postgres-branching/reset@v1
  with:
    branch_name: pr_${{ github.event.number }}
    parent_branch: app_main
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}
    pg_database: postgres
    clone_strategy: auto

3. Delete Preview DB

- name: Delete preview database
  uses: Eiley2/postgres-branching/delete@v1
  with:
    branch_name: pr_${{ github.event.number }}
    pg_host: ${{ secrets.PGHOST }}
    pg_port: ${{ secrets.PGPORT }}
    pg_user: ${{ secrets.PGUSER }}
    pg_password: ${{ secrets.PGPASSWORD }}
    pg_database: postgres

Full PR Workflow Example

name: Preview Database Lifecycle

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]

jobs:
  preview-db:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Create preview DB on open/update
        if: github.event.action != 'closed'
        uses: Eiley2/postgres-branching/create@v1
        with:
          branch_name: pr_${{ github.event.number }}
          parent_branch: app_main
          pg_host: ${{ secrets.PGHOST }}
          pg_port: ${{ secrets.PGPORT }}
          pg_user: ${{ secrets.PGUSER }}
          pg_password: ${{ secrets.PGPASSWORD }}

      - name: Delete preview DB on close
        if: github.event.action == 'closed'
        uses: Eiley2/postgres-branching/delete@v1
        with:
          branch_name: pr_${{ github.event.number }}
          pg_host: ${{ secrets.PGHOST }}
          pg_port: ${{ secrets.PGPORT }}
          pg_user: ${{ secrets.PGUSER }}
          pg_password: ${{ secrets.PGPASSWORD }}

Required GitHub Secrets

  • PGHOST
  • PGPORT
  • PGUSER
  • PGPASSWORD