Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Bartender-Unit-Tests

on:
push:
branches: [main, develop]
pull_request:
paths-ignore:
- ".github/**"
types:
- opened
- reopened
- synchronize
- ready_for_review
jobs:
continuous-integration:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}

services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ">=0.4.0"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: "Install dependencies"
run: uv sync --all-extras --dev

- name: "Run tests"
env:
DB_HOST: postgres
DB_PORT: 5432
run: uv run pytest -x --no-cov-on-fail --cov=. --cov-report xml --cov-report term

- name: "Run SonarQube Cloud Scan"
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.python.coverage.reportPaths=coverage.xml
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include .env
awslocal=aws --endpoint-url http://localhost:4566
clean-flags=--volumes --rmi all --remove-orphans
dc=docker compose
django-project-path=bartender/infrastructure/frameworks/django

build:
$(dc) up --build --watch
Expand Down Expand Up @@ -40,16 +39,16 @@ show-migrations:
$(dc) exec backend manage showmigrations

test:
uv run pytest -x --ds=bartender.infrastructure.settings.test
uv run pytest -x

test-parallel:
uv run pytest -n auto --ds=bartender.infrastructure.settings.test
uv run pytest -n auto

test-directory:
uv run pytest $(directory) -x --ds=bartender.infrastructure.settings.test
uv run pytest $(directory) -x

coverage:
uv run pytest -x --ds=bartender.infrastructure.settings.test --no-cov-on-fail --cov=. --no-header
uv run pytest -x --no-cov-on-fail --cov=. --no-header

coverage-html:
uv run pytest -x --ds=bartender.infrastructure.settings.test --no-cov-on-fail --cov=. --cov-report=html --no-header
uv run pytest -x --no-cov-on-fail --cov=. --cov-report=html --no-header
8 changes: 4 additions & 4 deletions bartender/infrastructure/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bartender.infrastructure.database.apps.tags',
'bartender.infrastructure.database.apps.glassware',
'bartender.infrastructure.database.apps.ingredients',
'bartender.infrastructure.database.apps.cocktails',
# 'bartender.infrastructure.database.apps.tags',
# 'bartender.infrastructure.database.apps.glassware',
# 'bartender.infrastructure.database.apps.ingredients',
# 'bartender.infrastructure.database.apps.cocktails',
]

MIDDLEWARE = [
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ manage = "manage:main"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["bartender"]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "bartender.infrastructure.settings.test"
python_files = ["test_*.py", "*_test.py"]
17 changes: 17 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sonar.projectKey=drestrepob_bartender
sonar.organization=elpelucas

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=bartender
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

# Custom
sonar.exclusions=tests/**, migrations/**, docs/**
sonar.python.coverage.reportPaths=coverage.xml