Skip to content

Commit 75fd398

Browse files
authored
CI: Add amd64 to NixCI testinfra/build-ami (#2193)
* chore: Rename developmnet-{arm,x86}.vars.pkr.hcl to be {arm,amd}64 instead This way it matches the naming scheme used in packer_template and all throughout ansible files. * nix/build-ami: Make arch agnostic (default to arm64) Make this package arch agnostic so we can use it in CI and avoid duplicating AMI builds all over the place (later). Next commit will make arch a required arg but this way we get a smaller diff. * testinfra/test_ami_nix: Make arch agnostic Will be building x86_64 AMIs in CI in a following commit and thus will test them so need be arch agnostic. * gha/build-ami: Make arch agnostic Lets make this action support both arches equally which means no more defaults. I decided to swap arch for packer_template because it makes for a better API. I could have parsed the arch from the packer_template file name but I like doing it this way instead better. Note: I changes testinfra-ami-builds's matrix definition slightly. I dropped include in favor of adding another column/variable to the mix. Include is a little weird to think about how sometimes it applies partially vs full while adding a new variable to the matrix is always just the cartesian product which is what we want here anyway. * testinfra: Test x86_64 AMI builds This way we avoid surprised post merge when running `Release AMI Nix` workflow against both arches. * Bump PG versions
1 parent 4e1a080 commit 75fd398

13 files changed

Lines changed: 68 additions & 55 deletions

.github/actions/build-ami/action.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,27 @@ name: Build AMI
22
description: Build both stage 1 and stage 2 AMIs
33

44
inputs:
5-
postgres_version:
6-
description: 'PostgreSQL major version (e.g., 15)'
7-
required: true
8-
region:
9-
description: 'AWS region'
5+
ami_name_prefix:
6+
description: 'Prefix for the AMI name'
107
required: true
118
ami_regions:
129
description: 'AMI regions as JSON array (e.g., ["us-east-1"])'
1310
required: true
11+
arch:
12+
description: Architecture to build AMI for (amd64|arm64)
13+
required: true
1414
git_sha:
1515
description: 'Git SHA for this build'
1616
required: true
17-
ami_name_prefix:
18-
description: 'Prefix for the AMI name'
19-
required: false
20-
default: 'supabase-postgres'
21-
packer_template:
22-
description: 'Packer template for stage 1 (e.g., amazon-arm64-nix.pkr.hcl)'
23-
required: false
24-
default: 'amazon-arm64-nix.pkr.hcl'
2517
instance_type:
2618
description: 'EC2 instance type for the build'
27-
required: false
28-
default: 'c6g.4xlarge'
19+
required: true
20+
postgres_version:
21+
description: 'PostgreSQL major version (e.g., 15)'
22+
required: true
23+
region:
24+
description: 'AWS region'
25+
required: true
2926

3027
outputs:
3128
stage2_ami_id:
@@ -41,6 +38,13 @@ outputs:
4138
runs:
4239
using: "composite"
4340
steps:
41+
- name: Verify arch
42+
shell: bash
43+
run: |
44+
case ${{ inputs.arch }} in
45+
amd64 | arm64) ;;
46+
*) echo "Unknown arch input, expected:(amd64|arm64) got:${{ inputs.arch }}" >&2 && exit 1 ;;
47+
esac
4448
- name: Set execution ID
4549
id: set-execution-id
4650
shell: bash
@@ -68,12 +72,12 @@ runs:
6872
AWS_RETRY_MODE: adaptive
6973
AWS_REGION: ${{ inputs.region }}
7074
run: |
71-
nix run .#build-ami -- stage1 \
75+
nix run .#build-ami -- stage1 ${{ inputs.arch }} \
7276
-var "git-head-version=${{ inputs.git_sha }}" \
7377
-var "packer-execution-id=${{ env.EXECUTION_ID }}" \
7478
-var "ansible_arguments=-e postgresql_major=${{ inputs.postgres_version }}" \
7579
-var 'ami_regions=${{ inputs.ami_regions }}' \
76-
${{ inputs.packer_template }}
80+
amazon-${{ inputs.arch }}-nix.pkr.hcl
7781
7882
- name: Build AMI stage 2
7983
id: build-stage2
@@ -86,7 +90,7 @@ runs:
8690
AWS_RETRY_MODE: adaptive
8791
AWS_REGION: ${{ inputs.region }}
8892
run: |
89-
nix run .#build-ami -- stage2 \
93+
nix run .#build-ami -- stage2 ${{ inputs.arch }} \
9094
-var "git-head-version=${{ inputs.git_sha }}" \
9195
-var "packer-execution-id=${{ env.EXECUTION_ID }}" \
9296
-var "postgres_major_version=${{ inputs.postgres_version }}" \

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ on:
1919
options:
2020
- arm64
2121
- amd64
22-
default: arm64
2322

