-
Notifications
You must be signed in to change notification settings - Fork 3
129 lines (108 loc) · 3.85 KB
/
chart-test.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
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
name: Chart testing
on:
pull_request:
paths: ["charts/**"]
types:
- opened
- edited
- reopened
- synchronize
branches:
- main
permissions:
contents: read
pull-requests: read
jobs:
check-readme:
runs-on: ubuntu-latest
steps:
- name: Install readme-generator-for-helm
run: npm install -g @bitnami/[email protected]
- uses: actions/checkout@v3
name: Checkout Conduktor Charts
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Execute readme-generator-for-helm
env:
GH_TOKEN: ${{ github.token }}
TEMP_FILE: "${{runner.temp}}/pr-${{github.event.number}}.diff"
run: |
export PR_ID=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
gh pr diff ${PR_ID} > $TEMP_FILE
files_changed="$(sed -nr 's/[\-\+]{3} [ab]\/(.*)/\1/p' $TEMP_FILE | sort | uniq)"
# Adding || true to avoid "Process exited with code 1" errors
charts_dirs_changed="$(echo "$files_changed" | xargs dirname | grep -o "charts/[^/]*" | sort | uniq || true)"
for chart in ${charts_dirs_changed}; do
echo "Updating README.md for ${chart}"
readme-generator --values "${chart}/values.yaml" --readme "${chart}/README.md" --schema "/tmp/schema.json"
done
- name: Check diff
run: |
if git status -s | grep -E 'charts/.*/README.md'; then
git diff
echo "::error title=README::README need to be re-generated ! Use bitnami/readme-generator-for-helm to re-generate it."
exit 1
fi
chart-linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout Conduktor Charts
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch history
run: git fetch --prune --unshallow
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (lint)
run: ct lint --config .github/ct-lint-config.yaml
chart-testing:
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch history
run: git fetch --prune --unshallow
- name: Install helm
uses: azure/setup-helm@v3
with:
version: "v3.14.0"
- name: Set up chart-testing
uses: helm/[email protected]
with:
version: 3.11.0
- name: Install K3D
shell: bash
env:
K3D_INSTALL_DIR: ${{ github.workspace }}/.github/.bin
K3D_VERSION: "5.7.3"
run: |
mkdir .github/.bin
export PATH="${{ github.workspace }}/.github/.bin:$PATH"
echo "PATH=${{ github.workspace }}/.github/.bin:$PATH" >> $GITHUB_ENV
echo "Installing k3d"
curl -s https://raw.githubusercontent.com/k3d-io/k3d/v${K3D_VERSION}/install.sh | USE_SUDO="false" bash
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config .github/ct-config.yaml --target-branch main)
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Install helm dependencies
if: steps.list-changed.outputs.changed == 'true'
run: make helm-deps
- name: Create k3d cluster
if: steps.list-changed.outputs.changed == 'true'
run: |
make k3d-ci-up
kubectl create ns ct || true
- name: Run chart-testing (install)
run: ct install --config .github/ct-config.yaml
if: steps.list-changed.outputs.changed == 'true'
- name: Delete k3d cluster
if: always()
run: make k3d-down