Skip to content

Commit f8bdf2f

Browse files
committed
.github/workflows: refactor matrix to make it more easily customizable
This uses a job to generate the matrix (hard coded today, we could definitely generate it from other inputs as well) instead of using the matrix syntax. Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
1 parent cc65a8f commit f8bdf2f

1 file changed

Lines changed: 32 additions & 39 deletions

File tree

.github/workflows/e2e-matrix.yml

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,54 +15,53 @@ defaults:
1515
shell: bash
1616

1717
jobs:
18+
generate-matrix:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
matrix: ${{ steps.set-matrix.outputs.matrix }}
22+
steps:
23+
- id: set-matrix
24+
run: |
25+
if [[ "${{ inputs.minimal }}" == "true" ]]; then
26+
# Minimal set: only one job
27+
matrix='{"include":[{"os":"ubuntu-latest","k8s-name":"k8s-latest","k8s-version":"v1.34.x","feature-flags":"stable"}]}'
28+
else
29+
# Full matrix:
30+
# - amd64: all combinations (2 k8s versions x 3 feature flags = 6 jobs)
31+
# - arm64: only k8s-latest with stable (1 job)
32+
# Total: 7 jobs
33+
matrix='{
34+
"include": [
35+
{"os": "ubuntu-latest", "k8s-name": "k8s-oldest", "k8s-version": "v1.28.x", "feature-flags": "stable"},
36+
{"os": "ubuntu-latest", "k8s-name": "k8s-oldest", "k8s-version": "v1.28.x", "feature-flags": "beta"},
37+
{"os": "ubuntu-latest", "k8s-name": "k8s-oldest", "k8s-version": "v1.28.x", "feature-flags": "alpha"},
38+
{"os": "ubuntu-latest", "k8s-name": "k8s-latest", "k8s-version": "v1.34.x", "feature-flags": "stable"},
39+
{"os": "ubuntu-latest", "k8s-name": "k8s-latest", "k8s-version": "v1.34.x", "feature-flags": "beta"},
40+
{"os": "ubuntu-latest", "k8s-name": "k8s-latest", "k8s-version": "v1.34.x", "feature-flags": "alpha"},
41+
{"os": "ubuntu-24.04-arm", "k8s-name": "k8s-latest", "k8s-version": "v1.34.x", "feature-flags": "stable"}
42+
]
43+
}'
44+
fi
45+
echo "matrix=$(echo $matrix | jq -c .)" >> $GITHUB_OUTPUT
46+
1847
e2e-tests:
48+
needs: generate-matrix
1949
concurrency:
2050
group: ${{ github.workflow }}-${{ matrix.os }}-${{ matrix.k8s-name }}-${{ matrix.feature-flags }}-${{ github.event.pull_request.number || github.ref }}
2151
cancel-in-progress: true
2252
name: e2e tests
2353
runs-on: ${{ matrix.os }}
2454
strategy:
2555
fail-fast: false # Keep running if one leg fails.
26-
matrix:
27-
os:
28-
- ubuntu-latest # amd64
29-
- ubuntu-24.04-arm # arm64
30-
31-
k8s-name:
32-
- k8s-oldest # 1.28
33-
- k8s-latest # 1.34
34-
35-
feature-flags:
36-
- stable
37-
- beta
38-
- alpha
39-
40-
include:
41-
- k8s-name: k8s-oldest
42-
k8s-version: v1.28.x
43-
- k8s-name: k8s-latest
44-
k8s-version: v1.34.x
45-
46-
# Limit arm64: only run k8s-latest on arm64 (stable), skip oldest on arm64
47-
exclude:
48-
- k8s-name: k8s-oldest
49-
os: ubuntu-24.04-arm
50-
- k8s-name: k8s-latest
51-
os: ubuntu-24.04-arm
52-
feature-flags: beta
53-
- k8s-name: k8s-latest
54-
os: ubuntu-24.04-arm
55-
feature-flags: alpha
56+
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
5657
env:
5758
KO_DOCKER_REPO: registry.local:5000/tekton
5859
CLUSTER_DOMAIN: c${{ github.run_id }}.local
5960
ARTIFACTS: ${{ github.workspace }}/artifacts
6061

6162
steps:
6263
- name: Free disk space
63-
if: |
64-
matrix.os != 'ubuntu-24.04-arm' &&
65-
(!inputs.minimal || (matrix.os == 'ubuntu-latest' && matrix.k8s-name == 'k8s-latest' && matrix.feature-flags == 'stable'))
64+
if: matrix.os != 'ubuntu-24.04-arm'
6665
run: |
6766
echo "--- Disk space before cleanup ---"
6867
df -h
@@ -74,16 +73,12 @@ jobs:
7473
echo "--- Disk space after cleanup ---"
7574
df -h
7675
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
77-
if: ${{ !inputs.minimal || (matrix.os == 'ubuntu-latest' && matrix.k8s-name == 'k8s-latest' && matrix.feature-flags == 'stable') }}
7876
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
79-
if: ${{ !inputs.minimal || (matrix.os == 'ubuntu-latest' && matrix.k8s-name == 'k8s-latest' && matrix.feature-flags == 'stable') }}
8077
with:
8178
go-version-file: "go.mod"
8279
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
83-
if: ${{ !inputs.minimal || (matrix.os == 'ubuntu-latest' && matrix.k8s-name == 'k8s-latest' && matrix.feature-flags == 'stable') }}
8480

8581
- name: Install Dependencies
86-
if: ${{ !inputs.minimal || (matrix.os == 'ubuntu-latest' && matrix.k8s-name == 'k8s-latest' && matrix.feature-flags == 'stable') }}
8782
working-directory: ./
8883
run: |
8984
echo '::group:: install go-junit-report'
@@ -97,7 +92,6 @@ jobs:
9792
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
9893
9994
- name: Run tests
100-
if: ${{ !inputs.minimal || (matrix.os == 'ubuntu-latest' && matrix.k8s-name == 'k8s-latest' && matrix.feature-flags == 'stable') }}
10195
run: |
10296
# This is a hack to make sure binary in /bin from the base image are not picked by default
10397
# On ubuntu-arm, there is a /bin/go that shadows the one setup-go installs
@@ -112,7 +106,6 @@ jobs:
112106
--e2e-env ./test/e2e-tests-kind-${{ matrix.feature-flags }}.env
113107
114108
- name: Upload test results
115-
if: ${{ !inputs.minimal || (matrix.os == 'ubuntu-latest' && matrix.k8s-name == 'k8s-latest' && matrix.feature-flags == 'stable') }}
116109
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
117110
with:
118111
name: ${{ matrix.k8s-version }}-${{ matrix.feature-flags }}-${{ matrix.os }}

0 commit comments

Comments
 (0)