Skip to content

Commit 2f2a6b5

Browse files
authored
Merge pull request #2 from Wikodit/wik-webservice/hardening
Wik webservice/hardening
2 parents 5db45ee + 9cfe9c9 commit 2f2a6b5

35 files changed

Lines changed: 1934 additions & 91 deletions

.chglog/config.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
style: github
2+
template: |
3+
## {{ if .PreviousTag }}[{{ .Version }}]({{ .Info.RepositoryURL }}/compare/{{ .PreviousTag }}...{{ .Version }}){{ else }}{{ .Version }}{{ end }} - {{ .Info.Date.Format "2006-01-02" }}
4+
5+
{{ range .Commits -}}
6+
{{- if or (contains .Commit.Header "feat") (contains .Commit.Header "fix") (contains .Commit.Header "docs") }}
7+
{{- if or (contains .Commit.Header "refactor") (contains .Commit.Header "perf") (contains .Commit.Header "test") }}
8+
{{- if or (contains .Commit.Header "build") (contains .Commit.Header "ci") (contains .Commit.Header "chore") }}
9+
* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
10+
{{ end -}}{{ end -}}{{ end -}}
11+
{{ end }}
12+
13+
info:
14+
title: CHANGELOG
15+
repository_url: https://github.com/wikodit/charts
16+
options:
17+
commit_filters:
18+
Type:
19+
- feat
20+
- fix
21+
- docs
22+
- refactor
23+
- perf
24+
- test
25+
- build
26+
- ci
27+
- chore
28+
header:
29+
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?!?: (.*)$"
30+
maps:
31+
- Type: 1
32+
- Scope: 2
33+
- Subject: 3
34+
notes:
35+
keywords:
36+
- BREAKING CHANGE

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
## Checklist
2222

23-
- [ ] Chart version bumped in `Chart.yaml`
23+
- [ ] Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) format
2424
- [ ] `helm lint` passes
2525
- [ ] `helm template` renders correctly
2626
- [ ] Unit tests pass (if applicable)

.github/workflows/lint-test.yaml

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Set up Helm
3636
uses: azure/setup-helm@v4
3737
with:
38-
version: v3.16.3
38+
version: v3.19.4
3939

4040
- name: Set up Python
4141
uses: actions/setup-python@v5
@@ -68,34 +68,56 @@ jobs:
6868
runs-on: ubuntu-latest
6969
needs: lint
7070
if: needs.lint.outputs.changed == 'true'
71+
outputs:
72+
matrix: ${{ steps.set-matrix.outputs.matrix }}
7173
steps:
7274
- name: Checkout
7375
uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
7478

7579
- name: Set up Helm
7680
uses: azure/setup-helm@v4
7781
with:
78-
version: v3.16.3
82+
version: v3.19.4
7983

80-
- name: Cache Helm plugins
81-
uses: actions/cache@v4
82-
with:
83-
path: ~/.local/share/helm/plugins
84-
key: helm-plugins-unittest-${{ runner.os }}
84+
- name: Set up chart-testing
85+
uses: helm/chart-testing-action@v2.7.0
8586

86-
- name: Install helm-unittest plugin
87+
- name: Get changed charts
88+
id: set-matrix
8789
run: |
88-
if ! helm plugin list | grep -q unittest; then
89-
helm plugin install https://github.com/helm-unittest/helm-unittest.git
90+
# Use main as target branch for push events
91+
TARGET_BRANCH="main"
92+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
93+
TARGET_BRANCH="${{ github.base_ref }}"
94+
fi
95+
96+
changed=$(ct list-changed --config ct.yaml --target-branch $TARGET_BRANCH 2>/dev/null || echo "")
97+
if [[ -z "$changed" ]]; then
98+
# Fallback: check git diff
99+
changed=$(git diff --name-only origin/$TARGET_BRANCH HEAD -- charts/ 2>/dev/null | grep -oP 'charts/\K[^/]+' | sort -u || echo "")
90100
fi
91101
102+
if [[ -n "$changed" ]]; then
103+
CHARTS=$(echo "$changed" | jq -R -s -c 'split("\n") | map(select(. != ""))')
104+
else
105+
CHARTS='[]'
106+
fi
107+
108+
echo "matrix={\"chart\":$CHARTS}" >> "$GITHUB_OUTPUT"
109+
110+
- name: Install helm-unittest plugin
111+
run: |
112+
helm plugin install https://github.com/helm-unittest/helm-unittest.git
113+
92114
- name: Run unit tests
93115
run: |
94116
failed=0
95-
for chart in charts/*/; do
96-
if [[ -d "${chart}tests" ]]; then
97-
echo "Testing ${chart}"
98-
if ! helm unittest "${chart}"; then
117+
for chart in ${{ fromJson(needs.lint.outputs.charts) }}; do
118+
if [[ -d "charts/${chart}/tests" ]]; then
119+
echo "Testing charts/${chart}"
120+
if ! helm unittest "charts/${chart}"; then
99121
failed=1
100122
fi
101123
fi
@@ -113,7 +135,7 @@ jobs:
113135
- name: Set up Helm
114136
uses: azure/setup-helm@v4
115137
with:
116-
version: v3.16.3
138+
version: v3.19.4
117139

118140
- name: Install kubeconform
119141
run: |
@@ -123,18 +145,18 @@ jobs:
123145
- name: Validate manifests
124146
run: |
125147
failed=0
126-
for chart in charts/*/; do
127-
chart_name=$(basename "$chart")
128-
echo "Validating ${chart_name}"
148+
for chart in ${{ fromJson(needs.lint.outputs.charts) }}; do
149+
chart_path="charts/${chart}"
150+
echo "Validating ${chart}"
129151
130152
# Use ci values if available, otherwise default
131153
values_file=""
132-
if [[ -f "${chart}ci/default-values.yaml" ]]; then
133-
values_file="-f ${chart}ci/default-values.yaml"
154+
if [[ -f "${chart_path}ci/default-values.yaml" ]]; then
155+
values_file="-f ${chart_path}ci/default-values.yaml"
134156
fi
135157
136-
helm dependency update "$chart" 2>/dev/null || true
137-
if ! helm template "$chart" $values_file | kubeconform -strict -summary -output json; then
158+
helm dependency update "$chart_path" 2>/dev/null || true
159+
if ! helm template "$chart_path" $values_file | kubeconform -strict -summary -output json; then
138160
failed=1
139161
fi
140162
echo "::endgroup::"
@@ -145,6 +167,9 @@ jobs:
145167
runs-on: ubuntu-latest
146168
needs: lint
147169
if: needs.lint.outputs.changed == 'true'
170+
strategy:
171+
fail-fast: false
172+
matrix: ${{ fromJson(needs.lint.outputs.charts) }}
148173
steps:
149174
- name: Checkout
150175
uses: actions/checkout@v4
@@ -153,7 +178,7 @@ jobs:
153178
uses: aquasecurity/trivy-action@0.28.0
154179
with:
155180
scan-type: 'fs'
156-
scan-ref: 'charts/'
181+
scan-ref: 'charts/${{ matrix.chart }}'
157182
scanners: 'misconfig'
158183
format: 'table'
159184
exit-code: '1'
@@ -173,7 +198,7 @@ jobs:
173198
- name: Set up Helm
174199
uses: azure/setup-helm@v4
175200
with:
176-
version: v3.16.3
201+
version: v3.19.4
177202

178203
- name: Set up chart-testing
179204
uses: helm/chart-testing-action@v2.7.0

0 commit comments

Comments
 (0)