Skip to content

Commit 744dba8

Browse files
AntonyAntony
authored andcommitted
chore(ci): add skeleton for nightly E2E matrix workflow with setup, matrix setup and cleanup
- Setup profiles: single profile 'sds' with storage class 'sds-replicated-volume' - Matrix setup (prepare): real setup logic with tools installation, kubeconfig, values preparation - Cleanup: real cleanup logic for nightly-nested-e2e-* namespaces Signed-off-by: Anton T. <[email protected]>
1 parent 75ae7a0 commit 744dba8

File tree

1 file changed

+257
-6
lines changed

1 file changed

+257
-6
lines changed

.github/workflows/e2e-matrix.yml

Lines changed: 257 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,274 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: E2E Matrix Tests (bootstrap)
15+
name: E2E Matrix Tests (Skeleton)
1616

1717
on:
18+
push:
19+
branches:
20+
- chore/ci/e2e-matrix-skeleton
1821
pull_request:
1922
types: [opened, reopened, synchronize, labeled, unlabeled]
2023
branches:
2124
- main
22-
- feat/ci-e2e-matrix
25+
- chore/ci/e2e-matrix-skeleton
26+
schedule:
27+
- cron: "30 2 * * *"
2328
workflow_dispatch:
29+
inputs:
30+
profiles:
31+
description: "Storage profiles (comma-separated): sds, cephrbd"
32+
required: false
33+
default: "sds,cephrbd"
34+
timeout:
35+
description: "Ginkgo timeout (e.g. 2h, 4h)"
36+
required: false
37+
default: "4h"
2438

2539
permissions:
2640
contents: read
2741

