-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (122 loc) · 4.69 KB
/
test_images.yaml
File metadata and controls
141 lines (122 loc) · 4.69 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
name: test-images
# This workflow can be triggered manually from any branch.
# Select the branch in the GitHub Actions UI when triggering the workflow.
on:
workflow_dispatch:
inputs:
package_repository:
description: "Package repository name (e.g., pgedge-postgres-internal, pgedge-postgres)"
type: string
default: "pgedge-postgres-internal"
required: false
tags:
description: "Comma-separated list of tags to test (e.g., 17-spock5-standard,17-spock5-minimal)"
type: string
required: true
architectures:
description: "Comma-separated list of architectures to test (x86,arm)"
type: string
default: "x86,arm"
required: false
permissions:
contents: read
packages: read
env:
IMAGE_REGISTRY: ghcr.io/pgedge
jobs:
# Parse inputs and generate the test matrix
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- name: Generate test matrix
id: generate
run: |
# Parse tags
IFS=',' read -ra TAGS <<< "${{ inputs.tags }}"
# Parse architectures
IFS=',' read -ra ARCHS <<< "${{ inputs.architectures }}"
# Build matrix JSON
matrix_items=""
for tag in "${TAGS[@]}"; do
tag=$(echo "$tag" | xargs) # trim whitespace
# Determine flavor from tag
if [[ "$tag" == *"-minimal"* ]]; then
flavor="minimal"
elif [[ "$tag" == *"-standard"* ]]; then
flavor="standard"
else
# Default to standard if not specified
flavor="standard"
fi
for arch in "${ARCHS[@]}"; do
arch=$(echo "$arch" | xargs) # trim whitespace
# Map user-friendly arch names to runner names
# Accept "arm" or "arm64" -> use ubuntu-24.04-arm
# Accept "x86" or "amd64" -> use ubuntu-latest
if [[ "$arch" == "arm" ]] || [[ "$arch" == "arm64" ]]; then
runner="ubuntu-24.04-arm"
arch_display="arm"
elif [[ "$arch" == "x86" ]] || [[ "$arch" == "amd64" ]]; then
runner="ubuntu-latest"
arch_display="x86"
else
echo "Error: Unknown architecture '$arch'. Use 'x86' or 'arm'"
exit 1
fi
if [[ -n "$matrix_items" ]]; then
matrix_items+=","
fi
matrix_items+="{\"tag\":\"$tag\",\"arch\":\"$arch_display\",\"flavor\":\"$flavor\",\"runner\":\"$runner\"}"
done
done
echo "matrix={\"include\":[$matrix_items]}" >> $GITHUB_OUTPUT
echo "Generated matrix: {\"include\":[$matrix_items]}"
test:
needs: setup
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.11'
cache-dependency-path: tests/go.sum
- name: Login to GitHub Container Registry
env:
GH_USER: ${{ github.actor }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${GH_TOKEN}" | docker login ghcr.io -u "${GH_USER}" --password-stdin
- name: Pull image
run: |
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ inputs.package_repository }}:${{ matrix.tag }}"
echo "Pulling image: $IMAGE"
docker pull "$IMAGE"
- name: Run tests
run: |
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ inputs.package_repository }}:${{ matrix.tag }}"
make test-image IMAGE="$IMAGE" FLAVOR="${{ matrix.flavor }}"
results-summary:
needs: [setup, test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Summary
run: |
echo "| Input | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Package Repository | ${{ inputs.package_repository }} |" >> $GITHUB_STEP_SUMMARY
echo "| Tags | ${{ inputs.tags }} |" >> $GITHUB_STEP_SUMMARY
echo "| Architectures | ${{ inputs.architectures }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.test.result }}" == "success" ]]; then
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Some tests failed.** Check the job logs for details." >> $GITHUB_STEP_SUMMARY
fi