-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (118 loc) · 4.37 KB
/
pr_test_latest.yaml
File metadata and controls
139 lines (118 loc) · 4.37 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
name: PR Test Latest Images
# This workflow runs on pull requests and tests the latest images
# from the internal repository to ensure they still work with any changes.
on:
pull_request:
branches:
- main
permissions:
contents: read
packages: read
env:
IMAGE_REGISTRY: ghcr.io/pgedge
PACKAGE_REPOSITORY: pgedge-postgres-internal
jobs:
# Get latest tags and generate test matrix
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
tags: ${{ steps.get-tags.outputs.tags }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Get latest tags
id: get-tags
run: |
TAGS=$(make latest-tags)
echo "tags=$TAGS" >> $GITHUB_OUTPUT
echo "Latest tags: $TAGS"
- name: Generate test matrix
id: generate
run: |
# Parse tags from make output
TAGS="${{ steps.get-tags.outputs.tags }}"
IFS=',' read -ra TAG_ARRAY <<< "$TAGS"
# Test on both architectures
ARCHS=("x86" "arm")
# Build matrix JSON
matrix_items=""
for tag in "${TAG_ARRAY[@]}"; 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
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: Pull image
run: |
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ env.PACKAGE_REPOSITORY }}:${{ matrix.tag }}"
echo "Pulling image: $IMAGE"
docker pull "$IMAGE"
- name: Run tests
run: |
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ env.PACKAGE_REPOSITORY }}:${{ matrix.tag }}"
make test-image IMAGE="$IMAGE" FLAVOR="${{ matrix.flavor }}"
results:
needs: [setup, test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Output
run: |
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Input | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Package Repository | ${{ env.PACKAGE_REPOSITORY }} |" >> $GITHUB_STEP_SUMMARY
echo "| Tags | ${{ needs.setup.outputs.tags }} |" >> $GITHUB_STEP_SUMMARY
echo "| Architectures | x86,arm |" >> $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