Skip to content

Commit

Permalink
Adapt release pipeline for single chart releases and publish on GitHub (
Browse files Browse the repository at this point in the history
  • Loading branch information
edmondop authored Aug 11, 2023
1 parent 4086a64 commit 8b3faac
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 156 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/check-chart-migration.yaml

This file was deleted.

132 changes: 24 additions & 108 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,123 +1,39 @@
name: Helm chart

name: Helm Continuous Integration
on:
push:
branches:
- master
tags:
- "**/[0-9]+.[0-9]+.[0-9]+"
- "**/[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"
branches: "main"
pull_request:

env:
HELM_PLUGIN_CHARTMUSEUM_PUSH_VERSION: 0.9.0
HELM_PUSH_REPOSITORY_NAME: chartmuseum
HELM_VERSION: 3.1.1
HELM_VERSION: 3.12.1
PYTHON_VERSION: 3.11

jobs:
helm:
name: Helm
runs-on: ubuntu-latest

name: Chart Linting
runs-on: ubuntu-22.04
steps:
- name: Check out code
- name: Checkout
uses: actions/checkout@v2

- uses: azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}

- name: Add Helm repositories
run: |
helm repo add incubator https://charts.helm.sh/incubator
helm repo add chartmuseum https://kubernetes-charts.banzaicloud.com
helm repo add banzaicloud-stable http://kubernetes-charts.banzaicloud.com/branch/master
helm repo add rimusz https://charts.rimusz.net
- name: Update Helm repositories
run: |
helm repo update
helm repo list
- name: Update Helm dependencies
run: |
find -H '.' \
-maxdepth 2 \
-name 'Chart.yaml' \
-execdir helm dependency update \;
- name: Lint Helm charts
run: |
find -H '.' \
-maxdepth 2 \
-name 'Chart.yaml' \
-printf '%h\n' \
| xargs helm lint
- name: Set Git refname
id: set-git-refname
run: |
GIT_REFNAME="$(echo "${{ github.ref }}" | sed -r 's@refs/(heads|pull|tags)/@@g')"
echo "GIT_REFNAME=${GIT_REFNAME}"
echo "git_refname=${GIT_REFNAME}" >> $GITHUB_OUTPUT
- name: Set Helm push enabled
id: set-helm-push-enabled
run: |
HELM_PUSH_ENABLED=""
if [ "${{ github.event_name }}" == "push" ] && echo "${{ steps.set-git-refname.outputs.git_refname }}" | grep -E -q "^(chart/)?[^/]+/[0-9]+\.[0-9]+\.[0-9]+"; then
HELM_PUSH_ENABLED=1
else
printf >&2 "Unstable chart (%s) from %s event, chart will not be pushed" "${{ steps.set-git-refname.outputs.git_refname }}" "${{ github.event_name }}"
fi
fetch-depth: 0

echo "HELM_PUSH_ENABLED=${HELM_PUSH_ENABLED}"
echo "helm_push_enabled=${HELM_PUSH_ENABLED}" >> $GITHUB_OUTPUT
- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Set chart name
id: set-chart-name
run: |
CHART_NAME="$(echo "${{ steps.set-git-refname.outputs.git_refname }}}" | awk -F '/' '{print $(NF-1)}')"
echo "CHART_NAME=${CHART_NAME}"
echo "chart_name=${CHART_NAME}" >> $GITHUB_OUTPUT
- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Package Helm chart
id: package-chart
run: |
HELM_PACKAGE_OUTPUT=$(helm package "${{ github.workspace }}/${{ steps.set-chart-name.outputs.chart_name }}") || exit 1
HELM_PACKAGE_PATH="${HELM_PACKAGE_OUTPUT##"Successfully packaged chart and saved it to: "}"
echo "HELM_PACKAGE_PATH=${HELM_PACKAGE_PATH}"
echo "helm_package_path=${HELM_PACKAGE_PATH}" >> $GITHUB_OUTPUT
- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Check Helm chart version in repository
run: |
CHART_PATH="${{ github.workspace }}/${{ steps.set-chart-name.outputs.chart_name }}"
EXPECTED_CHART_VERSION="$(echo "${{ steps.set-git-refname.outputs.git_refname }}" | awk -F '/' '{print $NF}')" || exit 1
ACTUAL_CHART_VERSION="$(awk '/version: [0-9]+\.[0-9]+\.[0-9]+/ {print $2}' "${CHART_PATH}/Chart.yaml")" || exit 1
if [ "${EXPECTED_CHART_VERSION}" != "${ACTUAL_CHART_VERSION}" ]; then
printf >&2 "chart version mismatches, name: %s, expected version (from tag): %s, actual version (from chart): %s" "${{ steps.set-chart-name.outputs.chart_name }}" "${EXPECTED_CHART_VERSION}" "${ACTUAL_CHART_VERSION}"
exit 1
fi
- name: Set up Helm
uses: azure/[email protected]
with:
version: ${{ env.HELM_VERSION }}

