Skip to content

Commit

Permalink
ci(test): add upgrade strategy matrix for helm tests
Browse files Browse the repository at this point in the history
Signed-off-by: Thuan Vo <[email protected]>
  • Loading branch information
tthvo committed Sep 23, 2024
1 parent 27de094 commit 05c7844
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
15 changes: 15 additions & 0 deletions .github/helm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# A wrapper script to overwrite or pass in additional helm arguments

HELM_LOCATION=${HELM_LOCATION:-"/usr/local/bin/helm"}

UPGRADE_STRATEGY_OVERWRITE=${UPGRADE_STRATEGY_OVERWRITE:-reuse-values}
UPGRADE_FORCE=${UPGRADE_FORCE:-false}

ARGS="$@"
if [[ "$1" == "upgrade " ]]; then
ARGS="${ARGS//--reuse-values/--${UPGRADE_STRATEGY_OVERWRITE}}"
ARGS="--force=${UPGRADE_FORCE} $ARGS"
fi

exec "${HELM_LOCATION}" "$ARGS"
27 changes: 20 additions & 7 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ on:
- v[0-9]+
- v[0-9]+.[0-9]+
- cryostat-v[0-9]+.[0-9]+
# TODO: Remove after approval
- separate-db-storage

jobs:
helm-test:
runs-on: ubuntu-latest
env:
TARGET_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }}
TEST_NAMESPACE: helm-test
WRAPPER_LOCATION: .github/helm
strategy:
matrix:
# Supported strategies
upgrade-strategy: ["reset-values", "reset-then-reuse-values"]
upgrade-force: [true, false]
steps:
- name: Fail if safe-to-test label NOT applied
if: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'safe-to-test') }}
Expand All @@ -51,16 +59,21 @@ jobs:
uses: helm/kind-action@v1
with:
cluster_name: ci-${{ github.run_id }}
- name: Install and test chart
- name: Wrap Helm in Wrapper Command
run: |
# FIXME: Remove when chart-testing fixes the issue https://github.com/helm/chart-testing/issues/525
# FIXME: Remvove after https://github.com/helm/chart-testing/issues/525
HELM_LOCATION="$(which helm)"
sudo mv $HELM_LOCATION "$(dirname $HELM_LOCATION)/.helm"
cat <(echo '#!/usr/bin/env bash') <(echo 'exec .helm "${@//--reuse-values/--reset-then-reuse-values}"') | sudo tee $HELM_LOCATION
sudo chmod +x $HELM_LOCATION
HELM_NEW_LOCATION="$(dirname $HELM_LOCATION)/.helm"
sudo mv "$HELM_LOCATION" "$HELM_NEW_LOCATION"
chmod +x "$WRAPPER_LOCATION" && sudo mv "$WRAPPER_LOCATION" "$HELM_LOCATION"
bash ct.bash --upgrade
# Export env var
echo "HELM_LOCATION=$HELM_LOCATION" >> $GITHUB_ENV
echo "UPGRADE_STRATEGY_OVERWRITE=${{ matrix.upgrade-strategy }}" >> $GITHUB_ENV
echo "UPGRADE_FORCE=${{ matrix.upgrade-force }}" >> $GITHUB_ENV
- name: Install and test chart
run: bash ct.bash --upgrade

helm-unittest:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/templates/cryostat_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cryostat.fullname" . }}
name: {{ include "cryostat.fullname" . }}-main
labels:
{{- include "cryostat.labels" . | nindent 4 }}
app.kubernetes.io/component: cryostat
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/tests/cryostat_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tests:
value: Deployment
- equal:
path: metadata.name
value: RELEASE-NAME-cryostat
value: RELEASE-NAME-cryostat-main
- equal:
path: spec.replicas
value: 1
Expand Down

0 comments on commit 05c7844

Please sign in to comment.