Skip to content

Fix helm uninstall

Fix helm uninstall #91

Workflow file for this run

#
# Copyright 2020 The dNation Jsonnet Translator Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Test Chart and Application
on:
pull_request:
# Only if there are changes to test.
paths:
- 'chart/**'
- 'translator/**'
- 'docker/**'
- 'test/**'
- 'setup.py'
- 'default_config.yaml'
- '.github/**'
jobs:
lint-chart:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch history
run: git fetch --prune --unshallow
- name: Run chart-testing (lint)
uses: helm/chart-testing-action@v1.0.0
with:
command: lint
config: .github/ct.yaml
build-image-install-chart-run-e2e-test:
runs-on: ubuntu-20.04
strategy:
matrix:
k8s:
- v1.17.11
- v1.19.1
needs:
- lint-chart
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build image
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./docker/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: false
load: true
tags: dnationcloud/kubernetes-jsonnet-translator:test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Fetch history
run: git fetch --prune --unshallow
- name: Create kind ${{ matrix.k8s }} cluster
uses: helm/kind-action@v1.2.0
with:
node_image: kindest/node:${{ matrix.k8s }}
- name: Load image
run: |
cluster_name=$(kind get clusters | head -1)
kind load docker-image dnationcloud/kubernetes-jsonnet-translator:test --name $cluster_name
- name: Run chart-testing (install)
uses: helm/chart-testing-action@v2.1.0
with:
command: install
config: .github/ct.yaml
- name: Install yq
run: |
pip3 install yq
- name: Run End-to-End test
run: |
set -x
helm install --set image.tag=test translator ./chart
kubectl apply -f ci/grafana-jsonnet.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.42/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
kubectl apply -f ci/prom-rule-jsonnet.yaml
timeout 30s bash -c 'until kubectl get cm grafana-dashboards-generated-example-dashboard &> /dev/null; do sleep 2; done' || (echo "Failed: configmap grafana-dashboards-generated-example-dashboard not found" >&2; false)
kubectl describe cm grafana-dashboards-generated-example-dashboard | grep -A 1 -- '----' | grep -v -- '----' > /tmp/grafana-dashboard.json
diff /tmp/grafana-dashboard.json ci/grafana-dashboard.json
timeout 30s bash -c 'until kubectl get prometheusrule prometheus-rules-generated &> /dev/null; do sleep 2; done' || (echo "Failed: prometheusrule prometheus-rules-generated not found" >&2; false)
kubectl get prometheusrule prometheus-rules-generated -o yaml | /opt/hostedtoolcache/ct/v3.4.0/x86_64/venv/bin/yq .spec > /tmp/prometheusrule-spec.json
/opt/hostedtoolcache/ct/v3.4.0/x86_64/venv/bin/yq . ci/prometheusrule-spec.yaml > ci/prometheusrule-spec.json
diff /tmp/prometheusrule-spec.json ci/prometheusrule-spec.json
kubectl create namespace test-namespace
helm upgrade --set image.tag=test,image.args='{--source_namespace,test-namespace,--target_namespace,test-namespace}' translator ./chart
kubectl apply -f ci/grafana-jsonnet-namespaced.yaml
timeout 30s bash -c 'until kubectl get cm -n test-namespace grafana-dashboards-generated-example-dashboard2 &> /dev/null; do sleep 2; done' || (echo "Failed: configmap grafana-dashboards-generated-example-dashboard2 not found" >&2; false)
number_of_dashboards=$(kubectl get cm -n test-namespace | grep grafana-dashboards-generated-example-dashboard2 | awk '{print $2}')
[[ $number_of_dashboards == "1" ]] || (echo "Failed: Number of generated dashboards is diffrent from expected." >&2; false)