-
Notifications
You must be signed in to change notification settings - Fork 37
328 lines (282 loc) · 12.6 KB
/
Copy pathporch-compat-matrix.yaml
File metadata and controls
328 lines (282 loc) · 12.6 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# Copyright 2026 The kpt Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CLI Compatibility Matrix
on:
workflow_dispatch:
schedule:
- cron: "0 8 * * 1" # Every Monday at 8AM UTC
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
KIND_CONTEXT_NAME: porch-test
jobs:
# ---------------------------------------------------------------------------
# 1. Resolve the last 4 published releases and build the server matrix
# ---------------------------------------------------------------------------
resolve-versions:
name: Resolve Versions
runs-on: ubuntu-latest
outputs:
releases: ${{ steps.releases.outputs.versions }}
server_matrix: ${{ steps.matrix.outputs.server_matrix }}
steps:
- name: Get last 4 releases
id: releases
env:
GH_TOKEN: ${{ github.token }}
UPSTREAM_REPO: kptdev/porch
run: |
# Always query upstream repo for releases (works correctly from forks)
VERSIONS=$(gh api repos/${UPSTREAM_REPO}/releases \
--jq '[.[] | select(.draft == false)] | sort_by(.published_at) | reverse | .[0:4] | [.[].tag_name]')
echo "versions=${VERSIONS}" >> "$GITHUB_OUTPUT"
echo "Resolved releases: ${VERSIONS}"
- name: Build server matrix
id: matrix
run: |
RELEASES='${{ steps.releases.outputs.versions }}'
SERVER_MATRIX=$(echo "$RELEASES" | jq -c '{include: ([{server_version: "latest"}] + [.[] | {server_version: .}])}')
echo "server_matrix=${SERVER_MATRIX}" >> "$GITHUB_OUTPUT"
echo "Server matrix:"
echo "$SERVER_MATRIX" | jq .
# ---------------------------------------------------------------------------
# 2. One self-contained runner per porch server version
# Each runner: checks out the version source, builds & deploys from it,
# then tests all CLI versions sequentially.
# ---------------------------------------------------------------------------
compat-test:
name: "Server ${{ matrix.server_version }}"
runs-on: ubuntu-latest
timeout-minutes: 60
needs: resolve-versions
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.resolve-versions.outputs.server_matrix) }}
env:
RELEASES: ${{ needs.resolve-versions.outputs.releases }}
steps:
# --- Step 1: Checkout the server version's source code ---
- name: Checkout upstream latest (1.5 branch)
if: matrix.server_version == 'latest'
uses: actions/checkout@v4
with:
repository: kptdev/porch
ref: '1.5' # NOTE this should revert back to main when we merge back
- name: Checkout upstream tag ${{ matrix.server_version }}
if: matrix.server_version != 'latest'
uses: actions/checkout@v4
with:
repository: kptdev/porch
ref: ${{ matrix.server_version }}
# --- Step 2: Setup tooling ---
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# --- Install's kpt based on porch go.mod native version ---
- name: Install kpt
run: |
KPT_VERSION=$(go list -m -f '{{.Version}}' github.com/kptdev/kpt 2>/dev/null)
if [ -z "${KPT_VERSION}" ]; then
echo "::error::Failed to resolve kpt version from go.mod. Cannot proceed with tests."
exit 1
fi
echo "Installing kpt ${KPT_VERSION}"
curl -fsSL "https://github.com/kptdev/kpt/releases/download/${KPT_VERSION}/kpt_linux_amd64-${KPT_VERSION#v}.tar.gz" | tar -xz -C /usr/local/bin/
# Save kpt version for result reporting
mkdir -p .build
echo "${KPT_VERSION}" > .build/kpt-version.txt
# --- Install's Kind without deploying a cluster ---
- name: Install Kind
uses: helm/kind-action@v1
with:
version: v0.30.0
install_only: true
- name: Set up Git config
run: |
git config --global user.name "Porch Compat"
git config --global user.email "porch-compat@porch.dev"
# --- Step 3: Setup dev env (kind + gitea + MetalLB + porchctl) ---
- name: Setup dev env
run: |
echo "=============================================="
echo "[SETUP] Setting up dev env for server ${{ matrix.server_version }}"
echo "=============================================="
./scripts/setup-dev-env.sh
# --- Step 4: Build and deploy porch with DB cache ---
- name: Build and deploy porch (DB cache, no git server)
run: |
echo "=============================================="
echo "[DEPLOY] Building and deploying porch server ${{ matrix.server_version }} with DB cache"
echo "=============================================="
make run-in-kind-db-cache-no-git
# --- Step 5: Download the CLI binaries ---
- name: Download released CLI versions
run: |
UPSTREAM_REPO="kptdev/porch"
for VERSION in $(echo "$RELEASES" | jq -r '.[]'); do
VERSION_NUM="${VERSION#v}"
CLI_URL="https://github.com/${UPSTREAM_REPO}/releases/download/${VERSION}/porchctl_${VERSION_NUM}_linux_amd64.tar.gz"
echo "Downloading porchctl ${VERSION} from ${CLI_URL}"
mkdir -p ".build/cli/${VERSION}"
curl -fsSL "${CLI_URL}" | tar -xz -C ".build/cli/${VERSION}/"
chmod +x ".build/cli/${VERSION}/porchctl"
done
# Also save the locally built porchctl as "latest"
mkdir -p .build/cli/latest
cp .build/porchctl .build/cli/latest/porchctl
echo "Available CLI versions:"
for d in .build/cli/*/; do
VERSION=$(basename "$d")
echo " ${VERSION}: $("${d}porchctl" version 2>/dev/null || echo 'version check skipped')"
done
# --- Step 6: Run CLI tests with each porchctl version sequentially ---
- name: Run CLI tests with all porchctl versions
id: run-tests
run: |
set +e
mkdir -p .build/compat-results
CLI_VERSIONS="latest $(echo "$RELEASES" | jq -r '.[]')"
for CLI_VERSION in $CLI_VERSIONS; do
echo ""
echo "=============================================="
echo "[TEST] CLI ${CLI_VERSION} against server ${{ matrix.server_version }}"
echo "=============================================="
# Swap the porchctl binary
cp "${GITHUB_WORKSPACE}/.build/cli/${CLI_VERSION}/porchctl" "${GITHUB_WORKSPACE}/.build/porchctl"
echo "[TEST] Using porchctl from ${CLI_VERSION}:"
.build/porchctl version 2>/dev/null || echo " version check skipped"
LOG_FILE=".build/compat-results/test-${CLI_VERSION}.log"
E2E=1 go test -v -timeout 20m ./test/e2e/cli 2>&1 | tee "${LOG_FILE}"
TEST_EXIT=${PIPESTATUS[0]}
# Parse results
RESULT="pass"
FAILED_TESTS=""
if [ $TEST_EXIT -ne 0 ]; then
RESULT="fail"
FAILED_TESTS=$(grep -E '^\s*--- FAIL:' "${LOG_FILE}" | sed 's/.*--- FAIL: //' | sed 's/ (.*//' | tr '\n' ',' | sed 's/,$//')
fi
# Write result JSON
cat > ".build/compat-results/result-${CLI_VERSION}.json" <<EOJSON
{
"server_version": "${{ matrix.server_version }}",
"cli_version": "${CLI_VERSION}",
"kpt_version": "$(cat .build/kpt-version.txt 2>/dev/null || echo 'unknown')",
"result": "${RESULT}",
"failed_tests": "${FAILED_TESTS}"
}
EOJSON
echo "Result: ${RESULT}"
echo "Failed tests: ${FAILED_TESTS}"
done
# --- Step 7: Upload results + server logs ---
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: "compat-results-${{ matrix.server_version }}"
path: .build/compat-results/
retention-days: 5
- name: Export porch server logs
if: always()
run: |
name=$(kubectl -n porch-system get pod -l app=porch-server -o custom-columns=NAME:.metadata.name --no-headers=true 2>/dev/null || echo "")
if [ -n "$name" ]; then
kubectl -n porch-system logs "$name" > server.log 2>/dev/null || true
fi
- name: Archive server logs
if: always()
uses: actions/upload-artifact@v4
with:
name: "server-log-${{ matrix.server_version }}"
path: server.log
compression-level: 0
retention-days: 2
if-no-files-found: ignore
# ---------------------------------------------------------------------------
# 3. Aggregate results into a compatibility matrix summary
# ---------------------------------------------------------------------------
compat-summary:
name: Compatibility Matrix Summary
if: always()
needs: [resolve-versions, compat-test]
runs-on: ubuntu-latest
steps:
- name: Download all result artifacts
uses: actions/download-artifact@v4
with:
pattern: compat-results-*
path: results/
- name: Generate compatibility matrix
run: |
RELEASES='${{ needs.resolve-versions.outputs.releases }}'
# Collect all result JSONs into a single array
RESULTS=$(find results/ -name 'result-*.json' -exec cat {} \; | jq -s '.')
# Build the markdown table
CLI_VERSIONS=$(echo "$RELEASES" | jq -r '["latest"] + . | .[]')
SERVER_VERSIONS=$(echo "$RELEASES" | jq -r '["latest"] + . | .[]')
# Header
HEADER="| Server ↓ \ CLI → |"
SEP="|---|"
for cv in $CLI_VERSIONS; do
HEADER="${HEADER} ${cv} |"
SEP="${SEP}---|"
done
{
echo "## CLI Compatibility Matrix (DB Cache)"
echo ""
echo "$HEADER"
echo "$SEP"
for sv in $SERVER_VERSIONS; do
# Extract kpt version for this server from any of its results
KPT_VER=$(echo "$RESULTS" | jq -r --arg sv "$sv" '
map(select(.server_version == $sv)) | .[0].kpt_version // "unknown"
')
ROW="| ${sv} (kpt ${KPT_VER}) |"
for cv in $CLI_VERSIONS; do
CELL=$(echo "$RESULTS" | jq -r --arg sv "$sv" --arg cv "$cv" '
map(select(.server_version == $sv and .cli_version == $cv)) |
if length == 0 then "⚪ N/A"
elif .[0].result == "pass" then "✅ All tests passed"
else
.[0].failed_tests as $ft |
if ($ft | length) > 0 then
"❌ " + ($ft | split(",") | map(select(. != "TestPorch")) | map(split("/") | last) | .[0:3] | join(", ")) +
(if ($ft | split(",") | map(select(. != "TestPorch")) | length) > 3 then " +" + (($ft | split(",") | map(select(. != "TestPorch")) | length) - 3 | tostring) + " more" else "" end)
else "❌"
end
end
')
ROW="${ROW} ${CELL} |"
done
echo "$ROW"
done
echo ""
echo "- ✅ = All CLI tests passed"
echo "- ❌ = One or more tests failed (failed test names shown)"
echo "- ⚪ = Test did not run"
echo ""
echo "**Note:** Tests are run using the native kpt version for each porch server release (shown in parentheses)."
echo "This version is resolved from the go.mod file of each server version. Results may differ if a different kpt version is used."
} | tee -a "$GITHUB_STEP_SUMMARY"
- name: Check for failures
run: |
# Fail the workflow if any test failed
FAILED=$(find results/ -name 'result-*.json' -exec grep -l '"result": "fail"' {} \;)
if [ -n "$FAILED" ]; then
echo "::error::Some compatibility tests failed. See the matrix summary above."
exit 1
fi