if helm search repo "${{ env.HELM_PUSH_REPOSITORY_NAME }}/${{ steps.set-chart-name.outputs.chart_name }}" --version "${ACTUAL_CHART_VERSION}" --output json | jq --exit-status 'length > 0'; then
printf >&2 "chart version already exists in the repository, repository: %s, name: %s, version: %s" "${{ env.HELM_PUSH_REPOSITORY_NAME }}" "${{ steps.set-chart-name.outputs.chart_name }}" "${ACTUAL_CHART_VERSION}"
exit 1
fi
# Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and
# yamllint (https://github.com/adrienverge/yamllint) which require Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Install Helm ChartMuseum push plugin
run: helm plugin install "https://github.com/chartmuseum/helm-push.git" --version "${{ env.HELM_PLUGIN_CHARTMUSEUM_PUSH_VERSION }}"
- name: Set up chart-testing
uses: helm/[email protected]
with:
version: v3.9.0

- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Push Helm chart
env:
HELM_REPO_PASSWORD: ${{ secrets.HELM_REPO_PASSWORD }}
HELM_REPO_USERNAME: ${{ secrets.HELM_REPO_USERNAME }}
run: helm push "${{ steps.package-chart.outputs.helm_package_path }}" "${{ env.HELM_PUSH_REPOSITORY_NAME }}"
- name: Lint chart
run: ct lint --all --config ct.yaml
63 changes: 63 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Helm Release

on:
push:
tags:
- "**/[0-9]+.[0-9]+.[0-9]+"
- "**/[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"


env:
HELM_VERSION: 3.1.1

jobs:
helm:
name: Publish to Github Pages
runs-on: ubuntu-22.04
permissions:
contents: write

steps:
- name: Check out code
uses: actions/checkout@v2

- uses: azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set Git refname
id: set-git-refname
run: |
GIT_REFNAME="$(echo "${{ github.ref }}" | sed -r 's@refs/(heads|pull|tags)/@@g')"
echo "GIT_REFNAME=${GIT_REFNAME}"
echo ::set-output name=git_refname::${GIT_REFNAME}
- name: Check Git Tag consistency with Chart version
run: |
EXPECTED_CHART_VERSION="$(echo "${{ steps.set-git-refname.outputs.git_refname }}" | awk -F '/' '{print $NF}')" || exit 1
ACTUAL_CHART_VERSION="$(awk '/version: [0-9]+\.[0-9]+\.[0-9]+/ {print $2}' "./charts/cadence/Chart.yaml")" || exit 1
if [ "${EXPECTED_CHART_VERSION}" != "${ACTUAL_CHART_VERSION}" ]; then
printf >&2 "chart version mismatches, expected version (from tag): %s, actual version (from chart): %s" "${EXPECTED_CHART_VERSION}" "${ACTUAL_CHART_VERSION}"
exit 1
fi
- name: Checkout forked chart-releaser
uses: actions/checkout@v3
with:
repository: edmondop/chart-releaser-action
path: chart-releaser-action
ref: ef58c21b3f93daff872ba384abd9cdb16e715334

- name: Run chart-releaser
uses: ./chart-releaser-action
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