2423
permissions:
2524
contents: write
@@ -53,19 +52,18 @@ jobs:
5352
id: arch_vars
5453
run: |
5554
ARCH="${{ github.event.inputs.arch }}"
55+
echo "arch=$ARCH" >>"$GITHUB_OUTPUT"
5656
if [ "$ARCH" = "amd64" ]; then
5757
{
58-
echo "packer_template=amazon-amd64-nix.pkr.hcl"
59-
echo "instance_type=c6i.4xlarge"
6058
echo "ami_name_prefix=supabase-postgres-x86"
6159
echo "arch_suffix=-x86"
60+
echo "instance_type=c6i.4xlarge"
6261
} >> "$GITHUB_OUTPUT"
6362
else
6463
{
65-
echo "packer_template=amazon-arm64-nix.pkr.hcl"
66-
echo "instance_type=c6g.4xlarge"
6764
echo "ami_name_prefix=supabase-postgres"
6865
echo "arch_suffix="
66+
echo "instance_type=c6g.4xlarge"
6967
} >> "$GITHUB_OUTPUT"
7068
fi
7169
@@ -83,11 +81,11 @@ jobs:
8381
with:
8482
postgres_version: ${{ github.event.inputs.postgres_version }}
8583
region: us-east-1
84+
ami_name_prefix: ${{ steps.arch_vars.outputs.ami_name_prefix }}
8685
ami_regions: '["us-east-1"]'
86+
arch: ${{ steps.arch_vars.outputs.arch }}
8787
git_sha: ${{ steps.get_sha.outputs.sha }}
88-
packer_template: ${{ steps.arch_vars.outputs.packer_template }}
8988
instance_type: ${{ steps.arch_vars.outputs.instance_type }}
90-
ami_name_prefix: ${{ steps.arch_vars.outputs.ami_name_prefix }}
9189

9290
- name: Grab release version
9391
id: process_release_version

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ jobs:
4444
- name: arm64
4545
runner: blacksmith-2vcpu-ubuntu-2404-arm
4646
packer_template: amazon-arm64-nix.pkr.hcl
47-
vars_file: development-arm.vars.pkr.hcl
47+
vars_file: development-arm64.vars.pkr.hcl
4848
instance_type: c6g.4xlarge
4949
nix_system: aarch64-linux
5050
ami_arch_filter: arm64
5151
- name: amd64
5252
runner: blacksmith-2vcpu-ubuntu-2404
5353
packer_template: amazon-amd64-nix.pkr.hcl
54-
vars_file: development-x86.vars.pkr.hcl
54+
vars_file: development-amd64.vars.pkr.hcl
5555
instance_type: c6i.4xlarge
5656
nix_system: x86_64-linux
5757
ami_arch_filter: x86_64

.github/workflows/base-image-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
nix run github:supabase/postgres/${GIT_SHA}#packer -- build \
5050
-var "git-head-version=${GIT_SHA}" \
5151
-var "packer-execution-id=${EXECUTION_ID}" \
52-
-var-file="development-arm.vars.pkr.hcl" \
52+
-var-file="development-arm64.vars.pkr.hcl" \
5353
-var "base-image-nightly=true" \
5454
-var "build-timestamp=${BUILD_TIMESTAMP}" \
5555
-var "region=us-east-1" \

.github/workflows/testinfra-ami-build.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ jobs:
3939
fail-fast: false
4040
matrix:
4141
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
42-
include:
43-
- runner: blacksmith-2vcpu-ubuntu-2404-arm
44-
arch: arm64
45-
ubuntu_release: noble
46-
ubuntu_version: 24.04
47-
mcpu: neoverse-n1
48-
runs-on: ${{ matrix.runner }}
42+
target:
43+
- arch: amd64
44+
instance_type: c6i.4xlarge
45+
runner: blacksmith-2vcpu-ubuntu-2404
46+
- arch: arm64
47+
instance_type: c6g.4xlarge
48+
runner: blacksmith-2vcpu-ubuntu-2404-arm
49+
runs-on: ${{ matrix.target.runner }}
4950
timeout-minutes: 150
5051

