Skip to content

ci: 👷 add cypress in kube ci #76

ci: 👷 add cypress in kube ci

ci: 👷 add cypress in kube ci #76

Workflow file for this run

name: Test on kubernetes
on:
# only work when code is on main branch
workflow_dispatch:
push:
branches:
- 'enh/kube'
jobs:
test-app-k8s:
runs-on: ubuntu-latest
env:
LOCAL_DOMAIN: basegun.kubernetes.local
steps:
- name: Start minikube
uses: medyagh/setup-minikube@latest
with:
addons: registry,ingress
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2
- name: Add hosts to /etc/hosts
run: |
MINIKUBE_IP="$(minikube ip)"
sudo echo "$MINIKUBE_IP $LOCAL_DOMAIN" | sudo tee -a /etc/hosts
# we are forced to attribute a DNS to kube cluster for it to work properly
- name: Checkout to code
uses: actions/checkout@v3
- name: Build and install basegun with helm, and test if deployment is successful
id: tests
run: |
# use docker env
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
TAG=$(make get-current-tag) BUILD_TARGET=test docker-compose -f docker-compose-prod.yml build backend
TAG=$(make get-current-tag) docker-compose -f docker-compose-prod.yml build frontend
helm upgrade --install basegun ./infra/kube/helm/ \
--set ingress.hosts[0].host="$LOCAL_DOMAIN" \
--set ingress.hosts[0].paths[0].path="/" \
--set ingress.hosts[0].paths[0].pathType="Prefix" \
--set backend.image.repository="basegun-backend" \
--set backend.image.tag="$(make get-current-tag)-prod" \
--set frontend.image.repository="basegun-frontend" \
--set frontend.image.tag="$(make get-current-tag)-prod" \
--set backend.secret.create="true" \
--set-string backend.secret.values.OS_USERNAME="${{ secrets.OS_USERNAME }}" \
--set-string backend.secret.values.OS_PASSWORD="${{ secrets.OS_PASSWORD }}" \
--set-string backend.secret.values.OS_PROJECT_NAME="${{ secrets.OS_PROJECT_NAME }}" \
--set-string backend.secret.values.OS_TEST="${{ secrets.OS_TEST }}" \
--set-string backend.secret.values.X_OVH_TOKEN="test" \
--set-string backend.secret.values.API_OVH_TOKEN="test"
for i in $(kubectl get deploy -o name); do kubectl rollout status $i -w --timeout=130s; done
- name: Display pod logs on failure
if: failure() && steps.tests.outcome == 'failure'
run: |
kubectl describe pods
kubectl logs deploy/basegun-backend --all-containers --ignore-errors
kubectl logs deploy/basegun-frontend --all-containers --ignore-errors
- name: Test unitests on backend
run : |
kubectl exec deploy/basegun-backend -c basegun-backend -- python -m unittest discover -v
- name: Setup nodejs (for cypress)
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install npm packages (for cypress)
run: npm ci
working-directory: ./frontend
- name: Test end to end
run: FRONTEND_HOST=kube.basegun.fr FRONTEND_PORT=80 npm run test:e2e-ci
working-directory: ./frontend