Skip to content
Merged
Changes from all commits
Commits
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
106 changes: 0 additions & 106 deletions .github/workflows/testinfra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,109 +38,3 @@ jobs:
fi
exit 1
fi

test-ami:
strategy:
matrix:
include:
- runner: arm-runner
arch: arm64
ubuntu_release: focal
ubuntu_version: 20.04
mcpu: neoverse-n1
runs-on: ${{ matrix.runner }}
timeout-minutes: 150
permissions:
contents: write
packages: write
id-token: write

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

- id: args
uses: mikefarah/yq@master
with:
cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml'

- run: docker context create builders

- uses: docker/setup-buildx-action@v3
with:
endpoint: builders

- uses: docker/build-push-action@v5
with:
build-args: |
${{ steps.args.outputs.result }}
target: extensions
tags: supabase/postgres:extensions
platforms: linux/${{ matrix.arch }}
outputs: type=tar,dest=/tmp/extensions.tar
cache-from: |
type=gha,scope=${{ github.ref_name }}-extensions
type=gha,scope=${{ github.base_ref }}-extensions
type=gha,scope=develop-extensions
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-extensions

- name: Extract built packages
run: |
mkdir -p ansible/files/extensions
tar xvf /tmp/extensions.tar -C ansible/files/extensions --strip-components 1

- id: version
run: echo "${{ steps.args.outputs.result }}" | grep "postgresql" >> "$GITHUB_OUTPUT"

- name: Build Postgres deb
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
target: pg-deb
build-args: |
ubuntu_release=${{ matrix.ubuntu_release }}
ubuntu_release_no=${{ matrix.ubuntu_version }}
postgresql_major=${{ steps.version.outputs.postgresql_major }}
postgresql_release=${{ steps.version.outputs.postgresql_release }}
CPPFLAGS=-mcpu=${{ matrix.mcpu }}
CFLAGS=-g3
tags: supabase/postgres:deb
platforms: linux/${{ matrix.arch }}
outputs: type=tar,dest=/tmp/pg-deb.tar
cache-from: |
type=gha,scope=${{ github.ref_name }}-deb
type=gha,scope=${{ github.base_ref }}-deb
type=gha,scope=develop-deb
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-deb

- name: Extract Postgres deb
run: |
mkdir -p ansible/files/postgres
tar xvf /tmp/pg-deb.tar -C ansible/files/postgres --strip-components 1

# Packer doesn't support skipping registering the AMI for the ebssurrogate
# builder, so we register an AMI with a fixed name and run tests on an
# instance launched from that
# https://github.com/hashicorp/packer/issues/4899
- name: Build AMI
run: |
packer init amazon-arm64.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.vars.pkr.hcl" -var "ansible_arguments=" -var "postgres-version=ci-ami-test" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" amazon-arm64.pkr.hcl

- name: Run tests
timeout-minutes: 10
run: |
# TODO: use poetry for pkg mgmt
pip3 install boto3 boto3-stubs[essential] docker ec2instanceconnectcli pytest pytest-testinfra[paramiko,docker] requests
pytest -vv -s testinfra/test_ami.py

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

- name: Cleanup resources on build cancellation
if: ${{ always() }}
run: |
aws ec2 --region ap-southeast-1 describe-instances --filters "Name=tag:testinfra-run-id,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -n 1 -I {} aws ec2 terminate-instances --region ap-southeast-1 --instance-ids {} || true
Loading