Integration tests #1
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: Tests Kubernetes manifest | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
container: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install -r requirements-test.txt | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
load: true | |
tags: test:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Start minikube | |
uses: medyagh/setup-minikube@master | |
- name: Deploy to minikube | |
run: | | |
kubectl create namespace scrapyd | |
minikube image push test:latest | |
sed -i 's/\(imagePullPolicy:\s*\)\w\+/\1Never/' kubernetes.yaml | |
sed -i 's/\(image:\s*\)ghcr\.io\/q-m\/scrapyd-k8s:/\1test:/' kubernetes.yaml | |
kubectl create -f kubernetes.yaml | |
URL=`minikube service scrapyd-k8s --url` \ | |
HOST=`echo "$URL" | sed 's/^http:\/\+\([^:\/]\+\):[0-9]\+\/\?$/\1/'` | |
PORT=`echo "$URL" | sed 's/^http:\/\+[^:\/]\+:\([0-9]\+\)\/\?$/\1/'` | |
while ! nc -q 1 "$HOST" "$PORT" </dev/null; do sleep 1; done | |
curl "$URL"/daemonstatus.json | |
- name: Run tests | |
run: | | |
TEST_BASE_URL=`minikube service scrapyd-k8s --url` \ | |
TEST_MAX_WAIT=60 \ | |
TEST_AVAILABLE_VERSIONS=latest,`skopeo list-tags docker://ghcr.io/q-m/scrapyd-k8s-spider-example | jq -r '.Tags | map(select(. != "latest" and (startswith("sha-") | not))) | join(",")'` \ | |
pytest -vv --color=yes test_api.py |