[Cadence](https://cadenceworkflow.io/) is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.

## Important information

BanzaiCloud is not maintaining anymore the Helm Chart for Cadence, so if you have been using the Cadence Helm Chart for some time you might need to change few things from now on. A special thanks to their team for the great work.

## TL;DR;

The new release process allows anybody to quickly publish the chart on GitHub repo, using `chart-releaser-action` GitHub action that creates public Helm Chart Repo. If your repo is not hosted under user `edmondop`, please replace the right username

```bash
$ helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
$ helm repo add cadence https://edmondop.github.io/cadence-helm-chart/
$ helm repo update
```

Expand All @@ -27,7 +32,7 @@ This chart bootstraps a [Cadence](https://github.com/uber/cadence) and a [Cadenc
To install the chart with the release name `my-release`:

```bash
$ helm install --name my-release --namespace cadence banzaicloud-stable/cadence
$ helm install --name my-release --namespace cadence cadence/cadence
```

> **Tip**: List all releases using `helm list`
Expand All @@ -37,7 +42,7 @@ $ helm install --name my-release --namespace cadence banzaicloud-stable/cadence

```console
# Helm
$ helm upgrade [RELEASE_NAME] banzaicloud-stable/cadence
$ helm upgrade [RELEASE_NAME] cadence/cadence
```

### From 0.20.x (or below) to 0.21.y (or above)
Expand Down Expand Up @@ -133,13 +138,13 @@ The command removes all the Kubernetes components associated with the chart and
The chart comes with a single node Cassandra by default (from [incubator/cassandra](https://github.com/helm/charts/tree/master/incubator/cassandra)).

```bash
$ helm install banzaicloud-stable/cadence
$ helm install cadence/cadence
```

You can increase the number of Cassandra nodes if you want:

```bash
$ helm install --set cassandra.config.cluster_size=3 banzaicloud-stable/cadence
$ helm install --set cassandra.config.cluster_size=3 cadence/cadence
```

> **Note:** It takes a few minutes to start Cassandra. You can speed it up by using configuration from `values.dev.yaml`.
Expand Down Expand Up @@ -175,13 +180,13 @@ $ kubectl exec -it cassandra-0 -- cqlsh -e "CREATE KEYSPACE cadence_visibility W
```

```bash
$ helm install -f values/values.cassandra.yaml banzaicloud-stable/cadence
$ helm install -f values/values.cassandra.yaml cadence/cadence
```

Alternatively, install the chart with manual migrations. Follow the steps in [migrations.md](migrations.md).

```bash
$ helm install -f values/values.cassandra.yaml --set schema.setup.enabled=false --set schema.update.enabled=false banzaicloud-stable/cadence
$ helm install -f values/values.cassandra.yaml --set schema.setup.enabled=false --set schema.update.enabled=false cadence/cadence
```


Expand All @@ -192,7 +197,7 @@ $ helm install -f values/values.cassandra.yaml --set schema.setup.enabled=false
The chart can be installed with a single node MySQL (from [stable/mysql](https://github.com/helm/charts/tree/master/stable/mysql)).

```bash
$ helm install --set cassandra.enabled=false --set mysql.enabled=true --set mysql.mysqlPassword=cadence banzaicloud-stable/cadence
$ helm install --set cassandra.enabled=false --set mysql.enabled=true --set mysql.mysqlPassword=cadence cadence/cadence
```

> **Note:** When installing MySQL from within the chart with automatic migrations, you **must** configure a password.
Expand Down Expand Up @@ -222,13 +227,13 @@ $ kubectl wait --for=condition=Ready pod/$(kubectl get pods -l 'app=mysql' -o js
```

```bash
$ helm install -f values/values.mysql.yaml banzaicloud-stable/cadence
$ helm install -f values/values.mysql.yaml cadence/cadence
```

Alternatively, install the chart with manual migrations. Follow the steps in [migrations.md](migrations.md).

```bash
$ helm install -f values/values.mysql.yaml --set schema.setup.enabled=false --set schema.update.enabled=false banzaicloud-stable/cadence
$ helm install -f values/values.mysql.yaml --set schema.setup.enabled=false --set schema.update.enabled=false cadence/cadence
```


Expand All @@ -238,13 +243,13 @@ As of 0.5.8 Cadence exports Prometheus metrics. The chart supports annotating Ca
so that Prometheus can scrape them:

```bash
$ helm install --set server.metrics.annotations.enabled=true banzaicloud-stable/cadence
$ helm install --set server.metrics.annotations.enabled=true cadence/cadence
```

Alternatively, you can enable ServiceMonitor when using [Prometheus Operator](https://github.com/coreos/prometheus-operator):

```bash
$ helm install --set server.metrics.serviceMonitor.enabled=true banzaicloud-stable/cadence
$ helm install --set server.metrics.serviceMonitor.enabled=true cadence/cadence
```

Note that you can enable monitoring for each service separately. See the configuration reference bellow.
Expand Down Expand Up @@ -279,7 +284,7 @@ The reason behind this limitation is that migrations are executed as helm hooks,

## Port forwarding to Cadence frontend

As of version 0.5.1 of this chart service (frontend, history, matching, worker) pods use the [pod IP as bind address](https://github.com/banzaicloud/banzai-charts/pull/997).
As of version 0.5.1 of this chart service (frontend, history, matching, worker) pods use the [pod IP as bind address](https://github.com/cadence/banzai-charts/pull/997).

This is a limitation of how Cadence cluster membership works and is required for scaling Cadence components.

Expand Down Expand Up @@ -393,18 +398,22 @@ Global options overridable per service are marked with an asterisk.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example:

```bash
$ helm install --name my-release --set server.image.tag=0.7.1 banzaicloud-stable/cadence
$ helm install --name my-release --set server.image.tag=0.7.1 cadence/cadence
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while
installing the chart. For example:

```bash
$ helm install --name my-release --values values.yaml banzaicloud-stable/cadence
$ helm install --name my-release --values values.yaml cadence/cadence
```

## Contributing

### New release process.
The new release process use GitHub Pages as an Helm Chart Repository. In order to test the release, set up GitHub Pages for your fork. This will allow you to see how your changes affect the final outcome. Please create a branch named `gh-pages` and enabled on your repository GitHub Pages from that branch. If you need more information, please consult the [Chart Releaser Action Documentation](https://github.com/helm/chart-releaser-action)


### Chart upgrade

For contributions involving an upgrade to the Cadence server version or
Expand Down
Loading

0 comments on commit 8b3faac

Please sign in to comment.