Skip to content

Commit c8d2e3f

Browse files
Feat: Initial implementation of chart with argo workflows init hook (#1)
1 parent 123d3e1 commit c8d2e3f

19 files changed

+551
-18
lines changed

.github/configs/cr.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Reference: https://github.com/helm/chart-releaser
2+
index-path: "./index.yaml"
3+
4+
# PGP signing
5+
sign: true
6+
key: garage-cf
7+
# keyring: # Set via env variable CR_KEYRING
8+
# passphrase-file: # Set via env variable CR_PASSPHRASE_FILE
9+
10+
# Enable automatic generation of release notes using GitHubs release notes generator.
11+
# see: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
12+
generate-release-notes: true

.github/configs/ct-install.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Reference: https://github.com/helm/chart-testing/blob/master/doc/ct_lint-and-install.md
2+
# Don't add the 'debug' attribute, otherwise the workflow won't work anymore
3+
# Only Used for the CT Install Stage
4+
remote: origin
5+
charts:
6+
- script/helm/garage
7+
helm-extra-args: "--timeout 600s"
8+
validate-chart-schema: false
9+
validate-maintainers: true
10+
validate-yaml: true
11+
exclude-deprecated: true
12+
excluded-charts: []

.github/configs/ct-lint.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Reference: https://github.com/helm/chart-testing/blob/master/doc/ct_lint-and-install.md
2+
# Don't add the 'debug' attribute, otherwise the workflow won't work anymore
3+
# Only Used for the CT Lint Stage
4+
remote: origin
5+
charts:
6+
- script/helm/garage
7+
validate-chart-schema: false
8+
validate-maintainers: false
9+
validate-yaml: true
10+
exclude-deprecated: true
11+
excluded-charts: []

.github/configs/kind-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane
5+
- role: worker
6+
- role: worker
7+
- role: worker

.github/configs/lintconf.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
rules:
3+
braces:
4+
min-spaces-inside: 0
5+
max-spaces-inside: 0
6+
min-spaces-inside-empty: -1
7+
max-spaces-inside-empty: -1
8+
brackets:
9+
min-spaces-inside: 0
10+
max-spaces-inside: 0
11+
min-spaces-inside-empty: -1
12+
max-spaces-inside-empty: -1
13+
colons:
14+
max-spaces-before: 0
15+
max-spaces-after: 1
16+
commas:
17+
max-spaces-before: 0
18+
min-spaces-after: 1
19+
max-spaces-after: 1
20+
comments:
21+
require-starting-space: true
22+
min-spaces-from-content: 1
23+
document-end: disable
24+
document-start: disable # No --- to start a file
25+
empty-lines:
26+
max: 2
27+
max-start: 0
28+
max-end: 0
29+
hyphens:
30+
max-spaces-after: 1
31+
indentation:
32+
spaces: consistent
33+
indent-sequences: whatever # - list indentation will handle both indentation and without
34+
check-multi-line-strings: false
35+
key-duplicates: enable
36+
line-length: disable # Lines can be any length
37+
new-line-at-end-of-file: enable
38+
new-lines:
39+
type: unix
40+
trailing-spaces: enable
41+
truthy:
42+
level: warning
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Reference: https://github.com/helm/chart-testing-action
2+
name: Linting and Testing
3+
on:
4+
pull_request:
5+
branches:
6+
- 'codefresh-main'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
chart-test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Helm
21+
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
22+
with:
23+
version: v3.10.1 # Also update in publish.yaml
24+
25+
- name: Set up python
26+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
27+
with:
28+
python-version: 3.9
29+
30+
- name: Setup Chart Linting
31+
id: lint
32+
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
33+
with:
34+
# Note: Also update in scripts/lint.sh
35+
version: v3.10.0
36+
37+
- name: Run chart-testing (lint)
38+
run: ct lint --debug --config ./.github/configs/ct-lint.yaml --target-branch ${{ github.base_ref }} --lint-conf ./.github/configs/lintconf.yaml
39+
40+
- name: Run docs-testing (helm-docs)
41+
id: helm-docs
42+
run: |
43+
./script/helm-docs.sh
44+
if [[ $(git diff --stat) != '' ]]; then
45+
echo -e '\033[0;31mDocumentation outdated!\033[0m ❌'
46+
git diff --color
47+
exit 1
48+
else
49+
echo -e '\033[0;32mDocumentation up to date\033[0m ✔'
50+
fi
51+
52+
- name: Create kind cluster
53+
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
54+
with:
55+
config: .github/configs/kind-config.yaml
56+
57+
- name: Run chart-testing (install)
58+
run: ct install --config ./.github/configs/ct-install.yaml --target-branch ${{ github.base_ref }}

.github/workflows/publish.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
## Reference: https://github.com/helm/chart-releaser-action
2+
name: Chart Publish
3+
on:
4+
push:
5+
branches:
6+
- codefresh-main
7+
paths:
8+
- "script/helm/garage/**"
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
publish:
15+
permissions:
16+
contents: write # for helm/chart-releaser-action to push chart release and create a release
17+
packages: write # to push OCI chart package to GitHub Registry
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Install Helm
26+
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
27+
with:
28+
version: v3.10.1 # Also update in lint-and-test.yaml
29+
30+
- name: Configure Git
31+
run: |
32+
git config user.name "$GITHUB_ACTOR"
33+
git config user.email "[email protected]"
34+
35+
- name: Package chart
36+
run: |
37+
rm -rf .cr-release-packages
38+
mkdir .cr-release-packages
39+
helm package script/helm/garage -u -d .cr-release-packages/
40+
41+
# The GitHub repository secret `PGP_PRIVATE_KEY` contains the private key
42+
# in ASCII-armored format. To export a (new) key, run this command:
43+
# `gpg --armor --export-secret-key <my key>`
44+
- name: Prepare PGP key
45+
run: |
46+
IFS=""
47+
echo "$PGP_PRIVATE_KEY" | gpg --dearmor > $HOME/secring.gpg
48+
echo "$PGP_PASSPHRASE" > $HOME/passphrase.txt
49+
50+
# Tell chart-releaser-action where to find the key and its passphrase
51+
echo "CR_KEYRING=$HOME/secring.gpg" >> "$GITHUB_ENV"
52+
echo "CR_PASSPHRASE_FILE=$HOME/passphrase.txt" >> "$GITHUB_ENV"
53+
env:
54+
PGP_PRIVATE_KEY: "${{ secrets.PGP_PRIVATE_KEY }}"
55+
PGP_PASSPHRASE: "${{ secrets.PGP_PASSPHRASE }}"
56+
57+
- name: Run chart-releaser
58+
uses: helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968 # v1.5.0 - currently there is a bug on 1.6.0 version, can upgrade back when it'll be solved - https://github.com/helm/chart-releaser-action/issues/171
59+
with:
60+
config: "./.github/configs/cr.yaml"
61+
skip_packaging: true
62+
charts_dir: script/helm
63+
env:
64+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
65+
66+
- name: Login to GHCR
67+
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
68+
with:
69+
registry: ghcr.io
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- name: Push chart to GHCR
74+
run: |
75+
shopt -s nullglob
76+
for pkg in .cr-release-packages/*.tgz; do
77+
if [ -z "${pkg:-}" ]; then
78+
break
79+
fi
80+
helm push "${pkg}" oci://ghcr.io/${{ github.repository }}
81+
done

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/pki
44
**/*.rs.bk
55
*.swp
6-
/.direnv
6+
/.direnv
7+
values-dev.yaml

script/helm-docs.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
## Reference: https://github.com/norwoodj/helm-docs
3+
set -eux
4+
CHART_DIR="$(cd "$(dirname "$0")/helm/garage" && pwd)"
5+
echo "$CHART_DIR"
6+
7+
echo "Running Helm-Docs"
8+
docker run \
9+
-v "$CHART_DIR:/helm-docs" \
10+
-u $(id -u) \
11+
--rm \
12+
jnorwood/helm-docs:v1.9.1

script/helm-lint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# This script runs the chart-testing tool locally. It simulates the linting that is also done by the github action. Run this without any errors before pushing.
3+
# Reference: https://github.com/helm/chart-testing
4+
set -eux
5+
6+
SRCROOT="$(cd "$(dirname "$0")/.." && pwd)"
7+
echo $SRCROOT
8+
echo -e "\n-- Linting all Helm Charts --\n"
9+
docker run \
10+
-v "$SRCROOT:/workdir" \
11+
--entrypoint /bin/sh \
12+
quay.io/helmpack/chart-testing:v3.10.0 \
13+
-c cd /workdir \
14+
ct lint \
15+
--config .github/configs/ct-lint.yaml \
16+
--lint-conf .github/configs/lintconf.yaml \
17+
--debug

0 commit comments

Comments
 (0)