|
@@ -0,0 +1,69 @@
|
|
|
+---
|
|
|
+################
|
|
|
+# Build & Test #
|
|
|
+################
|
|
|
+
|
|
|
+kind: pipeline
|
|
|
+name: build & deploy
|
|
|
+
|
|
|
+steps:
|
|
|
+ # Run tests against Python/Flask engine backend (with pytest)
|
|
|
+ - name: pytest with coverage
|
|
|
+ image: python:3.11.1
|
|
|
+ commands:
|
|
|
+ # Install dependencies
|
|
|
+ - pip install poetry
|
|
|
+ - poetry install --with test
|
|
|
+ # Start with a fresh database (which is already running as a service from Drone)
|
|
|
+ - poetry run pytest -n 5 --cov-report term:skip-covered --cov=coffee_wars tests
|
|
|
+ volumes:
|
|
|
+ # Mount pip cache from host
|
|
|
+ - name: pip_cache
|
|
|
+ path: /root/.cache/pip
|
|
|
+ - name: deploy
|
|
|
+ image: appleboy/drone-ssh
|
|
|
+ settings:
|
|
|
+ host:
|
|
|
+ - coffeewars.service
|
|
|
+ username: root
|
|
|
+ ssh_key:
|
|
|
+ from_secret: jail_key
|
|
|
+ command_timeout: 2m
|
|
|
+ script:
|
|
|
+ - pip uninstall -y coffee_wars
|
|
|
+ - pip install git+https://code.unbl.ink/secstate/coffee_wars.git@main
|
|
|
+ - cw migrate
|
|
|
+ - cw collectstatic --noinput
|
|
|
+ - immortalctl restart celery && immortalctl restart coffee_wars
|
|
|
+ when:
|
|
|
+ ref:
|
|
|
+ - refs/tags/*
|
|
|
+ - name: build success notification
|
|
|
+ image: parrazam/drone-ntfy:0.3-linux-amd64
|
|
|
+ when:
|
|
|
+ status: [success]
|
|
|
+ settings:
|
|
|
+ url: https://ntfy.unbl.ink
|
|
|
+ topic: drone
|
|
|
+ priority: low
|
|
|
+ tags:
|
|
|
+ - failure
|
|
|
+ - coffee_wars
|
|
|
+ - name: build failure notification
|
|
|
+ image: parrazam/drone-ntfy:0.3-linux-amd64
|
|
|
+ when:
|
|
|
+ status: [failure]
|
|
|
+ settings:
|
|
|
+ url: https://ntfy.unbl.ink
|
|
|
+ topic: drone
|
|
|
+ priority: high
|
|
|
+ tags:
|
|
|
+ - success
|
|
|
+ - coffee_wars
|
|
|
+volumes:
|
|
|
+ - name: docker
|
|
|
+ host:
|
|
|
+ path: /var/run/docker.sock
|
|
|
+ - name: pip_cache
|
|
|
+ host:
|
|
|
+ path: /tmp/cache/drone/pip
|