-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (77 loc) · 2.96 KB
/
test-endpoint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Endpoint CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
services:
# Label used to access the service container
kafka:
# Docker Hub image
image: bitnami/kafka:3.4
# Provide the password for postgres
env:
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "true"
# Kafka KRaft settings
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_PROCESS_ROLES: "controller,broker"
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "0@kafka:9093"
# Listeners
KAFKA_CFG_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093"
KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://:9092"
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: "PLAINTEXT"
# Set health checks to wait until postgres has started
options: >-
--health-cmd "kafka-topics.sh --bootstrap-server kafka:9092 --topic hc --create --if-not-exists && kafka-topics.sh --bootstrap-server kafka:9092 --topic hc --describe"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Tests run directly on the runner so we have to map the port
- 9092:9092
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install ruff pytest requests
pip install -r requirements.txt
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff check --output-format=github --select=E9,F63,F7,F82 .
# default set of ruff rules with GitHub Annotations
ruff check --output-format=github .
- name: Test with pytest
env:
PYTEST_ADDOPTS: "--color=yes"
AUTH_TOKEN: "abcd1234"
KAFKA_HOST: "localhost"
KAFKA_PORT: 9092
KAFKA_BOOTSTRAP_SERVERS: "localhost:9092"
LOG_LEVEL: "DEBUG"
DEBUG: 1
run: |
uvicorn app:app --host 0.0.0.0 --port 8000 --proxy-headers &&
pytest -v tests/test_api.py