-
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.
Fixes in Makefile and Workflows (#3)
* Fix fastapi update * Makefile * Style * Better on pr workflow * Move static * Service instead docker setup * Tests * Deps
- Loading branch information
Showing
10 changed files
with
110 additions
and
74 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,67 +1,80 @@ | ||
#name: Python package | ||
# | ||
#on: | ||
# pull_request: | ||
# | ||
#jobs: | ||
# test: | ||
# name: Unit tests | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v4 | ||
# - name: Set up docker | ||
# uses: docker-practice/actions-setup-docker@master | ||
# - name: Run postgres | ||
# run: | | ||
# docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-test postgres:15-alpine | ||
# - uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: '3.11' | ||
# - name: Install dependencies | ||
# run: | | ||
# python -m ensurepip | ||
# python -m pip install --upgrade --no-cache-dir pip | ||
# python -m pip install --upgrade --no-cache-dir -r requirements.txt -r requirements.dev.txt | ||
# - name: Migrate DB | ||
# run: | | ||
# DB_DSN=postgresql://postgres@localhost:5432/postgres alembic upgrade head | ||
# - name: Build coverage file | ||
# run: | | ||
# DB_DSN=postgresql://postgres@localhost:5432/postgres pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=achievement_api tests/ | tee pytest-coverage.txt | ||
# - name: Print report | ||
# if: always() | ||
# run: | | ||
# cat pytest-coverage.txt | ||
# - name: Pytest coverage comment | ||
# uses: MishaKav/pytest-coverage-comment@main | ||
# with: | ||
# pytest-coverage-path: ./pytest-coverage.txt | ||
# title: Coverage Report | ||
# badge-title: Code Coverage | ||
# hide-badge: false | ||
# hide-report: false | ||
# create-new-comment: false | ||
# hide-comment: false | ||
# report-only-changed-files: false | ||
# remove-link-from-badge: false | ||
# junitxml-path: ./pytest.xml | ||
# junitxml-title: Summary | ||
# linting: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - uses: actions/setup-python@v2 | ||
# with: | ||
# python-version: 3.11 | ||
# - uses: isort/isort-action@master | ||
# with: | ||
# requirementsFiles: "requirements.txt requirements.dev.txt" | ||
# - uses: psf/black@stable | ||
# - name: Comment if linting failed | ||
# if: ${{ failure() }} | ||
# uses: thollander/actions-comment-pull-request@v2 | ||
# with: | ||
# message: | | ||
# :poop: Code linting failed, use `black` and `isort` to fix it. | ||
name: Python tests | ||
|
||
on: | ||
pull_request: | ||
|
||
|
||
jobs: | ||
test: | ||
name: Unit tests | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:15 | ||
env: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
-p 5432:5432 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: | | ||
python -m ensurepip | ||
python -m pip install --upgrade --no-cache-dir pip | ||
python -m pip install --upgrade --no-cache-dir -r requirements.txt -r requirements.dev.txt | ||
- name: Migrate DB | ||
run: | | ||
DB_DSN=postgresql://postgres@localhost:5432/postgres alembic upgrade head | ||
- name: Build coverage file | ||
id: pytest | ||
run: | | ||
DB_DSN=postgresql://postgres@localhost:5432/postgres pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=achievement_api tests/ | tee pytest-coverage.txt | ||
exit ${PIPESTATUS[0]} | ||
- name: Print report | ||
if: always() | ||
run: | | ||
cat pytest-coverage.txt | ||
- name: Pytest coverage comment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
if: always() | ||
with: | ||
pytest-coverage-path: ./pytest-coverage.txt | ||
title: Coverage Report | ||
badge-title: Code Coverage | ||
hide-badge: false | ||
hide-report: false | ||
create-new-comment: false | ||
hide-comment: false | ||
report-only-changed-files: false | ||
remove-link-from-badge: false | ||
junitxml-path: ./pytest.xml | ||
junitxml-title: Summary | ||
- name: Fail on pytest errors | ||
if: steps.pytest.outcome == 'failure' | ||
run: exit 1 | ||
|
||
linting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
- uses: isort/isort-action@master | ||
with: | ||
requirementsFiles: "requirements.txt requirements.dev.txt" | ||
- uses: psf/black@stable | ||
- name: Comment if linting failed | ||
if: failure() | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
message: | | ||
:poop: Code linting failed, use `black` and `isort` to fix it. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ pydantic[dotenv] | |
pydantic-settings | ||
SQLAlchemy | ||
uvicorn | ||
python-multipart |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
from achievement_api.routes.base import app | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
yield TestClient(app) |
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,3 @@ | ||
def test_unprocessable_jsons_no_token(client): | ||
response = client.get(f"/openapi.json") | ||
assert response.status_code == 200 |