diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 0000000..33295f0 --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -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 diff --git a/charts/tremor/Chart.yaml b/charts/tremor/Chart.yaml index d729b65..452c115 100644 --- a/charts/tremor/Chart.yaml +++ b/charts/tremor/Chart.yaml @@ -28,6 +28,6 @@ appVersion: "1.0" description: "Chart to deploy a tremor instance" icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/tremor/horizontal/color/tremor-horizontal-color.png name: "tremor" -version: "0.1.1" +version: "0.1.2" maintainers: - - name: Tremor Team + - name: tremor-rs diff --git a/e2e-test.sh b/e2e-test.sh new file mode 100755 index 0000000..8d4a3a6 --- /dev/null +++ b/e2e-test.sh @@ -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 \ No newline at end of file