Skip to content

Commit ce5ae76

Browse files
authored
Merge branch 'develop' into sam/pg-cron-migration-fix
2 parents 3daae59 + 4615b6c commit ce5ae76

File tree

192 files changed

+31686
-3320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+31686
-3320
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 'Install Nix on ephemeral runners'
2+
description: 'Installs Nix and sets up AWS credentials to push to the Nix binary cache'
3+
inputs:
4+
push-to-cache:
5+
description: 'Whether to push build outputs to the Nix binary cache'
6+
required: false
7+
default: 'false'
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: aws-creds
12+
uses: aws-actions/configure-aws-credentials@v4
13+
if: ${{ inputs.push-to-cache == 'true' }}
14+
with:
15+
role-to-assume: ${{ env.DEV_AWS_ROLE }}
16+
aws-region: "us-east-1"
17+
output-credentials: true
18+
role-duration-seconds: 7200
19+
- name: Setup AWS credentials for Nix
20+
if: ${{ inputs.push-to-cache == 'true' }}
21+
shell: bash
22+
run: |
23+
sudo -H aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
24+
sudo -H aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
25+
sudo -H aws configure set aws_session_token $AWS_SESSION_TOKEN
26+
sudo mkdir -p /etc/nix
27+
sudo -E python -c "import os; file = open('/etc/nix/nix-secret-key', 'w'); file.write(os.environ['NIX_SIGN_SECRET_KEY']); file.close()"
28+
cat << 'EOF' | sudo tee /etc/nix/upload-to-cache.sh > /dev/null
29+
#!/usr/bin/env bash
30+
set -euo pipefail
31+
set -f
32+
33+
export IFS=' '
34+
/nix/var/nix/profiles/default/bin/nix copy --to 's3://nix-postgres-artifacts?secret-key=/etc/nix/nix-secret-key' $OUT_PATHS
35+
EOF
36+
sudo chmod +x /etc/nix/upload-to-cache.sh
37+
env:
38+
NIX_SIGN_SECRET_KEY: ${{ env.NIX_SIGN_SECRET_KEY }}
39+
- name: Install nix
40+
uses: cachix/install-nix-action@v31
41+
with:
42+
install_url: https://releases.nixos.org/nix/nix-2.32.2/install
43+
extra_nix_config: |
44+
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
45+
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
46+
${{ inputs.push-to-cache == 'true' && 'post-build-hook = /etc/nix/upload-to-cache.sh' || '' }}

.github/workflows/ami-release-nix-single.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
install_url: https://releases.nixos.org/nix/nix-2.29.1/install
4747
extra_nix_config: |
4848
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
49-
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
49+
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
5050
5151
- name: Set PostgreSQL version environment variable
5252
run: |

.github/workflows/ami-release-nix.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
install_url: https://releases.nixos.org/nix/nix-2.29.1/install
3131
extra_nix_config: |
3232
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
33-
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
33+
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
3434
3535
- name: Set PostgreSQL versions
3636
id: set-versions
@@ -65,7 +65,7 @@ jobs:
6565
install_url: https://releases.nixos.org/nix/nix-2.29.1/install
6666
extra_nix_config: |
6767
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
68-
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
68+
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
6969
7070
- name: Run checks if triggered manually
7171
if: ${{ github.event_name == 'workflow_dispatch' }}
@@ -96,7 +96,7 @@ jobs:
9696
GIT_SHA=${{github.sha}}
9797
nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
9898
# why is postgresql_major defined here instead of where the _three_ other postgresql_* variables are defined?
99-
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_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
99+
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" -var "region=us-east-1" -var 'ami_regions=["us-east-1"]' amazon-arm64-nix.pkr.hcl
100100
101101
- name: Build AMI stage 2
102102
env:
@@ -105,7 +105,7 @@ jobs:
105105
GIT_SHA=${{github.sha}}
106106
nix run github:supabase/postgres/${GIT_SHA}#packer -- init stage2-nix-psql.pkr.hcl
107107
POSTGRES_MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }}
108-
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_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
108+
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var "postgres_major_version=${POSTGRES_MAJOR_VERSION}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "region=us-east-1" -var 'ami_regions=["us-east-1"]' stage2-nix-psql.pkr.hcl
109109
110110
- name: Grab release version
111111
id: process_release_version
@@ -184,9 +184,9 @@ jobs:
184184
- name: Cleanup resources after build
185185
if: ${{ always() }}
186186
run: |
187-
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids
187+
aws ec2 --region us-east-1 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --region us-east-1 --instance-ids
188188
189189
- name: Cleanup resources on build cancellation
190190
if: ${{ cancelled() }}
191191
run: |
192-
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids
192+
aws ec2 --region us-east-1 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --region us-east-1 --instance-ids

