Skip to content

Commit 8570e30

Browse files
AntonyAntony
authored andcommitted
chore(ci): implement setup profiles, matrix setup and cleanup jobs
- 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 20821ac commit 8570e30

File tree

1 file changed

+188
-11
lines changed

1 file changed

+188
-11
lines changed

.github/workflows/e2e-matrix.yml

Lines changed: 188 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,152 @@ on:
3939
permissions:
4040
contents: read
4141

42+
env:
43+
E2E_K8S_URL: https://api.e2e.virtlab.flant.com
44+
4245
jobs:
4346
setup:
44-
name: Setup (skeleton)
47+
name: Setup Profiles
4548
runs-on: ubuntu-latest
4649
outputs:
4750
profiles: ${{ steps.profiles.outputs.profiles }}
4851
steps:
4952
- uses: actions/checkout@v4
5053

51-
- name: Set profiles matrix (static)
54+
- name: Load storage profiles
5255
id: profiles
5356
run: |
54-
echo 'profiles=["sds","cephrbd"]' >> "$GITHUB_OUTPUT"
57+
# Single profile: sds with storage class sds-replicated-volume
58+
echo 'profiles=["sds"]' >> "$GITHUB_OUTPUT"
5559
56-
- name: Echo planned matrix
60+
- name: Print matrix
5761
run: |
58-
echo "Matrix profiles: ${{ steps.profiles.outputs.profiles }}"
62+
echo "Will test profiles: ${{ steps.profiles.outputs.profiles }}"
5963
6064
prepare:
61-
name: Prepare (${{ matrix.profile }}) [skeleton]
65+
name: Matrix Setup (${{ matrix.profile }})
6266
needs: [setup]
6367
runs-on: ubuntu-latest
68+
timeout-minutes: 300
6469
concurrency:
6570
group: prepare-${{ github.ref }}-${{ matrix.profile }}
6671
cancel-in-progress: true
6772
strategy:
6873
fail-fast: false
6974
matrix:
7075
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+
7186
steps:
72-
- name: Echo prepare
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
73121
run: |
74-
echo "Prepare stage for profile=${{ matrix.profile }}"
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
75188

76189
run-e2e:
77190
name: E2E (${{ matrix.profile }}) [skeleton]
@@ -87,6 +200,7 @@ jobs:
87200
steps:
88201
- name: Echo run
89202
run: |
203+
echo "E2E stage for profile=${{ matrix.profile }} (skeleton - placeholder)"
90204
report:
91205
name: Report [skeleton]
92206
needs: [setup, run-e2e]
@@ -98,11 +212,74 @@ jobs:
98212
echo "Report stage (skeleton). Collecting results from matrix..."
99213
100214
cleanup:
101-
name: Cleanup [skeleton]
215+
name: Cleanup Resources
102216
needs: report
103217
if: always()
104218
runs-on: ubuntu-latest
105219
steps:
106-
- name: Echo cleanup
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()
107282
run: |
108-
echo "Cleanup stage (skeleton). Nothing to do."
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)