-
Notifications
You must be signed in to change notification settings - Fork 59
103 lines (89 loc) · 3.49 KB
/
helmcharts-e2e.yaml
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
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: E2E test with helm charts
on:
pull_request:
branches: [main]
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
- helm-charts/**
- .github/workflows/scripts/chart-integration/**
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CHARTS_DIR: "helm-charts"
jobs:
job1:
name: Get-test-matrix
runs-on: ubuntu-latest
outputs:
run_matrix: ${{ steps.get-test-matrix.outputs.run_matrix }}
steps:
- name: Checkout out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get test matrix
id: get-test-matrix
run: |
changed_charts=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | \
grep '^$CHARTS_DIR/' | \
grep -vE 'README.md|common' | \
cut -d'/' -f2 | sort -u )
# set run_matrix to be "{"chart":["chart1","chart2",...]}"
run_matrix="{\"chart\":["
for chart in ${changed_charts}; do
run_matrix="${run_matrix}\"${chart}\","
done
run_matrix=$run_matrix"]}"
echo "run_matrix=${run_matrix}"
echo "run_matrix=${run_matrix}" >> $GITHUB_OUTPUT
Chart-test:
needs: job1
strategy:
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
runs-on: inspur-icx-1
continue-on-error: true
outputs:
should_cleanup: ${{ steps.set_boolean.outputs.should_cleanup }}
steps:
- name: E2e test chart
run: |
echo "Matrix - chart: ${{ matrix.chart }}"
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*
- name: Checkout out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set variables
run: |
echo "RELEASE_NAME=${{ matrix.chart }}$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "NAMESPACE=${{ matrix.chart }}-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "ROLLOUT_TIMEOUT_SECONDS=300s" >> $GITHUB_ENV
echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
echo "should_cleanup=false" >> $GITHUB_ENV
echo "RELEASENAME=$RELEASE_NAME"
echo "NAMESPACE=$NAMESPACE"
- name: Initialize chart testing
run: |
.github/workflows/scripts/chart-integration/lib.sh init_codegen
- name: Helm install
run: |
echo "should_cleanup=true" >> $GITHUB_ENV
if ! helm install --create-namespace --namespace $NAMESPACE --wait --timeout "$ROLLOUT_TIMEOUT_SECONDS" $RELEASE_NAME $CHARTS_DIR/${{ matrix.chart }} ; then
echo "Failed to install chart ${{ matrix.chart }}"
fi
- name: Validate e2e test
run: |
.github/workflows/scripts/chart-integration/lib.sh validate_codegen $RELEASE_NAME $NAMESPACE
- name: Helm uninstall
if: always() && ${{ needs.Chart-test.outputs.should_cleanup }}
run: |
helm uninstall $RELEASE_NAME --namespace $NAMESPACE
if ! kubectl delete ns $NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
kubectl delete pods --namespace $NAMESPACE --force --grace-period=0 --all
kubectl delete ns $NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
fi