forked from janus-idp/helm-backstage
-
Notifications
You must be signed in to change notification settings - Fork 37
106 lines (95 loc) · 3.77 KB
/
Copy pathtest.yaml
File metadata and controls
106 lines (95 loc) · 3.77 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
name: Test Charts
on:
pull_request:
branches:
- main
- release-[0-9]+.[0-9]+
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
discover-charts:
name: Discover changed charts
runs-on: ubuntu-latest
outputs:
charts: ${{ steps.list.outputs.charts }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: List changed charts
id: list
env:
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
run: |
ci_changed=$(git diff --name-only "origin/${TARGET_BRANCH}"...HEAD -- .github/actions/test-charts/ .github/workflows/test.yaml ct.yaml ct-install.yaml)
if [[ -n "$ci_changed" ]]; then
echo "CI files changed — testing all charts"
all_charts=true
else
all_charts=false
fi
if [[ "$all_charts" == "true" ]]; then
chart_dirs=$(find charts -mindepth 1 -maxdepth 1 -type d)
else
changed_files=$(git diff --name-only "origin/${TARGET_BRANCH}"...HEAD -- charts/)
if [[ -z "$changed_files" ]]; then
echo "charts=[]" >> "$GITHUB_OUTPUT"
exit 0
fi
chart_dirs=$(echo "$changed_files" | cut -d'/' -f1-2 | sort -u)
fi
excluded=$(yq e '.excluded-charts[]' ct.yaml 2>/dev/null || true)
charts='[]'
while IFS= read -r chart; do
[[ -z "$chart" ]] && continue
[[ ! -d "$chart" ]] && continue
chart_name=$(basename "$chart")
if ! echo "$excluded" | grep -qx "$chart_name"; then
charts=$(echo "$charts" | jq -c --arg c "$chart_name" '. + [$c]')
fi
done <<< "$chart_dirs"
echo "charts=$charts" >> "$GITHUB_OUTPUT"
test-chart:
needs: discover-charts
if: needs.discover-charts.outputs.charts != '[]'
name: Test (${{ matrix.chart }})
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
chart: ${{ fromJson(needs.discover-charts.outputs.charts) }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: Generate full-plugins values for template sanity check
if: matrix.chart == 'backstage'
run: |
yq e '{"global": {"dynamic": {"includes": .global.dynamic.includes}, "lightspeed": {"plugins": .global.lightspeed.plugins}}, "orchestrator": {"plugins": .orchestrator.plugins}}' \
charts/backstage/values.yaml > /tmp/backstage-full-plugins-values.yaml
- name: Test charts
uses: ./.github/actions/test-charts
with:
target_branch: ${{ github.event.pull_request.base.ref }}
chart: charts/${{ matrix.chart }}
monitoring_heartbeat: ${{ vars.TEST_MONITORING_HEARTBEAT_ENABLED || 'false' }}
helm_template_values_file: ${{ matrix.chart == 'backstage' && '/tmp/backstage-full-plugins-values.yaml' || '' }}
# Aligning job name with the OpenShift CI config: https://github.com/openshift/release/blob/master/core-services/prow/02_config/redhat-developer/rhdh-chart/_prowconfig.yaml#L18
status:
name: Test Latest Release
needs: [discover-charts, test-chart]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check test results
run: |
result="${{ needs.test-chart.result }}"
if [[ "$result" != "success" && "$result" != "skipped" ]]; then
echo "Chart tests did not succeed (result: $result)."
exit 1
fi
echo "All chart tests passed (or no charts to test)."