42+
env:
43+
E2E_K8S_URL: https://api.e2e.virtlab.flant.com
44+
2845
jobs:
29-
noop:
30-
name: Bootstrap
46+
setup:
47+
name: Setup Profiles
3148
runs-on: ubuntu-latest
49+
outputs:
50+
profiles: ${{ steps.profiles.outputs.profiles }}
3251
steps:
33-
- name: Say hello
34-
run: echo "Bootstrap workflow OK"
52+
- uses: actions/checkout@v4
53+
54+
- name: Load storage profiles
55+
id: profiles
56+
run: |
57+
# Single profile: sds with storage class sds-replicated-volume
58+
echo 'profiles=["sds"]' >> "$GITHUB_OUTPUT"
59+
60+
- name: Print matrix
61+
run: |
62+
echo "Will test profiles: ${{ steps.profiles.outputs.profiles }}"
63+
64+
prepare:
65+
name: Matrix Setup (${{ matrix.profile }})
66+
needs: [setup]
67+
runs-on: ubuntu-latest
68+
timeout-minutes: 300
69+
concurrency:
70+
group: prepare-${{ github.ref }}-${{ matrix.profile }}
71+
cancel-in-progress: true
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
profile: ${{ fromJson(needs.setup.outputs.profiles) }}
76+
77+
env:
78+
GO_VERSION: "1.24.6"
79+
TMP_ROOT: ${{ github.workspace }}/ci/dvp-e2e/tmp
80+
STORAGE_CLASS: sds-replicated-volume
81+
82+
outputs:
83+
run_id: ${{ steps.prep.outputs.run_id }}
84+
storage_class: ${{ env.STORAGE_CLASS }}
85+
86+
steps:
87+
- uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0
90+
91+
- name: Install Task
92+
uses: arduino/setup-task@v2
93+
with:
94+
version: 3.x
95+
repo-token: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Install Helm
98+
uses: azure/[email protected]
99+
with:
100+
version: v3.17.2
101+
102+
- name: Install kubectl
103+
uses: azure/setup-kubectl@v4
104+
with:
105+
version: 'latest'
106+
107+
- name: Install Deckhouse CLI
108+
env:
109+
D8_VERSION: v0.13.2
110+
run: |
111+
set -euo pipefail
112+
echo "Installing d8 ${D8_VERSION}..."
113+
curl -fsSL -o d8.tgz "https://deckhouse.io/downloads/deckhouse-cli/${D8_VERSION}/d8-${D8_VERSION}-linux-amd64.tar.gz"
114+
tar -xzf d8.tgz linux-amd64/bin/d8
115+
mv linux-amd64/bin/d8 /usr/local/bin/d8
116+
chmod +x /usr/local/bin/d8
117+
rm -rf d8.tgz linux-amd64
118+
d8 --version
119+
120+
- name: Install yq
121+
run: |
122+
echo "Installing yq..."
123+
curl -L -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.1/yq_linux_amd64
124+
chmod +x /usr/local/bin/yq
125+
126+
- name: Prepare environment
127+
id: prep
128+
run: |
129+
RUN_ID="nightly-nested-e2e-${{ matrix.profile }}-$(date +%H%M)"
130+
echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
131+
echo "RUN_ID=$RUN_ID" >> "$GITHUB_ENV"
132+
echo "PROFILE=${{ matrix.profile }}" >> "$GITHUB_ENV"
133+
echo "TMP_ROOT=${{ env.TMP_ROOT }}" >> "$GITHUB_ENV"
134+
mkdir -p "${{ env.TMP_ROOT }}/shared" "${{ env.TMP_ROOT }}/matrix-logs"
135+
136+
- name: Build parent kubeconfig from secret
137+
shell: bash
138+
run: |
139+
set -euo pipefail
140+
mkdir -p "$HOME/.kube"
141+
cat > "$HOME/.kube/config" <<EOF
142+
apiVersion: v1
143+
kind: Config
144+
clusters:
145+
- cluster:
146+
server: ${E2E_K8S_URL}
147+
insecure-skip-tls-verify: true
148+
name: parent
149+
contexts:
150+
- context:
151+
cluster: parent
152+
user: sa
153+
name: parent
154+
current-context: parent
155+
users:
156+
- name: sa
157+
user:
158+
token: "${{ secrets.E2E_NESTED_SA_SECRET }}"
159+
EOF
160+
chmod 600 "$HOME/.kube/config"
161+
echo "KUBECONFIG=$HOME/.kube/config" >> "$GITHUB_ENV"
162+
163+
- name: Prepare run values.yaml
164+
working-directory: ci/dvp-e2e
165+
run: |
166+
task run:values:prepare \
167+
RUN_ID="${{ env.RUN_ID }}" \
168+
RUN_NAMESPACE="${{ env.RUN_ID }}" \
169+
RUN_DIR="${{ env.TMP_ROOT }}/runs/${{ env.RUN_ID }}"
170+
echo "VALUES_TEMPLATE_FILE=${{ env.TMP_ROOT }}/runs/${{ env.RUN_ID }}/values.yaml" >> $GITHUB_ENV
171+
172+
- name: Configure storage profile
173+
working-directory: ci/dvp-e2e
174+
run: |
175+
# Set storage profile to sds with storage class sds-replicated-volume
176+
PROFILE='sds' yq eval --inplace '.storageProfile = strenv(PROFILE)' "${{ env.TMP_ROOT }}/runs/${{ env.RUN_ID }}/values.yaml"
177+
echo "Configured storage profile: sds with storage class: ${STORAGE_CLASS}"
178+
179+
- name: Upload run context
180+
if: always()
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: run-context-${{ env.RUN_ID }}
184+
path: |
185+
ci/dvp-e2e/tmp/runs/${{ env.RUN_ID }}
186+
ci/dvp-e2e/tmp/shared
187+
if-no-files-found: warn
188+
189+
run-e2e:
190+
name: E2E (${{ matrix.profile }}) [skeleton]
191+
needs: [setup, prepare]
192+
runs-on: ubuntu-latest
193+
concurrency:
194+
group: e2e-${{ github.ref }}-${{ matrix.profile }}
195+
cancel-in-progress: true
196+
strategy:
197+
fail-fast: false
198+
matrix:
199+
profile: ${{ fromJson(needs.setup.outputs.profiles) }}
200+
steps:
201+
- name: Echo run
202+
run: |
203+
echo "E2E stage for profile=${{ matrix.profile }} (skeleton - placeholder)"
204+
report:
205+
name: Report [skeleton]
206+
needs: [setup, run-e2e]
207+
if: always()
208+
runs-on: ubuntu-latest
209+
steps:
210+
- name: Echo report
211+
run: |
212+
echo "Report stage (skeleton). Collecting results from matrix..."
213+
214+
cleanup:
215+
name: Cleanup Resources
216+
needs: report
217+
if: always()
218+
runs-on: ubuntu-latest
219+
steps:
220+
- uses: actions/checkout@v4
221+
222+
- name: Install Task
223+
uses: arduino/setup-task@v2
224+
225+
- name: Install kubectl
226+
uses: azure/setup-kubectl@v4
227+
with:
228+
version: 'latest'
229+
230+
- name: Build parent kubeconfig from secret (cleanup)
231+
shell: bash
232+
run: |
233+
set -euo pipefail
234+
mkdir -p "$HOME/.kube"
235+
cat > "$HOME/.kube/config" <<EOF
236+
apiVersion: v1
237+
kind: Config
238+
clusters:
239+
- cluster:
240+
server: ${E2E_K8S_URL}
241+
insecure-skip-tls-verify: true
242+
name: parent
243+
contexts:
244+
- context:
245+
cluster: parent
246+
user: sa
247+
name: parent
248+
current-context: parent
249+
users:
250+
- name: sa
251+
user:
252+
token: "${{ secrets.E2E_NESTED_SA_SECRET }}"
253+
EOF
254+
chmod 600 "$HOME/.kube/config"
255+
echo "KUBECONFIG=$HOME/.kube/config" >> "$GITHUB_ENV"
256+
257+
- name: Cleanup test namespaces
258+
run: |
259+
set -euo pipefail
260+
PREFIX="nightly-nested-e2e-"
261+
echo "🧹 Cleaning up namespaces matching prefix '${PREFIX}'"
262+
mapfile -t CANDIDATES < <(kubectl get ns -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep "^${PREFIX}" || true)
263+
OURS=()
264+
for ns in "${CANDIDATES[@]:-}"; do
265+
[ -z "$ns" ] && continue
266+
if kubectl -n "$ns" get deploy jump-host >/dev/null 2>&1; then
267+
OURS+=("$ns")
268+
fi
269+
done
270+
if [ "${#OURS[@]}" -eq 0 ]; then
271+
echo "[INFO] No namespaces to delete."
272+
else
273+
echo "[INFO] Deleting namespaces:"
274+
printf ' - %s\n' "${OURS[@]}"
275+
for ns in "${OURS[@]}"; do
276+
kubectl delete ns "$ns" --wait=false || true
277+
done
278+
fi
279+
280+
- name: Report cleanup results
281+
if: always()
282+
run: |
283+
echo "### Cleanup Results" >> $GITHUB_STEP_SUMMARY
284+
echo "✅ Cleanup job completed" >> $GITHUB_STEP_SUMMARY
285+
echo "🧹 Attempted to clean up namespaces matching 'nightly-nested-e2e-*'" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)