python-api-server/.drone.yml

144 lines
3.4 KiB
YAML
Raw Normal View History

2023-04-12 15:56:47 +02:00
---
kind: pipeline
type: docker
2023-06-10 11:13:39 +02:00
name: linting
2023-04-28 21:45:36 +02:00
2023-04-12 15:56:47 +02:00
steps:
2023-06-10 11:13:39 +02:00
- name: gitleaks
2023-04-23 16:18:25 +02:00
image: plugins/gitleaks
settings:
path: .
when:
event:
exclude:
- tag
2023-04-12 15:56:47 +02:00
2023-04-23 16:18:25 +02:00
- name: hadolint
image: hadolint/hadolint:latest-debian
commands:
2023-06-10 11:13:39 +02:00
- hadolint Dockerfile
2023-04-25 21:01:50 +02:00
2023-06-10 11:13:39 +02:00
---
kind: pipeline
type: docker
name: selfhosted
depends_on: # bezieht sich auf linting pipeline
- linting
steps:
2023-04-20 13:43:26 +02:00
- name: docker_build_and_push_selfhosted
2023-04-12 15:56:47 +02:00
image: plugins/docker
settings:
dockerfile: Dockerfile
2023-04-20 13:46:41 +02:00
repo: registry.mgrote.net/python-api-server
2023-04-20 13:43:26 +02:00
registry: registry.mgrote.net
2023-04-12 15:56:47 +02:00
tags:
- ${DRONE_COMMIT_SHA:0:8}
2023-04-12 15:56:47 +02:00
- ${DRONE_COMMIT_BRANCH}
2023-04-20 13:40:21 +02:00
- latest
2023-04-20 13:48:58 +02:00
when:
event:
exclude:
- pull_request
2023-04-23 16:14:47 +02:00
- tag
2023-06-10 11:13:39 +02:00
- name: docker_build_and_push_selfhosted_tag
image: plugins/docker
settings:
dockerfile: Dockerfile
repo: registry.mgrote.net/python-api-server
registry: registry.mgrote.net
tags:
- ${DRONE_TAG}
when:
event:
- tag
---
kind: pipeline
type: docker
2023-06-10 11:14:17 +02:00
name: dockerhub
2023-06-10 11:13:39 +02:00
depends_on: # bezieht sich auf linting pipeline
- linting
steps:
2023-04-23 16:07:03 +02:00
- name: docker_build_and_push_dockerhub
image: plugins/docker
settings:
username:
from_secret: DOCKERHUB_USER
password:
from_secret: DOCKERHUB_PASS
dockerfile: Dockerfile
repo: quotengrote/python-api-server
tags:
- ${DRONE_COMMIT_SHA:0:8}
2023-04-23 16:07:03 +02:00
- ${DRONE_COMMIT_BRANCH}
- latest
when:
event:
exclude:
- pull_request
2023-04-23 16:14:47 +02:00
- tag
2023-04-23 16:07:03 +02:00
- name: docker_build_and_push_dockerhub_tag
image: plugins/docker
settings:
username:
from_secret: DOCKERHUB_USER
password:
from_secret: DOCKERHUB_PASS
dockerfile: Dockerfile
repo: quotengrote/python-api-server
tags:
2023-04-23 16:16:40 +02:00
- ${DRONE_TAG}
2023-04-23 16:07:03 +02:00
when:
event:
- tag
2023-06-26 23:42:28 +02:00
---
kind: pipeline
type: docker
2023-06-26 23:43:13 +02:00
name: test
2023-06-26 23:42:28 +02:00
depends_on:
- selfhosted
- dockerhub
2023-06-26 23:44:40 +02:00
steps:
2023-06-26 23:42:28 +02:00
- name: test
image: registry.mgrote.net/python-api-server:latest
environment:
MAX_CONTENT_LENGTH: 50
UPLOAD_DIRECTORY: /uploads
AUTH_TOKEN: myuploadtoken
ENABLE_WEBSERVER: false
DEBIAN_FRONTEND: noninteractive
2023-06-26 23:42:28 +02:00
commands:
2023-06-26 23:44:16 +02:00
- |
2023-06-26 23:48:45 +02:00
apt update
2023-06-26 23:54:49 +02:00
apt install wget jq curl -y
2023-06-26 23:58:45 +02:00
python3 -m gunicorn app:app c gunicorn_config.py &
2023-06-26 23:44:16 +02:00
export TOKEN=myuploadtoken
2023-07-04 13:27:14 +02:00
export URL="127.0.0.1:5000"
2023-06-26 23:44:16 +02:00
mkdir -p tests
2023-06-26 23:59:49 +02:00
echo "Test: normaler Upload"
2023-06-26 23:44:16 +02:00
echo content > tests/file
curl -X POST -H "token: $TOKEN" -F "file=@tests/file" $URL/upload | jq
2023-06-26 23:59:49 +02:00
echo "Test: leerer Upload"
2023-06-26 23:44:16 +02:00
curl -X POST -H "token: $TOKEN" $URL/upload | jq
2023-06-26 23:59:49 +02:00
echo "Test: fehlerhafter Dateiname Upload"
2023-06-26 23:44:16 +02:00
touch ./tests/'hallo\welt.txt'
curl -X POST -H "token: $TOKEN" -F "file=@tests/hallo\welt.txt" $URL/upload | jq
2023-06-26 23:59:49 +02:00
echo "Test: List Files"
2023-06-26 23:44:16 +02:00
curl -H "token: $TOKEN" $URL/list | jq
2023-06-26 23:59:49 +02:00
echo "Test: download Datei"
2023-06-26 23:44:16 +02:00
wget $URL/download/file -o ./tests/file
ls -lah ./tests/file
2023-06-26 23:59:49 +02:00
echo "Test: download nicht vorhandene Datei"
2023-06-26 23:44:16 +02:00
wget $URL/download/file2
2023-06-26 23:59:49 +02:00
echo "Test: lösche Datei"
2023-06-26 23:44:16 +02:00
curl -X DELETE -H "token: $TOKEN" $URL/delete/file | jq
2023-06-26 23:59:49 +02:00
echo "Test: lösche nicht vorhandene Datei"
2023-06-26 23:44:16 +02:00
curl -X DELETE -H "token: $TOKEN" $URL/delete/file2 | jq
2023-06-26 23:59:49 +02:00
echo "Test: check health"
2023-06-26 23:44:16 +02:00
curl $URL/health
rm -rf tests