Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
558b441
chore: backport 33b49ebe981ce2756a634205ad19e2eea0897606 to current p…
darora Aug 12, 2024
f069325
chore: build AMI on release branch
darora Aug 12, 2024
3ddf2d2
chore: also release docker image
darora Aug 12, 2024
9559a10
chore: release pg_upgrade scripts off release branches
darora Aug 12, 2024
1cf22f8
fix: watch correct spec
darora Aug 12, 2024
5dcba64
fix: wrappers nix-based pg_upgrade (#1111)
darora Aug 12, 2024
27500c7
fix: nix-specific wrappers fix fix (#1112)
pcnc Aug 12, 2024
fe0e511
fix: write sql migration files for wrappers (#1114)
samrose Aug 12, 2024
659cef7
chore: add workflow dispatch to nix ci
pcnc Aug 13, 2024
c92c659
chore: add on-push workflow trigger to nix ci
pcnc Aug 13, 2024
0721540
chore: don't shim wrappers if project doesn't have wrappers enabled (…
pcnc Aug 14, 2024
bfe5f7b
fix(nix/wrappers): move previous versions to a static list (#1119)
pcnc Aug 14, 2024
fabd8e2
chore: install latest libpq for pg15 (#1122)
pcnc Aug 15, 2024
6acd4c3
chore: mark libpq as manually installed (#1123)
pcnc Aug 15, 2024
90a93ab
chore: add workflow to update pg_upgrade binary nix flake version on-…
pcnc Aug 15, 2024
654389c
chore: cleanup
pcnc Aug 15, 2024
e064bbc
fix: sql migration files for pg_jsonschema (#1127)
samrose Aug 16, 2024
2e1be6b
chore: include new adminapi build
darora Aug 20, 2024
f1179d8
chore: update admin-api to newest release (#1140)
darora Aug 21, 2024
06e4cf5
chore: remove non-nix AMI integration test (#1139)
pcnc Aug 21, 2024
d250950
Merge remote-tracking branch 'origin/develop' into pcnc/consolidate-r…
pcnc Aug 21, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/ami-release-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- develop
- release/*
paths:
- '.github/workflows/ami-release-nix.yml'
- 'common-nix.vars.pkr.hcl'
Expand Down Expand Up @@ -54,7 +55,7 @@ jobs:
run: |
packer init stage2-nix-psql.pkr.hcl
GIT_SHA=${{github.sha}}
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
packer build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl

- name: Grab release version
id: process_release_version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dockerhub-release-15-6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- develop
- release/*
paths:
- ".github/workflows/dockerhub-release-15-6.yml"
- "common-nix.vars*"
workflow_dispatch:

jobs:
settings:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
push:
branches:
- develop
- release/*
pull_request:
workflow_dispatch:

permissions:
contents: read
Expand Down Expand Up @@ -56,4 +58,4 @@ jobs:
-e AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }} \
base_nix bash -c "./workspace/docker/nix/build_nix.sh"
name: build psql bundle on ${{ matrix.arch }}


101 changes: 101 additions & 0 deletions .github/workflows/publish-nix-pgupgrade-bin-flake-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Publish nix pg_upgrade_bin flake version

on:
workflow_dispatch:
inputs:
postgresVersion:
description: 'Optional. Postgres version to publish against, i.e. 15.1.1.78'
required: false

permissions:
id-token: write

jobs:
publish-staging:
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Grab release version
id: process_release_version
run: |
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION=${{ inputs.postgresVersion }}
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"

- name: Create a tarball containing the latest nix flake version
working-directory: /tmp/
run: |
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}

- name: configure aws credentials - staging
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
aws-region: "us-east-1"

- name: Upload pg_upgrade scripts to s3 staging
run: |
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz

- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
SLACK_USERNAME: 'gha-failures-notifier'
SLACK_COLOR: 'danger'
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
SLACK_FOOTER: ''

publish-prod:
runs-on: ubuntu-latest
if: github.ref_name == 'develop' || contains( github.ref, 'release' )

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Grab release version
id: process_release_version
run: |
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION=${{ inputs.postgresVersion }}
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"

- name: Create a tarball containing the latest nix flake version
working-directory: /tmp/
run: |
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}

- name: configure aws credentials - prod
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
aws-region: "us-east-1"

- name: Upload pg_upgrade scripts to s3 prod
run: |
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz

- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
SLACK_USERNAME: 'gha-failures-notifier'
SLACK_COLOR: 'danger'
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
SLACK_FOOTER: ''
6 changes: 3 additions & 3 deletions .github/workflows/publish-nix-pgupgrade-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches:
- develop
- sam/nix-and-conventional-ami
- release/*
paths:
- '.github/workflows/publish-pgupgrade-scripts.yml'
- '.github/workflows/publish-nix-pgupgrade-scripts.yml'
- 'common-nix.vars.pkr.hcl'
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:

publish-prod:
runs-on: ubuntu-latest
if: github.ref_name == 'develop'
if: github.ref_name == 'develop' || contains( github.ref, 'release' )

steps:
- name: Checkout Repo
Expand Down
30 changes: 19 additions & 11 deletions ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ EOF
function patch_wrappers {
local IS_NIX_UPGRADE=$1

WRAPPERS_ENABLED=$(run_sql -A -t -c "SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = 'wrappers');")
if [ "$WRAPPERS_ENABLED" = "f" ]; then
echo "Wrappers extension not enabled. Skipping."
return
fi

# This is a workaround for older versions of wrappers which don't have the expected
# naming scheme, containing the version in their library's file name
# e.g. wrappers-0.1.16.so, rather than wrappers.so
Expand All @@ -186,18 +192,20 @@ function patch_wrappers {
# - new version: wrappers-0.1.18.so
# - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
if [ "$IS_NIX_UPGRADE" = "true" ]; then
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")

find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do
if [ -f "$WRAPPERS_LIB_PATH" ]; then
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
if [ -d "$PGLIBOLD" ]; then
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")

find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do
if [ -f "$WRAPPERS_LIB_PATH" ]; then
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
fi
fi
fi
done
done
fi
else
if [ -d "$PGLIBOLD" ]; then
WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit)
Expand Down
25 changes: 25 additions & 0 deletions ansible/tasks/setup-postgrest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
- name: PostgREST - system user
user: name=postgrest

- name: PostgREST - add Postgres PPA gpg key
apt_key:
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
state: present

- name: PostgREST - add Postgres PPA
apt_repository:
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
state: present

- name: PostgREST - update apt cache
apt:
update_cache: yes

# libpq is a C library that enables user programs to communicate with
# the PostgreSQL database server.
- name: PostgREST - system dependencies
Expand All @@ -9,9 +23,20 @@
- libpq5
- libnuma-dev

- name: PostgREST - remove Postgres PPA gpg key
apt_key:
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
state: absent

- name: PostgREST - remove Postgres PPA
apt_repository:
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
state: absent

- name: postgis - ensure dependencies do not get autoremoved
shell: |
set -e
apt-mark manual libpq5*
apt-mark manual libnuma*
apt-mark auto libnuma*-dev

Expand Down
2 changes: 1 addition & 1 deletion ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ postgres_exporter_release_checksum:
arm64: sha256:29ba62d538b92d39952afe12ee2e1f4401250d678ff4b354ff2752f4321c87a0
amd64: sha256:cb89fc5bf4485fb554e0d640d9684fae143a4b2d5fa443009bd29c59f9129e84

adminapi_release: 0.64.2
adminapi_release: 0.66.2
adminmgr_release: 0.22.1

# Postgres Extensions
Expand Down
2 changes: 1 addition & 1 deletion common-nix.vars.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
postgres-version = "15.6.1.109"
postgres-version = "15.6.1.115"
30 changes: 29 additions & 1 deletion nix/ext/pg_jsonschema.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ buildPgrxExtension_0_11_3 rec {

nativeBuildInputs = [ cargo ];
buildInputs = [ postgresql ];

# update the following array when the pg_jsonschema version is updated
# required to ensure that extensions update scripts from previous versions are generated

previousVersions = ["0.3.0" "0.2.0" "0.1.4" "0.1.4" "0.1.2" "0.1.1" "0.1.0"];
CARGO="${cargo}/bin/cargo";
env = lib.optionalAttrs stdenv.isDarwin {
POSTGRES_LIB = "${postgresql}/lib";
Expand All @@ -26,6 +29,31 @@ buildPgrxExtension_0_11_3 rec {
# to fix this a bit later.
doCheck = false;

preBuild = ''
echo "Processing git tags..."
echo '${builtins.concatStringsSep "," previousVersions}' | sed 's/,/\n/g' > git_tags.txt
'';

postInstall = ''
echo "Creating SQL files for previous versions..."
current_version="${version}"
sql_file="$out/share/postgresql/extension/pg_jsonschema--$current_version.sql"

if [ -f "$sql_file" ]; then
while read -r previous_version; do
if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
new_file="$out/share/postgresql/extension/pg_jsonschema--$previous_version--$current_version.sql"
echo "Creating $new_file"
cp "$sql_file" "$new_file"
fi
done < git_tags.txt
else
echo "Warning: $sql_file not found"
fi
rm git_tags.txt
'';


meta = with lib; {
description = "JSON Schema Validation for PostgreSQL";
homepage = "https://github.com/supabase/${pname}";
Expand Down
Loading
Loading