Skip to content

test

test #78

Workflow file for this run

name: test
on:
push:
tags:
- "*"
branches:
- "*"
schedule:
- cron: "0 0 * * 1"
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Go Version
uses: actions/setup-go@v2
with:
go-version: '1.21'
- uses: AbsaOSS/[email protected]
name: "Create K3D Cluster"
with:
cluster-name: "test-cluster-1"
args: --agents 1
- name: Install Test Dependencies
run: |
# kubebuilder
make install-kubebuilder KUBEBUILDER_INSTALL_DIR=/tmp/kubebuilder/bin
sudo chmod -R 777 /tmp/kubebuilder
# kube-apiserver
curl -L -o /tmp/kubebuilder/bin/kube-apiserver https://dl.k8s.io/v1.24.1/bin/linux/amd64/kube-apiserver
chmod a+x /tmp/kubebuilder/bin/kube-apiserver
cp /tmp/kubebuilder/bin/kube-apiserver /usr/local/bin/kube-apiserver
export TEST_ASSET_KUBE_APISERVER=/tmp/kubebuilder/bin/kube-apiserver
export KUBEBUILDER_ASSETS=/tmp/kubebuilder/bin/
# etcd
curl -L -o /tmp/etcd-v3.5.4-linux-amd64.tar.gz https://github.com/etcd-io/etcd/releases/download/v3.5.4/etcd-v3.5.4-linux-amd64.tar.gz
tar -xzvf /tmp/etcd-v3.5.4-linux-amd64.tar.gz -C /tmp/
mv /tmp/etcd-v3.5.4-linux-amd64/etcd /tmp/kubebuilder/bin
rm -rf /tmp/etcd-v3.5.4-linux-amd64*
export TEST_ASSET_ETCD=/tmp/kubebuilder/bin/etcd
# kustomize
make install-kustomize KUSTOMIZE_INSTALL_DIR=/tmp
export PATH=$PATH:/tmp
# ketch
kubectl cluster-info
make manifests install ketch manager
export PATH=$PATH:$(pwd)/bin
ketch -v
# helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && chmod 700 get_helm.sh && ./get_helm.sh
# cert-manager
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml
# traefik
helm repo add traefik https://helm.traefik.io/traefik
helm repo update
helm uninstall traefik -n kube-system
helm install traefik traefik/traefik
# istio
ISTIO_VERSION=1.11.0 && curl -L -k https://istio.io/downloadIstio |ISTIO_VERSION=1.11.0 sh - && cd istio-$ISTIO_VERSION && ./bin/istioctl install --set profile=demo -y
cd ../
# nginx
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx
# check services
kubectl get svc -A
# wait for containers
kubectl wait --for=condition=Ready=true pod -n cert-manager --all
kubectl get pods -A
# install bats
sudo apt-get update -yq && sudo apt-get install bats -y
- name: Unit Tests
run: |
TEST_ASSET_ETCD="/tmp/kubebuilder/bin/etcd" \
TEST_ASSET_KUBE_APISERVER="/tmp/kubebuilder/bin/kube-apiserver" \
KUBEBUILDER_ASSETS="/tmp/kubebuilder/bin/" \
go test ./... -p 1
TEST_ASSET_ETCD="/tmp/kubebuilder/bin/etcd" \
TEST_ASSET_KUBE_APISERVER="/tmp/kubebuilder/bin/kube-apiserver" \
KUBEBUILDER_ASSETS="/tmp/kubebuilder/bin/" \
go test ./... -p 1 -coverprofile cover.out | tee coverage.txt
- name: Checkout unit-test-coverage
uses: actions/checkout@v2
with:
repository: theketchio/unit-test-coverage
ref: main
path: unit-test-coverage
- name: build coverage-tester
run: go build -o unit-tester unit-test-coverage/main.go
- name: validate unit Tests
run: ./unit-tester --coverage coverage.txt --limits ci/limits.json
- name: Run Integration Tests
run: |
cli_tests/job.sh
cli_tests/app.sh