-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Denis Karpelevich <[email protected]>
- Loading branch information
Showing
27 changed files
with
217 additions
and
48 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Test Auth FastAPI App | ||
|
||
on: | ||
|
@@ -14,26 +11,32 @@ permissions: | |
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.10 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.12" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
pip install pytest | ||
pip install -r ./tests/end_to_end/requirements.txt | ||
# - name: Lint with flake8 | ||
# run: | | ||
# # stop the build if there are Python syntax errors or undefined names | ||
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Set environment variables from secrets and create .env file | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest | ||
echo "${{ secrets.ENV_FILE }}" > ./test_apps/end_to_end/.env | ||
echo "${{ secrets.PRIVATE_KEY }}" > ./keys/private_key.pem | ||
echo "${{ secrets.PUBLIC_KEY }}" > ./keys/public_key.pem | ||
ls -al | ||
- name: Run docker-compose | ||
uses: hoverkraft-tech/[email protected] | ||
with: | ||
compose-file: "./test_apps/end_to_end/docker-compose.yml" |
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
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
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
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
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
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
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
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
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
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
File renamed without changes.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,5 +34,5 @@ http { | |
text/xml | ||
text/javascript; | ||
|
||
include conf.d/prod.conf; | ||
include conf.d/test.conf; | ||
} |
Empty file.
File renamed without changes.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import asyncio | ||
|
||
import pytest_asyncio | ||
|
||
pytest_plugins = ("test_apps.end_to_end.fixtures.setup_redis",) | ||
|
||
|
||
@pytest_asyncio.fixture(scope="session") | ||
def event_loop(): | ||
loop = asyncio.get_event_loop() | ||
yield loop | ||
loop.close() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: '3' | ||
|
||
services: | ||
fastapi-auth-api: | ||
image: fastapi-auth-api | ||
restart: unless-stopped | ||
build: | ||
context: ../../ | ||
dockerfile: auth.Dockerfile | ||
env_file: | ||
- .env | ||
networks: | ||
- test_apps | ||
expose: | ||
- "8000" | ||
depends_on: | ||
redis: | ||
condition: service_healthy | ||
volumes: | ||
- ./../../test_apps:/${APP_HOME}/test_apps | ||
|
||
tests: | ||
image: fastapi-auth-api | ||
privileged: true | ||
env_file: | ||
- .env | ||
networks: | ||
- test_apps | ||
depends_on: | ||
redis: | ||
condition: service_healthy | ||
fastapi-auth-api: | ||
condition: service_started | ||
entrypoint: ${APP_HOME}/test_apps/end_to_end/entrypoint.sh | ||
volumes: | ||
- ./../../test_apps:/${APP_HOME}/test_apps | ||
|
||
redis: | ||
image: redis:latest | ||
restart: always | ||
container_name: redis | ||
privileged: true | ||
networks: | ||
- test_apps | ||
healthcheck: | ||
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] | ||
interval: 30s | ||
timeout: 10s | ||
retries: 5 | ||
|
||
|
||
networks: | ||
test_apps: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
echo "Waiting for volume $APP_HOME/test_apps/ ..." | ||
|
||
while [ ! -d "$APP_HOME"/test_apps/ ] | ||
do | ||
echo "volume $APP_HOME/test_apps/ is still creating ..." | ||
sleep 1 | ||
done | ||
|
||
echo "volume $APP_HOME/test_apps/ created" | ||
|
||
pip install -r "$APP_HOME"/test_apps/end_to_end/requirements.txt && | ||
pytest -s -v --disable-warnings "$APP_HOME"/test_apps/end_to_end/src |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest_asyncio | ||
from test_apps.end_to_end.settings import settings | ||
from redis.asyncio import Redis | ||
|
||
|
||
redis_cli = Redis(host=settings.redis_host, | ||
port=settings.redis_port) | ||
|
||
|
||
@pytest_asyncio.fixture(scope='class') | ||
async def redis_clear_data_before_after(): | ||
await redis_cli.flushall() | ||
yield | ||
await redis_cli.flushall() | ||
|
||
|
||
@pytest_asyncio.fixture(scope='class') | ||
async def redis_clear_data_after(): | ||
yield | ||
await redis_cli.flushall() | ||
|
||
|
||
@pytest_asyncio.fixture(scope='class') | ||
async def redis_clear_data_before(): | ||
await redis_cli.flushall() | ||
yield |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pytest==8.2.2 | ||
pytest-asyncio==0.23.7 |
Oops, something went wrong.