Skip to content

Commit eb9e09e

Browse files
authored
Add chart workflows (#1)
1 parent 524cf1b commit eb9e09e

12 files changed

Lines changed: 270 additions & 3 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Lint and Test Charts
2+
3+
on:
4+
push:
5+
paths:
6+
- 'charts/**'
7+
- '.github/**'
8+
workflow_dispatch:
9+
10+
env:
11+
KUBE_SCORE_VERSION: 1.10.0
12+
HELM_VERSION: v3.4.1
13+
14+
jobs:
15+
lint-test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Helm
24+
uses: azure/setup-helm@v1
25+
with:
26+
version: ${{ env.HELM_VERSION }}
27+
28+
- name: Set up kube-score
29+
run: |
30+
wget https://github.com/zegl/kube-score/releases/download/v${{ env.KUBE_SCORE_VERSION }}/kube-score_${{ env.KUBE_SCORE_VERSION }}_linux_amd64 -O kube-score
31+
chmod 755 kube-score
32+
33+
- name: Kube-score generated manifests
34+
run: helm template --values charts/.ci/values-kube-score.yaml charts/* | ./kube-score score -
35+
--ignore-test pod-networkpolicy
36+
--ignore-test deployment-has-poddisruptionbudget
37+
--ignore-test deployment-has-host-podantiaffinity
38+
--ignore-test container-security-context
39+
--ignore-test pod-probes
40+
--ignore-test container-image-tag
41+
--enable-optional-test container-security-context-privileged
42+
--enable-optional-test container-security-context-readonlyrootfilesystem
43+
44+
# python is a requirement for the chart-testing action below (supports yamllint among other tests)
45+
- uses: actions/setup-python@v2
46+
with:
47+
python-version: 3.7
48+
49+
- name: Set up chart-testing
50+
uses: helm/chart-testing-action@v2.0.1
51+
52+
- name: Run chart-testing (list-changed)
53+
id: list-changed
54+
run: |
55+
changed=$(ct list-changed --config charts/.ci/ct-config.yaml)
56+
if [[ -n "$changed" ]]; then
57+
echo "::set-output name=changed::true"
58+
fi
59+
60+
- name: Run chart-testing (lint)
61+
run: ct lint --config charts/.ci/ct-config.yaml
62+
63+
- name: Create kind cluster
64+
uses: helm/kind-action@v1.0.0
65+
if: steps.list-changed.outputs.changed == 'true'
66+
67+
# We need cert-manager already installed in the cluster because we assume the CRDs exist
68+
- name: Install cert-manager
69+
run: helm install cert-manager jetstack/cert-manager --set installCRDs=true --wait
70+
71+
- name: Run chart-testing (install)
72+
run: ct install --config charts/.ci/ct-config.yaml
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Publish helm chart
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main # assume that the branch name may change in future
8+
paths:
9+
- 'charts/**'
10+
- '.github/**'
11+
workflow_dispatch:
12+
13+
env:
14+
KUBE_SCORE_VERSION: 1.10.0
15+
HELM_VERSION: v3.4.1
16+
17+
jobs:
18+
lint-chart:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Helm
27+
uses: azure/setup-helm@v1
28+
with:
29+
version: ${{ env.HELM_VERSION }}
30+
31+
- name: Set up kube-score
32+
run: |
33+
wget https://github.com/zegl/kube-score/releases/download/v${{ env.KUBE_SCORE_VERSION }}/kube-score_${{ env.KUBE_SCORE_VERSION }}_linux_amd64 -O kube-score
34+
chmod 755 kube-score
35+
36+
- name: Kube-score generated manifests
37+
run: helm template --values charts/.ci/values-kube-score.yaml charts/* | ./kube-score score -
38+
--ignore-test pod-networkpolicy
39+
--ignore-test deployment-has-poddisruptionbudget
40+
--ignore-test deployment-has-host-podantiaffinity
41+
--ignore-test container-security-context
42+
--ignore-test pod-probes
43+
--ignore-test container-image-tag
44+
--enable-optional-test container-security-context-privileged
45+
--enable-optional-test container-security-context-readonlyrootfilesystem
46+
47+
# python is a requirement for the chart-testing action below (supports yamllint among other tests)
48+
- uses: actions/setup-python@v2
49+
with:
50+
python-version: 3.7
51+
52+
- name: Set up chart-testing
53+
uses: helm/chart-testing-action@v2.0.1
54+
55+
- name: Run chart-testing (list-changed)
56+
id: list-changed
57+
run: |
58+
changed=$(ct list-changed --config charts/.ci/ct-config.yaml)
59+
if [[ -n "$changed" ]]; then
60+
echo "::set-output name=changed::true"
61+
fi
62+
63+
- name: Run chart-testing (lint)
64+
run: ct lint --config charts/.ci/ct-config.yaml
65+
66+
- name: Create kind cluster
67+
uses: helm/kind-action@v1.0.0
68+
if: steps.list-changed.outputs.changed == 'true'
69+
70+
- name: Run chart-testing (install)
71+
run: ct install --config charts/.ci/ct-config.yaml
72+
73+
publish-chart:
74+
75+
runs-on: ubuntu-latest
76+
needs: lint-chart
77+
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v2
81+
with:
82+
fetch-depth: 0
83+
84+
- name: Configure Git
85+
run: |
86+
git config user.name "$GITHUB_ACTOR"
87+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
88+
89+
- name: Install Helm
90+
uses: azure/setup-helm@v1
91+
with:
92+
version: ${{ env.HELM_VERSION }}
93+
94+
# We need cert-manager already installed in the cluster because we assume the CRDs exist
95+
- name: Install cert-manager
96+
run: helm install cert-manager jetstack/cert-manager --set installCRDs=true --wait
97+
98+
- name: Run chart-releaser
99+
uses: helm/chart-releaser-action@v1.1.0
100+
env:
101+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
102+

charts/.ci/ct-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file defines the config for "ct" (chart tester) used by the helm linting GitHub workflow
2+
lint-conf: charts/.ci/lint-config.yaml
3+
chart-repos:
4+
- jetstack=https://charts.jetstack.io

charts/.ci/lint-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rules:
2+
# One blank line is OK
3+
empty-lines:
4+
max-start: 1
5+
max-end: 1
6+
max: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker run --rm -it -w /repo -v $(pwd):/repo quay.io/helmpack/chart-testing ct lint --all --config charts/.ci/ct-config.yaml
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
4+
for chart in `ls charts`;
5+
do
6+
helm template --values charts/$chart/ci/ci-values.yaml charts/$chart | kube-score score - \
7+
--ignore-test pod-networkpolicy \
8+
--ignore-test deployment-has-poddisruptionbudget \
9+
--ignore-test deployment-has-host-podantiaffinity \
10+
--ignore-test pod-probes \
11+
--ignore-test container-image-tag \
12+
--enable-optional-test container-security-context-privileged \
13+
--enable-optional-test container-security-context-readonlyrootfilesystem \
14+
--ignore-test container-security-context
15+
done

charts/actions-runner-controller/Chart.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.0
18+
version: 0.1.1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
23-
appVersion: 0.11.2
23+
appVersion: 0.16.0
24+
25+
home: https://github.com/summerwind/actions-runner-controller
26+
27+
sources:
28+
- https://github.com/summerwind/actions-runner-controller
29+
30+
maintainers:
31+
- name: summerwind
32+
email: contact@summerwind.jp
33+
url: https://github.com/summerwind
34+
- name: funkypenguin
35+
email: davidy@funkypenguin.co.nz
36+
url: https://www.funkypenguin.co.nz
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file sets some opinionated values for kube-score to use
2+
# when parsing the chart
3+
image:
4+
pullPolicy: Always
5+
6+
podSecurityContext:
7+
fsGroup: 2000
8+
9+
securityContext:
10+
capabilities:
11+
drop:
12+
- ALL
13+
readOnlyRootFilesystem: true
14+
runAsNonRoot: true
15+
runAsUser: 2000
16+
17+
resources:
18+
limits:
19+
cpu: 100m
20+
memory: 128Mi
21+
requests:
22+
cpu: 100m
23+
memory: 128Mi
24+
25+
# Set the following to true to create a dummy secret, allowing the manager pod to start
26+
# This is only useful in CI
27+
createDummySecret: true

charts/actions-runner-controller/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Create the name of the service account to use
8989
{{- end }}
9090

9191
{{- define "actions-runner-controller.authProxyServiceName" -}}
92-
{{- include "actions-runner-controller.fullname" . }}-controller-manager-metrics-service
92+
{{- include "actions-runner-controller.fullname" . }}-metrics-service
9393
{{- end }}
9494

9595
{{- define "actions-runner-controller.selfsignedIssuerName" -}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This template only exists to facilitate CI testing of the chart, since
2+
# a secret is expected to be found in the namespace by the controller manager
3+
{{ if .Values.createDummySecret -}}
4+
apiVersion: v1
5+
data:
6+
github_token: dGVzdA==
7+
kind: Secret
8+
metadata:
9+
name: controller-manager
10+
{{- end }}

0 commit comments

Comments
 (0)