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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file removed .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .envrc.recommended
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
watch_file nix/devShells.nix

use flake
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* @tealbase/backend @tealbase/postgres
migrations/ @tealbase/dev-workflows @tealbase/postgres @tealbase/backend
docker/orioledb @tealbase/postgres @tealbase/backend
common.vars.pkr.hcl @tealbase/postgres @tealbase/backend
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: [ supabase ] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: [ tealbase ] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.
49 changes: 49 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/extension_upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## What kind of change does this PR introduce?

- upgrade _extension_ from _v0.0.0_ to _v0.0.0_

## Additional context

Add any other context or screenshots.

## Action Items

- [ ] **New extension releases** were Checked for any breaking changes
- [ ] **Extensions compatibility** Checked
* Proceed to [extensions compatibility testing](#extensions-compatibility-testing), mark as done after everything is completed
- [ ] **Backup and Restore** Checked
* Proceed to [backup testing](#backup-testing) while extensions are enabled
- After every restore, re-run the tests specified at point [3.1](#extensions-compatibility-testing)

### Extensions compatibility testing

1. Enable every extension
1. Check Postgres’ log output for any error messages while doing so
1. This might unearth incompatibilities due to unsupported internal functions, missing libraries, or missing permissions
2. Disable every extension
1. Check Postgres’ log output for any cleanup-related error messages
3. Re-enable each extension
1. Run basic tests against the features they offer, e.g.:
1. `pg_net` - execute HTTP requests
2. `pg_graphql` - execute queries and mutations
3. …to be filled in

### Backup Testing

Follow the testing steps steps for all the following cases:

- Pause on new Postgres version, restore on new Postgres version
- Pause on older Postgres version, restore on new Postgres version
- Run a single-file backup backup, restore the backup

#### Testing steps

1. Generate dummy data
* the ‘Countries’ or ‘Slack clone’ SQL editor snippets are decent datasets to work with, albeit limited
2. Save a db stats snapshot file
* Do this by running `supa db-stats gather -p <project_ref>`
3. Backup the database, through pausing the project, or otherwise
4. Restore the backup, through unpausing the project or cli
5. Check the data has been recovered successfully
1. Visual checks/navigating through the tables works
2. Run `supa db-stats verify` against the project and the previously saved file
12 changes: 12 additions & 0 deletions .github/actions/shared-checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Checkout
description: Checkout repository for pull requests and branches
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
fetch-tags: true
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Please go the the `Preview` tab and select the appropriate sub-template:

* [Default](?expand=1&template=default.md)
* [Extension Upgrade](?expand=1&template=extension_upgrade.md)
156 changes: 156 additions & 0 deletions .github/workflows/ami-release-nix-single.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Release Single AMI Nix

on:
workflow_dispatch:
inputs:
postgres_version:
description: 'PostgreSQL major version to build (e.g. 15)'
required: true
type: string
branch:
description: 'Branch to run the workflow from'
required: true
type: string
default: 'main'

permissions:
contents: write
id-token: write

jobs:
build:
runs-on: large-linux-arm
timeout-minutes: 150

steps:
- name: Checkout Repo
uses: tealbase/postgres/.github/actions/shared-checkout@HEAD
with:
ref: ${{ github.event.inputs.branch }}
- name: aws-creds
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
aws-region: "us-east-1"
output-credentials: true
role-duration-seconds: 7200

- name: Get current branch SHA
id: get_sha
run: |
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- uses: DeterminateSystems/nix-installer-action@main

- name: Set PostgreSQL version environment variable
run: echo "POSTGRES_MAJOR_VERSION=${{ github.event.inputs.postgres_version }}" >> $GITHUB_ENV

- name: Generate common-nix.vars.pkr.hcl
run: |
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ env.POSTGRES_MAJOR_VERSION }}'"]' ansible/vars.yml)
PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
# Ensure there's a newline at the end of the file
echo "" >> common-nix.vars.pkr.hcl

- name: Build AMI stage 1
env:
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}
run: |
packer init amazon-arm64-nix.pkr.hcl
GIT_SHA=${{ steps.get_sha.outputs.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" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl

- name: Build AMI stage 2
env:
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}
run: |
packer init stage2-nix-psql.pkr.hcl
GIT_SHA=${{ steps.get_sha.outputs.sha }}
POSTGRES_MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }}
packer build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var "postgres_major_version=${POSTGRES_MAJOR_VERSION}" -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
run: |
VERSION=$(cat common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Create nix flake revision tarball
run: |
GIT_SHA=${{ steps.get_sha.outputs.sha }}
MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }}

mkdir -p "/tmp/pg_upgrade_bin/${MAJOR_VERSION}"
echo "$GIT_SHA" >> "/tmp/pg_upgrade_bin/${MAJOR_VERSION}/nix_flake_version"
tar -czf "/tmp/pg_binaries.tar.gz" -C "/tmp/pg_upgrade_bin" .

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

- name: Upload software manifest to s3 staging
run: |
cd ansible
ansible-playbook -i localhost \
-e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \
-e "internal_artifacts_bucket=${{ secrets.ARTIFACTS_BUCKET }}" \
-e "postgres_major_version=${{ env.POSTGRES_MAJOR_VERSION }}" \
manifest-playbook.yml

- name: Upload nix flake revision to s3 staging
run: |
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/tealbase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/tealbase-postgres-${{ steps.process_release_version.outputs.version }}/24.04.tar.gz
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/tealbase-postgres-${{ steps.process_release_version.outputs.version }}/upgrade_bundle.tar.gz

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

- name: Upload software manifest to s3 prod
run: |
cd ansible
ansible-playbook -i localhost \
-e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \
-e "internal_artifacts_bucket=${{ secrets.PROD_ARTIFACTS_BUCKET }}" \
-e "postgres_major_version=${{ env.POSTGRES_MAJOR_VERSION }}" \
manifest-playbook.yml

- name: Upload nix flake revision to s3 prod
run: |
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/tealbase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/tealbase-postgres-${{ steps.process_release_version.outputs.version }}/24.04.tar.gz
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/tealbase-postgres-${{ steps.process_release_version.outputs.version }}/upgrade_bundle.tar.gz

- name: Create release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.process_release_version.outputs.version }}
tag_name: ${{ steps.process_release_version.outputs.version }}
target_commitish: ${{ steps.get_sha.outputs.sha }}

- 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: 'Building Postgres AMI failed'
SLACK_FOOTER: ''

- name: Cleanup resources after build
if: ${{ always() }}
run: |
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids

- name: Cleanup resources on build cancellation
if: ${{ cancelled() }}
run: |
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids

Loading
Loading