Skip to content

Test

Test #457

Workflow file for this run

name: Test
on:
push:
pull_request:
schedule:
- cron: "25 3 * * 3"
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
$HOME/.local/bin/poetry config virtualenvs.create false
- name: Install dependencies
run: $HOME/.local/bin/poetry install --no-interaction
- name: flake8
run: flake8 --ignore=E731,W503,W504 reproserver tests
- name: Unit tests
run: TESTS_DIR=tests/unit python tests
test:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
$HOME/.local/bin/poetry config virtualenvs.create false
- name: Install dependencies
run: $HOME/.local/bin/poetry install --no-interaction
- name: Install minikube
run: |
sudo mkdir -p /usr/local/bin
sudo curl -Lo /usr/local/bin/minikube https://github.com/kubernetes/minikube/releases/download/v1.31.1/minikube-linux-amd64
sudo chmod +x /usr/local/bin/minikube
sudo curl -Lo /usr/local/bin/kubectl https://dl.k8s.io/release/v1.27.4/bin/linux/amd64/kubectl
sudo chmod +x /usr/local/bin/kubectl
- name: Start Kubernetes cluster
run: |
minikube start --kubernetes-version=1.27.4 --driver=docker --nodes=1 --container-runtime=docker --ports=8000:30808
kubectl describe node
kubectl apply -f k8s/ingress-nginx.yml
- name: Build image
run: |
(eval $(minikube docker-env); docker build -t reproserver_web .)
- name: Start reproserver on Kubernetes
run: |
# Wait for nginx ingress
kubectl -n ingress-nginx wait --timeout=5m --for=condition=Available deploy ingress-nginx-controller
helm install reproserver k8s/helm --namespace default -f k8s/minikube.values.yml
# Wait for the pods to be available
if ! kubectl wait --timeout=10m --for=condition=Available deploy --all; then
kubectl get pod
exit 1
fi
export WEB_URL=http://localhost:8000
# Wait a little bit more until the web server replies
slept=0; while [ $(curl -s -o /dev/null -w "%{http_code}" $WEB_URL/) != 200 ]; do
if [ $slept -gt 300 ]; then
echo "web didn't come up after ${slept}s"
exit 1
fi
sleep 5; slept=$((slept + 5))
done
echo "web came up after ${slept}s"
curl -I -X GET $WEB_URL/
- name: Run integration tests
run: |
if ! TESTS_DIR=tests/integ WEB_URL=http://localhost:8000 python tests; then
echo "logs: deploy/reproserver"
kubectl logs deploy/reproserver 2>&1
echo "logs: runners"
kubectl logs --all-containers --prefix -l app.kubernetes.io/component=run
exit 1
fi