Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circle ci #168

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
version: 2.1

jobs:
lint-charts:
docker:
- image: quay.io/helmpack/chart-testing:v3.1.1
steps:
- checkout
- run:
command: ct lint --config tests/kind/ct.yaml

helm-unittests:
docker:
- image: cimg/base:2021.04
resource_class: small
steps:
- checkout
- run:
name: Install Helm
command: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm version
- run:
name: Install Helm Unittest
command: |
helm plugin install https://github.com/quintush/helm-unittest
- run:
name: Run Helm Linter
command: |
helm lint apim/apim3
helm lint am
helm lint cockpit
helm lint ae
- run:
name: Run APIM unit tests
command: |
helm unittest -3 -f 'tests/**/*.yaml' apim/apim3
- run:
name: Run AM unit tests
command: |
helm unittest -3 -f 'tests/*.yaml' am

helm-chart-testing:
machine:
image: 'ubuntu-2004:202101-01'
resource_class: medium
environment:
CLUSTER_NAME: chart-testing
NODE_K8S_VERSION: v1.20.2@sha256:8f7ea6e7642c0da54f04a7ee10431549c0257315b3a634f6ef2fecaaedb19bab
KIND_VERSION: v0.11.1
WAIT_FOR_CONTROLPLANE: 60s
steps:
- checkout
- run:
name: Install Helm
command: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm version
- run:
name: Install Kubectl
command: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
./kubectl version --client=true
- run:
name: Install Charts
command: tests/kind/e2e-kind.sh
# name: Install Kind
# command: |
# curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
# chmod +x ./kind
# ./kind --version
# - run:
# name: Create Kind Cluster
# command: |
# echo 'Delete existing cluster'
# ./kind delete cluster --name "$CLUSTER_NAME" > /dev/null 2>&1 || true

# echo 'Create new Kind cluster'
# ./kind create cluster --name "$CLUSTER_NAME" --kubeconfig $HOME/$CLUSTER_NAME.kubeconfig --config tests/kind/kind-config.yaml --image "kindest/node:$NODE_K8S_VERSION" --wait $WAIT_FOR_CONTROLPLANE

# cat $HOME/$CLUSTER_NAME.kubeconfig

# ./kubectl cluster-info --context kind-chart-testing --kubeconfig $HOME/$CLUSTER_NAME.kubeconfig

workflows:
build_branch:
jobs:
- lint-charts
- helm-unittests
- helm-chart-testing
# - run_integration_tests:
# requires:
# - run_helm_tests
1 change: 1 addition & 0 deletions tests/kind/ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
helm-extra-args: --timeout 800s
69 changes: 69 additions & 0 deletions tests/kind/e2e-kind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

readonly CT_VERSION=v3.1.1
readonly KIND_VERSION=v0.11.1
readonly CLUSTER_NAME=chart-testing
readonly K8S_VERSION=v1.20.2@sha256:8f7ea6e7642c0da54f04a7ee10431549c0257315b3a634f6ef2fecaaedb19bab

run_ct_container() {
echo 'Running ct container...'
docker run --rm --interactive --detach --network host --name ct \
--volume "$(pwd)/tests/kind/ct.yaml:/etc/ct/ct.yaml" \
--volume "$(pwd):/workdir" \
--workdir /workdir \
"quay.io/helmpack/chart-testing:$CT_VERSION" \
cat
echo
}

cleanup() {
echo 'Removing ct container...'
docker kill ct > /dev/null 2>&1

echo 'Done!'
}

docker_exec() {
docker exec --interactive ct "$@"
}

create_kind_cluster() {
echo 'Installing kind...'

curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-linux-amd64"
chmod +x kind
sudo mv kind /usr/local/bin/kind

kind create cluster --name "$CLUSTER_NAME" --kubeconfig $HOME/$CLUSTER_NAME.kubeconfig --config tests/kind/kind-config.yaml --image "kindest/node:$K8S_VERSION" --wait 60s

echo 'Copying kubeconfig to container...'
docker cp $HOME/$CLUSTER_NAME.kubeconfig ct:/root/.kube/config

docker_exec kubectl cluster-info
echo

docker_exec kubectl get nodes
echo

echo 'Cluster ready!'
echo
}

install_charts() {
docker_exec ct install
echo
}

main() {
run_ct_container
trap cleanup EXIT

create_kind_cluster
install_charts
}

main
6 changes: 6 additions & 0 deletions tests/kind/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
featureGates:
EphemeralContainers: true
nodes:
- role: control-plane