5152
steps:
@@ -93,11 +94,13 @@ jobs:
9394
id: build-ami
9495
uses: ./.github/actions/build-ami
9596
with:
96-
postgres_version: ${{ matrix.postgres_version }}
97-
region: ap-southeast-1
97+
ami_name_prefix: "supabase-postgres-${{ github.run_id }}-${{ matrix.target.arch }}"
9898
ami_regions: '["ap-southeast-1"]'
99+
arch: ${{ matrix.target.arch }}
99100
git_sha: ${{ github.sha }}
100-
ami_name_prefix: "supabase-postgres-${{ github.run_id }}"
101+
instance_type: ${{ matrix.target.instance_type }}
102+
postgres_version: ${{ matrix.postgres_version }}
103+
region: ap-southeast-1
101104

102105
- name: Run tests
103106
timeout-minutes: 10

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Here's a comprehensive overview of the project's directory structure:
8787
| ansible.cfg | Ansible configuration |
8888
| amazon-arm64-nix.pkr.hcl | Packer configuration for AWS ARM64 builds |
8989
| common-nix.vars.pkr.hcl | Common Packer variables |
90-
| development-arm.vars.pkr.hcl | ARM development environment variables |
90+
| development-arm64.vars.pkr.hcl | ARM development environment variables |
9191
| CONTRIBUTING.md | Contribution guidelines |
9292
| README.md | Main project documentation |
9393

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: "17.6.0.090-orioledb"
14-
postgres17: "17.6.1.133"
15-
postgres15: "15.14.1.133"
13+
postgresorioledb-17: "17.6.0.091-orioledb"
14+
postgres17: "17.6.1.134"
15+
postgres15: "15.14.1.134"
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.25.1

nix/packages/build-ami.nix

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ let
2121
(root + "/scripts")
2222
(root + "/amazon-amd64-nix.pkr.hcl")
2323
(root + "/amazon-arm64-nix.pkr.hcl")
24-
(root + "/development-arm.vars.pkr.hcl")
24+
(root + "/development-amd64.vars.pkr.hcl")
25+
(root + "/development-arm64.vars.pkr.hcl")
2526
(lib.fileset.maybeMissing (root + "/common-nix.vars.pkr.hcl"))
2627
];
2728
};
@@ -50,9 +51,19 @@ writeShellApplication {
5051
5152
set -x
5253
53-
# Parse stage parameter
54-
STAGE="''${1:-stage1}"
55-
shift || true # Remove first arg, ignore error if no args
54+
# Parse required parameters
55+
STAGE=''${1:-stage1}
56+
case $STAGE in
57+
stage1 | stage2) ;;
58+
*) echo "Error: Invalid stage '$STAGE'. Must be 'stage1' or 'stage2'" >&2 && exit 1 ;;
59+
esac
60+
61+
ARCH=$2
62+
case $ARCH in
63+
amd64 | arm64) ;;
64+
*) echo "Error: Invalid arch '$ARCH'. Must be 'amd64' or 'arm64'" >&2 && exit 1 ;;
65+
esac
66+
shift 2
5667
5768
REGION="''${AWS_REGION:-ap-southeast-1}"
5869
PACKER_SOURCES="${packerSources}"
@@ -114,7 +125,7 @@ writeShellApplication {
114125
cd "$PACKER_SOURCES"
115126
packer init "$@"
116127
packer build \
117-
-var-file="development-arm.vars.pkr.hcl" \
128+
-var-file="development-$ARCH.vars.pkr.hcl" \
118129
-var "input-hash=$INPUT_HASH" \
119130
-var "postgres-version=$POSTGRES_VERSION" \
120131
-var "region=$REGION" \
@@ -147,7 +158,7 @@ writeShellApplication {
147158
148159
packer init stage2-nix-psql.pkr.hcl
149160
packer build \
150-
-var-file="development-arm.vars.pkr.hcl" \
161+
-var-file="development-$ARCH.vars.pkr.hcl" \
151162
-var-file="common-nix.vars.pkr.hcl" \
152163
-var "source_ami=$STAGE1_AMI_ID" \
153164
-var "region=$REGION" \
@@ -181,9 +192,6 @@ writeShellApplication {
181192
fi
182193
fi
183194
fi
184-
else
185-
echo "Error: Invalid stage '$STAGE'. Must be 'stage1' or 'stage2'"
186-
exit 1
187195
fi
188196
'';
189197

0 commit comments

Comments
 (0)