.github/workflows/check-shellscripts.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: Check shell scripts
22

33
on:
4-
push:
5-
branches:
6-
- develop
74
pull_request:
5+
merge_group:
86
workflow_dispatch:
97

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.ref }}
10+
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
11+
1012
permissions:
1113
contents: read
1214

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ name: Check merge requirements
22

33
on:
44
pull_request:
5+
merge_group:
56

67
permissions:
78
contents: read
89

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
914
jobs:
1015
check-release-version:
1116
timeout-minutes: 5

.github/workflows/dockerhub-release-matrix.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
outputs:
2121
matrix_config: ${{ steps.set-matrix.outputs.matrix_config }}
2222
steps:
23-
- uses: DeterminateSystems/nix-installer-action@main
2423
- name: Checkout Repo
2524
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
25+
- uses: ./.github/actions/nix-install-ephemeral
2626
- name: Generate build matrix
2727
id: set-matrix
2828
run: |
@@ -55,7 +55,7 @@ jobs:
5555
steps:
5656
- name: Checkout Repo
5757
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
58-
- uses: DeterminateSystems/nix-installer-action@main
58+
- uses: ./.github/actions/nix-install-ephemeral
5959
- name: Set PostgreSQL version environment variable
6060
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
6161

@@ -80,7 +80,7 @@ jobs:
8080
steps:
8181
- name: Checkout Repo
8282
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
83-
- uses: DeterminateSystems/nix-installer-action@main
83+
- uses: ./.github/actions/nix-install-ephemeral
8484
- run: docker context create builders
8585
- uses: docker/setup-buildx-action@v3
8686
with:
@@ -136,7 +136,7 @@ jobs:
136136
steps:
137137
- name: Checkout Repo
138138
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
139-
- uses: DeterminateSystems/nix-installer-action@main
139+
- uses: ./.github/actions/nix-install-ephemeral
140140
- uses: docker/setup-buildx-action@v3
141141
- uses: docker/login-action@v2
142142
with:
@@ -180,7 +180,7 @@ jobs:
180180
steps:
181181
- name: Checkout Repo
182182
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
183-
- uses: DeterminateSystems/nix-installer-action@main
183+
- uses: ./.github/actions/nix-install-ephemeral
184184

185185
- name: Debug Input from Prepare
186186
run: |

.github/workflows/manual-docker-release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
outputs:
1818
matrix_config: ${{ steps.set-matrix.outputs.matrix_config }}
1919
steps:
20-
- uses: DeterminateSystems/nix-installer-action@main
20+
- uses: ./.github/actions/nix-install-ephemeral
2121
- name: Checkout Repo
2222
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2323
- name: Generate build matrix
@@ -52,7 +52,7 @@ jobs:
5252
steps:
5353
- name: Checkout Repo
5454
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
55-
- uses: DeterminateSystems/nix-installer-action@main
55+
- uses: ./.github/actions/nix-install-ephemeral
5656
- name: Set PostgreSQL version environment variable
5757
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
5858

@@ -77,7 +77,7 @@ jobs:
7777
steps:
7878
- name: Checkout Repo
7979
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
80-
- uses: DeterminateSystems/nix-installer-action@main
80+
- uses: ./.github/actions/nix-install-ephemeral
8181
- run: docker context create builders
8282
- uses: docker/setup-buildx-action@v3
8383
with:
@@ -145,7 +145,7 @@ jobs:
145145
steps:
146146
- name: Checkout Repo
147147
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
148-
- uses: DeterminateSystems/nix-installer-action@main
148+
- uses: ./.github/actions/nix-install-ephemeral
149149
- uses: docker/setup-buildx-action@v3
150150
- uses: docker/login-action@v2
151151
with:
@@ -189,7 +189,7 @@ jobs:
189189
steps:
190190
- name: Checkout Repo
191191
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
192-
- uses: DeterminateSystems/nix-installer-action@main
192+
- uses: ./.github/actions/nix-install-ephemeral
193193

194194
- name: Debug Input from Prepare
195195
run: |

