-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ekarlso/add-chart-testing
feat: Add chart-testing
- Loading branch information
Showing
3 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Helm | ||
uses: azure/setup-helm@v3 | ||
with: | ||
version: v3.10.0 | ||
|
||
- name: Set up chart-testing | ||
uses: helm/chart-testing-action@v2.3.1 | ||
|
||
- name: Run chart-testing (list-changed) | ||
id: list-changed | ||
run: | | ||
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) | ||
if [[ -n "$changed" ]]; then | ||
echo "changed=yes" >> $GITHUB_ENV | ||
fi | ||
- name: Run chart-testing (lint) | ||
run: ct lint --target-branch ${{ github.event.repository.default_branch }} | ||
|
||
- name: Run chart-testing (install) | ||
if: env.changed == 'yes' | ||
run: | | ||
bash -xe ./e2e-test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/bash | ||
|
||
export K8S_VERSION="${K8S_VERSION:-v1.23.12}" | ||
export CLUSTER_NAME=${CLUSTER_NAME:-chart-testing} | ||
|
||
# function wait_for_daemonset() { | ||
# ns="$1" | ||
# name="$2" | ||
|
||
# retries=10 | ||
# while [[ $retries -ge 0 ]];do | ||
# sleep 3 | ||
# ready=$(kubectl -n $ns get daemonset $name -o jsonpath="{.status.numberReady}") | ||
# required=$(kubectl -n $ns get daemonset $name -o jsonpath="{.status.desiredNumberScheduled}") | ||
# echo "$kind $ns/$name: rdy $ready req $required" | ||
|
||
# if [[ $ready -eq $required ]];then | ||
# echo "Succeeded" | ||
# break | ||
# fi | ||
# ((retries--)) | ||
# done | ||
# } | ||
|
||
get_tremor_pod() { | ||
kubectl get pod -n $1 -l app=tremor -o jsonpath='{ .items[0].metadata.name }' | ||
} | ||
|
||
wait_for_pod() { | ||
pod=$(get_tremor_pod $1) | ||
kubectl wait pods -n $1 $pod --for condition=Ready --timeout=90s | ||
} | ||
|
||
collect_info() { | ||
pod=$(get_tremor_pod $1) | ||
|
||
kubectl describe pod -n $1 $pod | ||
kubectl logs -n $1 $pod | ||
} | ||
|
||
create_kind_cluster() { | ||
if kubectl cluster-info >/dev/null 2>&1; then | ||
return 0 | ||
fi | ||
|
||
kind create cluster --name "$CLUSTER_NAME" --image "kindest/node:$K8S_VERSION" --wait 60s | ||
|
||
kubectl cluster-info || kubectl cluster-info dump | ||
echo | ||
|
||
kubectl get nodes | ||
echo | ||
|
||
echo 'Cluster ready!' | ||
echo | ||
} | ||
|
||
cleanup() { | ||
kind delete cluster --name "$CLUSTER_NAME" | ||
echo 'Done!' | ||
} | ||
|
||
generate_ns_name() { | ||
awk -F '-' '{print $5}'< /proc/sys/kernel/random/uuid | ||
} | ||
|
||
test_daemonset() { | ||
namespace=e2e-$(generate_ns_name) | ||
|
||
helm upgrade -i --create-namespace -n "$namespace" tremor ./charts/tremor | ||
|
||
wait_for_pod $namespace | ||
collect_info $namespace | ||
} | ||
|
||
test_deployment() { | ||
namespace=`generate_ns_name` | ||
|
||
helm upgrade -i --create-namespace -n "$namespace" tremor ./charts/tremor --set=kind=Deployment | ||
|
||
wait_for_pod $namespace | ||
collect_info $namespace | ||
} | ||
|
||
create_kind_cluster | ||
|
||
test_daemonset | ||
test_deployment |