-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (112 loc) · 3.97 KB
/
pr-chart-lint-and-test.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Lint and Test Charts
"on":
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
env:
python_version: '3.10'
jobs:
prep_job:
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.changed-files.outputs.any_changed }}
matrix: ${{ steps.result.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: tj-actions/changed-files@v45
id: changed-files
with:
files: |
**/*.yaml
**/*.yml
**/*.tpl
.github/
files_ignore: |
**/.*md
.github/CODEOWNERS
.github/dependabot.yml
- run: |
echo "Has changes: ${{ steps.changed-files.outputs.any_changed }}"
echo "Changed files: ${{ steps.changed-files.outputs.all_changed_files }}"
{
echo "matrix<<EOF"
echo '{ "include": ['
[[ "${{ steps.changed-files.outputs.any_changed }}" == 'false' ]] && echo '{ "name": "lint" },'
echo '{ "name": "k8s-1.31", "kindest_image": "kindest/node:v1.31.2" },'
echo '{ "name": "k8s-1.30", "kindest_image": "kindest/node:v1.30.6" },'
echo '{ "name": "k8s-1.29", "kindest_image": "kindest/node:v1.29.10" },'
echo '{ "name": "k8s-1.28", "kindest_image": "kindest/node:v1.28.15" },'
echo '{ "name": "k8s-1.27", "kindest_image": "kindest/node:v1.27.16" },'
echo '{ "name": "k8s-1.26", "kindest_image": "kindest/node:v1.26.15" }'
echo '] }'
echo "EOF"
} >> "$GITHUB_OUTPUT"
id: result
test:
runs-on: ubuntu-latest
needs: prep_job
if: ${{ needs.prep_job.outputs.has_changes == 'true' }}
env:
# See https://github.com/kubernetes-sigs/kind/releases
# Check and update the image versions in the prep_job as well when updating this version.
kind_version: v0.25.0
strategy:
matrix: ${{ fromJson(needs.prep_job.outputs.matrix) }}
name: ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: azure/setup-helm@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Set up chart-testing
uses: helm/[email protected]
- name: Lint charts
run: ct lint --config .github/workflows/conf/ct-lint.yml
- uses: helm/kind-action@main
with:
config: .github/workflows/conf/kind.yml
version: ${{ env.kind_version }}
node_image: ${{ matrix.kindest_image }}
- name: Create chart preconditions
run: .github/workflows/scripts/chart-test-prep.sh
- name: Chart installation tests
run: .github/workflows/scripts/chart-test.sh
- name: Debug information on failure
run: kubectl describe nodes; echo "=== API Versions ==="; kubectl api-versions; echo "=== CRDs ==="; kubectl get crd
if: failure()
lint:
runs-on: ubuntu-latest
needs: prep_job
if: ${{ needs.prep_job.outputs.has_changes == 'true' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Run checkov on each test case permutation
run: .github/workflows/scripts/checkov-chart-linting.sh
skip:
runs-on: ubuntu-latest
needs: prep_job
if: ${{ needs.prep_job.outputs.has_changes == 'false' }}
strategy:
matrix: ${{ fromJson(needs.prep_job.outputs.matrix) }}
name: ${{ matrix.name }}
steps:
- run: |
echo "Skip ${{ matrix.name }} for this pull request because no relevant files have been changed."
echo "This is needed to not block the pull request as these are configured as required status check."