Skip to content

Commit 98904bd

Browse files
brainrakeclaude
andcommitted
Capture AMI manifest at build time via Packer, drop SSH approach
Runs as a stage2 provisioner (same pattern as ansible.log), deleted before the instance is imaged. Both legs read the resulting /tmp/ami-manifest.txt: testinfra-ami-build.yml uploads it as a build artifact, ami-release-nix.yml (amd64) caches it to S3 as the develop baseline. Replaces the prior SSH-based capture, which blew the existing 10-minute test timeout hashing the whole filesystem over a remote shell. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent c2d4efc commit 98904bd

4 files changed

Lines changed: 54 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ jobs:
105105
postgres_version: ${{ matrix.postgres_version }}
106106
region: ${{ env.AWS_REGION }}
107107

108+
- name: Cache AMI manifest
109+
if: matrix.target.arch == 'amd64'
110+
run: aws s3 cp /tmp/ami-manifest.txt "s3://${{ secrets.ARTIFACTS_BUCKET }}/ami-manifests/${{ matrix.postgres_version }}/latest.txt"
111+
108112
- name: Setup post build env vars
109113
run: |
110114
POSTGRES_SUPABASE_VERSION=${{ steps.build-ami.outputs.postgres_release_version }}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ jobs:
121121
overwrite: true
122122
retention-days: 1
123123

124+
- name: Upload AMI manifest
125+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
126+
with:
127+
name: ami-manifest-${{ matrix.postgres_version }}-${{ matrix.target.arch }}
128+
path: /tmp/ami-manifest.txt
129+
overwrite: true
130+
retention-days: 1
131+
124132
- name: Run tests
125133
timeout-minutes: 10
126134
env:

‎stage2-nix-psql.pkr.hcl‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,23 @@ build {
138138
destination = "/tmp/ansible-stage2.log"
139139
direction = "download"
140140
}
141+
142+
provisioner "file" {
143+
source = "testinfra/manifest-snapshot.sh"
144+
destination = "/tmp/manifest-snapshot.sh"
145+
}
146+
147+
provisioner "shell" {
148+
inline = [
149+
"chmod +x /tmp/manifest-snapshot.sh",
150+
"sudo /tmp/manifest-snapshot.sh > /tmp/ami-manifest.txt",
151+
"rm /tmp/manifest-snapshot.sh"
152+
]
153+
}
154+
155+
provisioner "file" {
156+
source = "/tmp/ami-manifest.txt"
157+
destination = "/tmp/ami-manifest.txt"
158+
direction = "download"
159+
}
141160
}

‎testinfra/manifest-snapshot.sh‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
EXCLUDE='^/(proc|run|tmp|var/log|data)(/|$)'
5+
6+
find / -xdev \( -type f -o -type l \) 2>/dev/null | grep -Ev "$EXCLUDE" | sort | while read -r f; do
7+
if [ -L "$f" ]; then
8+
printf '%s\tlink\t%s\n' "$f" "$(readlink "$f")"
9+
else
10+
printf '%s\t%s\t%s\n' "$f" "$(stat -c '%a:%U:%G' "$f" 2>/dev/null || echo '?')" "$(sha256sum "$f" 2>/dev/null | cut -d' ' -f1)"
11+
fi
12+
done
13+
14+
echo '--- units ---'
15+
systemctl list-unit-files --no-pager 2>/dev/null | sort
16+
echo '--- users ---'
17+
getent passwd | sort
18+
echo '--- groups ---'
19+
getent group | sort
20+
echo '--- nft ---'
21+
nft list ruleset 2>/dev/null || true
22+
echo '--- sysctl ---'
23+
sysctl -a 2>/dev/null | sort

0 commit comments

Comments
 (0)