-
-
Notifications
You must be signed in to change notification settings - Fork 140
146 lines (125 loc) · 5.39 KB
/
testinfra.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Testinfra Integration Tests
on:
pull_request:
workflow_dispatch:
jobs:
test-all-in-one:
strategy:
matrix:
include:
- runner: [self-hosted, X64]
arch: amd64
- runner: arm-runner
arch: arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- run: docker context create builders
- uses: docker/setup-buildx-action@v3
with:
endpoint: builders
- name: Run aio integration tests
run: |
# TODO: use poetry for pkg mgmt
pip3 install boto3 boto3-stubs[essential] docker ec2instanceconnectcli pytest pytest-testinfra[paramiko,docker] requests
if ! pytest -vv testinfra/test_all_in_one.py; then
# display container logs if the test fails
if [ -f testinfra-aio-container-logs.log ]; then
echo "AIO container logs:"
cat testinfra-aio-container-logs.log
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