-
-
Notifications
You must be signed in to change notification settings - Fork 245
144 lines (128 loc) · 4.96 KB
/
docker-image-test.yml
File metadata and controls
144 lines (128 loc) · 4.96 KB
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
name: Docker Image Test
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- develop
- release/*
workflow_call:
secrets:
DEV_AWS_ROLE:
required: true
NIX_SIGN_SECRET_KEY:
required: true
workflow_dispatch:
inputs:
dockerfile:
description: 'Specific Dockerfile to test (leave empty for all)'
required: false
default: ''
type: string
permissions:
id-token: write
contents: read
jobs:
check-changes:
name: Check Docker Image Changes
runs-on: blacksmith-2vcpu-ubuntu-2404
outputs:
should_run: ${{ steps.check.outputs.should_run }}
input_hash: ${{ steps.check.outputs.input_hash }}
steps:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install nix
uses: ./.github/actions/nix-install-ephemeral
with:
push-to-cache: 'false'
env:
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
- name: Check Docker image changes
id: check
uses: ./.github/actions/check-docker-image-changes
with:
event_name: ${{ github.event_name }}
base_ref: ${{ github.base_ref }}
docker-image-test:
name: Test ${{ matrix.name }}
needs: check-changes
if: needs.check-changes.outputs.should_run == 'true'
runs-on: large-linux-arm
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- { dockerfile: Dockerfile-15, target: "", name: 15 }
- { dockerfile: Dockerfile-17, target: "", name: 17 }
- { dockerfile: Dockerfile-orioledb-17, target: "", name: orioledb-17 }
- { dockerfile: Dockerfile-multigres, target: variant-17, name: multigres-17 }
- { dockerfile: Dockerfile-multigres, target: variant-orioledb-17, name: multigres-orioledb-17 }
steps:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install nix
uses: ./.github/actions/nix-install-ephemeral
with:
push-to-cache: 'false'
env:
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
- name: Create Docker context
run: docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
with:
endpoint: builders
- name: Build Docker image
run: |
echo "Building ${{ matrix.name }}..."
TARGET_ARG=""
if [ -n "${{ matrix.target }}" ]; then
TARGET_ARG="--target ${{ matrix.target }}"
fi
docker build -f "${{ matrix.dockerfile }}" $TARGET_ARG \
-t "pg-docker-test:${{ matrix.name }}" \
-t "supabase-postgres:${{ matrix.name }}-analyze" \
.
- name: Run image size analysis
if: ${{ matrix.target == '' }}
run: |
echo "=== Image Size Analysis for ${{ matrix.name }} ==="
nix run --accept-flake-config .#image-size-analyzer -- --image Dockerfile-${{ matrix.name }} --no-build
- name: Run Docker image tests
if: ${{ matrix.target == '' }}
run: |
echo "=== Running tests for ${{ matrix.name }} ==="
nix run --accept-flake-config .#docker-image-test -- --no-build Dockerfile-${{ matrix.name }}
- name: Run multigres Docker image tests
if: ${{ matrix.target != '' }}
run: |
echo "=== Running tests for ${{ matrix.name }} ==="
nix run --accept-flake-config .#docker-image-test -- --no-build --target ${{ matrix.target }} ${{ matrix.dockerfile }}
- name: Show container logs on failure
if: failure()
run: |
CONTAINER_NAME=$(docker ps -a --filter "name=pg-test-${{ matrix.name }}" --format "{{.Names}}" | head -1)
if [[ -n "$CONTAINER_NAME" ]]; then
echo "=== Container logs for $CONTAINER_NAME ==="
docker logs "$CONTAINER_NAME" 2>&1 || true
fi
- name: Cleanup
if: always()
run: |
docker ps -a --filter "name=pg-test-${{ matrix.name }}" -q | xargs -r docker rm -f || true
docker rmi "pg-docker-test:${{ matrix.name }}" || true
docker rmi "supabase-postgres:${{ matrix.name }}-analyze" || true
skip-notification:
name: Docker Image Test (Skipped)
needs: check-changes
if: needs.check-changes.outputs.should_run == 'false'
runs-on: ubuntu-latest
steps:
- name: Report skipped
run: |
echo "Docker image tests skipped - inputs unchanged"
echo "Input hash: ${{ needs.check-changes.outputs.input_hash }}"