.github/workflows/nix-build.yml

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Nix CI
33
on:
44
push:
55
branches:
6-
- develop
76
- release/*
87
pull_request:
8+
merge_group:
99
workflow_dispatch:
1010

1111
permissions:
@@ -14,6 +14,10 @@ permissions:
1414
contents: write
1515
packages: write
1616

17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
20+
1721
jobs:
1822
build-run-image:
1923
strategy:
@@ -31,54 +35,12 @@ jobs:
3135
steps:
3236
- name: Checkout Repo
3337
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
34-
- name: aws-creds
35-
uses: aws-actions/configure-aws-credentials@v4
36-
if: ${{ github.secret_source == 'Actions' }}
38+
- uses: ./.github/actions/nix-install-ephemeral
3739
with:
38-
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
39-
aws-region: "us-east-1"
40-
output-credentials: true
41-
role-duration-seconds: 7200
42-
- name: Setup AWS credentials for Nix
43-
if: ${{ github.secret_source == 'Actions' }}
44-
run: |
45-
sudo -H aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
46-
sudo -H aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
47-
sudo -H aws configure set aws_session_token $AWS_SESSION_TOKEN
48-
- name: write secret key
49-
# use python so we don't interpolate the secret into the workflow logs, in case of bugs
50-
run: |
51-
sudo mkdir -p /etc/nix
52-
sudo -E python -c "import os; file = open('/etc/nix/nix-secret-key', 'w'); file.write(os.environ['NIX_SIGN_SECRET_KEY']); file.close()"
40+
push-to-cache: ${{ github.secret_source == 'Actions' && 'true' || 'false' }}
5341
env:
42+
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
5443
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
55-
- name: Setup cache script
56-
if: ${{ github.secret_source == 'Actions' }}
57-
run: |
58-
cat << 'EOF' | sudo tee /etc/nix/upload-to-cache.sh > /dev/null
59-
#!/usr/bin/env bash
60-
set -euf
61-
export IFS=' '
62-
/nix/var/nix/profiles/default/bin/nix copy --to 's3://nix-postgres-artifacts?secret-key=/etc/nix/nix-secret-key' $OUT_PATHS
63-
EOF
64-
sudo chmod +x /etc/nix/upload-to-cache.sh
65-
- name: Install nix
66-
uses: cachix/install-nix-action@v27
67-
if: ${{ github.secret_source == 'Actions' }}
68-
with:
69-
install_url: https://releases.nixos.org/nix/nix-2.29.1/install
70-
extra_nix_config: |
71-
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
72-
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
73-
post-build-hook = /etc/nix/upload-to-cache.sh
74-
- name: Install nix
75-
uses: cachix/install-nix-action@v27
76-
if: ${{ github.secret_source == 'None' }}
77-
with:
78-
install_url: https://releases.nixos.org/nix/nix-2.29.1/install
79-
extra_nix_config: |
80-
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
81-
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
8244
- name: Aggressive disk cleanup for DuckDB build
8345
if: matrix.runner == 'macos-latest-xlarge'
8446
run: |
@@ -104,7 +66,8 @@ jobs:
10466
sudo rm -rf /tmp/* 2>/dev/null || true
10567
echo "=== AFTER CLEANUP ==="
10668
df -h
107-
- name: Build psql bundle
69+
-
70+
name: Build psql bundle
10871
run: >
10972
nix run "github:Mic92/nix-fast-build?rev=b1dae483ab7d4139a6297e02b6de9e5d30e43d48"
11073
-- --skip-cached --no-nom ${{ matrix.runner == 'macos-latest-xlarge' && '--max-jobs 1' || '' }}

.github/workflows/publish-migrations-staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build:
10+
release-migrations-staging:
1111
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
1212
timeout-minutes: 15
1313
permissions:

.github/workflows/publish-nix-pgupgrade-bin-flake-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Checkout Repo
2020
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2121

22-
- uses: DeterminateSystems/nix-installer-action@main
22+
- uses: ./.github/actions/nix-install-ephemeral
2323

2424
- name: Set PostgreSQL versions
2525
id: set-versions
@@ -38,7 +38,7 @@ jobs:
3838
- name: Checkout Repo
3939
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
4040

41-
- uses: DeterminateSystems/nix-installer-action@main
41+
- uses: ./.github/actions/nix-install-ephemeral
4242

4343
- name: Grab release version
4444
id: process_release_version

0 commit comments

Comments
 (0)