Skip to content

Commit

Permalink
Merge pull request #705 from k8up-io/helm-repo
Browse files Browse the repository at this point in the history
Integrate K8up Helm chart
  • Loading branch information
ccremer authored Jul 15, 2022
2 parents 5501055 + ed8bb57 commit 45a068b
Show file tree
Hide file tree
Showing 57 changed files with 2,942 additions and 52 deletions.
41 changes: 26 additions & 15 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
## Summary

* Short summary of what's included in the PR
* Give special note to breaking changes: List the exact changes or provide links to documentation.

## Checklist

<!--
Thank you for your pull request. Please provide a description above and
review the checklist below.
-->
### For Code changes

## Checklist
<!--
Remove items that do not apply. For completed items, change [ ] to [x].
-->
- [ ] Categorize the PR by setting a good title and adding one of the labels:
`bug`, `enhancement`, `documentation`, `change`, `breaking`, `dependency`
as they show up in the changelog
- [ ] PR contains the label `area:operator`
- [ ] Link this PR to related issues
- [ ] I have not made _any_ changes in the `charts/` directory.

### For Helm Chart changes

- [ ] Keep pull requests small so they can be easily reviewed.
- [ ] Categorize the PR by setting a good title and adding one of the labels:
`bug`, `enhancement`, `documentation`, `change`, `breaking`,
as they show up in the changelog
- [ ] Update the documentation.
- [ ] Update tests.
- [ ] Link this PR to related issues.
`bug`, `enhancement`, `documentation`, `change`, `breaking`, `dependency`
as they show up in the changelog
- [ ] PR contains the label `area:chart`
- [ ] PR contains the chart label, e.g. `chart:appcat-service-s3`
- [ ] Variables are documented in the values.yaml using the format required by [Helm-Docs](https://github.com/norwoodj/helm-docs#valuesyaml-metadata).
- [ ] Chart Version bumped if immediate release after merging is planned
- [ ] I have run `make chart-docs`
- [ ] Link this PR to related code release or other issues.

<!--
NOTE: these things are not required to open a PR and can be done afterwards,
NOTE:
Do *not* mix code changes with chart changes, it will break the release process.
Delete the checklist section that doesn't apply to the change.
NOTE:
These things are not required to open a PR and can be done afterwards,
while the PR is open.
-->
Empty file added .github/boilerplate.go.txt
Empty file.
54 changes: 54 additions & 0 deletions .github/changelog-charts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"pr_template": "- ${{TITLE}} (#${{NUMBER}})",
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"enhancement",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🛠️ Minor Changes",
"labels": [
"change",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🔎 Breaking Changes",
"labels": [
"breaking",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🐛 Fixes",
"labels": [
"bug",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 📄 Documentation",
"labels": [
"documentation",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🔗 Dependency Updates",
"labels": [
"dependency",
"area:chart"
],
"exhaustive": true
}
],
"template": "This release contains _only_ Helm chart changes\n\n${{CATEGORIZED_COUNT}} changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}"
}
13 changes: 13 additions & 0 deletions .github/changelog-charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -eo pipefail

chart="${1}"

tagPattern="${chart}-(.+)"
chartLabel="chart:${chart}"

echo ::group::Configuring changelog generator
jq '.tag_resolver.filter.pattern="'$tagPattern'" | .tag_resolver.transformer.pattern="'$tagPattern'" | .categories[].labels += ["'$chartLabel'"]' \
.github/changelog-charts.json | tee .github/configuration.json
echo ::endgroup::
10 changes: 10 additions & 0 deletions .github/helm-docs-footer.gotmpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}

<!---
Common/Useful Link references from values.yaml
-->
[resource-units]: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes
[prometheus-operator]: https://github.com/coreos/prometheus-operator
15 changes: 15 additions & 0 deletions .github/helm-docs-header.gotmpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

{{ template "chart.badgesSection" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

## Installation

```bash
helm repo add k8up-io https://k8up-io.github.io/k8up
helm install {{ template "chart.name" . }} k8up-io/{{ template "chart.name" . }}
```
10 changes: 10 additions & 0 deletions .github/render-charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -eo pipefail

chartYaml="${1}"
chartName=$(dirname "${chartYaml}")

echo "::group::Render chart ${chartName}"
helm template "${chartName}"
echo "::endgroup::"
36 changes: 36 additions & 0 deletions .github/workflows/chart-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ChartLint

on:
pull_request:
# only run when there are chart changes
paths:
- 'charts/**'
- '!charts/charts.mk'
- '!charts/go*'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'

- uses: actions/setup-go@v3

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify charts are upt-do-date
run: make chart-lint

template:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Render Helm charts
run: find charts -type f -name Chart.yaml -exec .github/render-charts.sh {} \;
81 changes: 81 additions & 0 deletions .github/workflows/chart-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: ChartRelease

on:
push:
tags:
- "[a-z]+-*" # match tags following the 'chart-name-x.y.z'

jobs:
# Currently this job with changelog generator only works for the k8up chart...
# More charts (e.g. forks) may need additional engineering to get the changelog right.
gh-pages:
runs-on: ubuntu-latest
steps:
- name: Download cr
uses: giantswarm/[email protected]
with:
binary: cr
version: "1.4.0"
download_url: https://github.com/helm/chart-releaser/releases/download/v${version}/chart-releaser_${version}_linux_amd64.tar.gz
tarball_binary_path: "${binary}"
smoke_test: "${binary} version"

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'

- uses: actions/setup-go@v3

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Get chart name
run: echo "CHART_NAME=$(echo ${GITHUB_REF##*/} | grep --perl-regexp --only-matching '^([a-zA-Z0-9-]+)(?![0-9.]+)')" >> $GITHUB_ENV

- name: Get chart versions
run: |
echo "CHART_VERSION=$(yq e '.version' charts/${CHART_NAME}/Chart.yaml)" >> $GITHUB_ENV
echo "PREVIOUS_CHART_VERSION=$(git tag --sort=taggerdate --list "k8up-*" | tail -n 2 | head -n 1 | rev | cut -d - -f 1 | rev)" >> $GITHUB_ENV
- name: Prepare changelog config
run: .github/changelog-charts.sh ${CHART_NAME}

- name: Generate additional artifacts
run: make chart-prepare

- name: Package Helm chart
run: |
mkdir -p .cr-index
cr package charts/${CHART_NAME}
cr upload
cr index --push
env:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CR_OWNER: ${{ github.repository_owner }}
CR_GIT_REPO: ${{ github.event.repository.name }}

- name: Build changelog from PRs with labels
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3
with:
configuration: ".github/configuration.json"
ignorePreReleases: true
outputFile: .github/release-notes.md
fromTag: ${{ env.CHART_NAME }}-${{ env.PREVIOUS_CHART_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# there doesn't seem to be any maintained GitHub actions that allow uploading assets after release has been made.
- name: Update release
run: |
gh release upload ${CHART_NAME}-${CHART_VERSION} .github/crds.yaml
gh release edit ${CHART_NAME}-${CHART_VERSION} --notes-file .github/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ChartTest

on:
pull_request:
# only run when there are chart changes
paths:
- 'charts/**'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'

- uses: actions/setup-go@v3

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run chart tests
run: make chart-test
14 changes: 11 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ name: Docs

on:
push:
branches:
- master
tags:
- "*"
- "v*"
paths-ignore:
- charts/**

jobs:
antora:
Expand All @@ -17,6 +21,7 @@ jobs:
run: |
git config user.name "Antora via GitHub Actions"
git config user.email "[email protected]"
- name: Parse semver string
id: semver
uses: booxmedialtd/ws-action-parse-semver@v1
Expand All @@ -42,10 +47,13 @@ jobs:
continue-on-error: true

- name: Patch Antora file for Release
run: yq eval 'del(.prerelease) | del (.display_version) | .version = "${{ env.MINOR_VERSION }}"' -i docs/antora.yml
run: |
yq eval 'del(.prerelease) | del (.display_version) | .version = "${{ env.MINOR_VERSION }}" | .asciidoc.attributes.releaseVersion = "v${{ steps.semver.outputs.fullversion }}"' -i docs/antora.yml
if: ${{ steps.semver.outputs.prerelease == '' }}
- name: Patch Antora file for Prerelease
run: yq eval 'del (.display_version) | .version = "${{ env.MINOR_VERSION }}", .prerelease = "-${{ steps.semver.outputs.prerelease }}"' -i docs/antora.yml
run: |
yq eval 'del (.display_version) | .version = "${{ env.MINOR_VERSION }}" | .prerelease = "-${{ steps.semver.outputs.prerelease }}" | .asciidoc.attributes.releaseVersion = "v${{ steps.semver.outputs.fullversion }}"' -i docs/antora.yml
cat docs/antora.yml
if: ${{ steps.semver.outputs.prerelease != '' }}

- name: Commit
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,29 @@ jobs:
- kind-node-version: v1.18.19
steps:
- uses: actions/checkout@v3

- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
run: echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: azure/setup-kubectl@v3
with:
version: ${{ matrix.kind-node-version }}
id: install

- name: Run e2e tests
run: make crd e2e-test -e KIND_NODE_VERSION=${{ matrix.kind-node-version }} -e KIND_KUBECTL_ARGS=--validate=false -e bats_args="--report-formatter junit"

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure()
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
run: echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run linters
run: make lint
Loading

0 comments on commit 45a068b

Please sign in to comment.