Skip to content

Commit

Permalink
Add endpoints for Entitlements operations (#4)
Browse files Browse the repository at this point in the history
* chore: Go back to single step (MPT-4917)

* chore: Small CI improvments (MPT-4917)

* chore: CI branch changes to trigger the pipeline (MPT-4917)

* chore: Move openapi spec generation to CI (MPT-4917)

* chore: Remove openapi.json from the repo as now we're using CI to generate it and save into artefacts (MPT-4917)

* chore: Remove special branch condition now that we're back to using master (MPT-4917)

* chore: Remove TODOs (MPT-4917)

* feat: Add entitlements endpoints (MPT-4901)

* feat: Add pagination (MPT-4901)

* feat: Add tests (MPT-4901)

* Add license file

* Fix licensor name

* CI Pipeline improvements (MPT-4917) (#3)

* chore: Go back to single step (MPT-4917)
* chore: Small CI improvments (MPT-4917)
* chore: CI branch changes to trigger the pipeline (MPT-4917)
* chore: Move openapi spec generation to CI (MPT-4917)
* chore: Remove openapi.json from the repo as now we're using CI to generate it and save into artefacts (MPT-4917)
* chore: Remove special branch condition now that we're back to using master (MPT-4917)
* chore: Remove TODOs (MPT-4917)

* chore: CI branch changes to trigger the pipeline (MPT-4917)

* chore: Move openapi spec generation to CI (MPT-4917)

* chore: Remove special branch condition now that we're back to using master (MPT-4917)

* chore: Remove TODOs (MPT-4917)

* CI Pipeline improvements (MPT-4917) (#3)

* chore: Go back to single step (MPT-4917)
* chore: Small CI improvments (MPT-4917)
* chore: CI branch changes to trigger the pipeline (MPT-4917)
* chore: Move openapi spec generation to CI (MPT-4917)
* chore: Remove openapi.json from the repo as now we're using CI to generate it and save into artefacts (MPT-4917)
* chore: Remove special branch condition now that we're back to using master (MPT-4917)
* chore: Remove TODOs (MPT-4917)

* chore: Go back to single step (MPT-4917)

* chore: Remove TODOs (MPT-4917)

* chore: Move openapi spec generation to CI (MPT-4917)

* chore: Remove TODOs (MPT-4917)

* feat: Exclude migrations from linting and remove duplicated tests

* feat: Remove mypy -- causes more problems than benefits

* feat: Set up testing database and integrate it with CI

* feat: Make app dependant on the DB in docker-compose

* feat: Add one more test

* feat: Set the line length to 100

* feat: Remove pytst coverage fail_under as this would be covered by another tool

* feat: Change the project dependancies to adhere with the starndards of the other repos

* feat: Remove pgadmin

* feat: db container -- use the POSTGRES_PORT env variable to select the port instead of a hardcoding 5432

* feat: Update gitignore

* feat: Remove CammelModel :)

* feat: Update dockerfile

* feat: Remove test_postgres_... env vars

* feat: Update docker compose to follow the same pattern as other repos

* feat: Simplify the default initialisation of Settings

* feat: add prefix to env vars

* feat: s/repository/collection

* feat: Update the github actions to use a service for the DB instead of running docker-compose

* feat: Remove makefile

---------

Co-authored-by: Francesco Faraone <[email protected]>
  • Loading branch information
arturbalabanov and Francesco Faraone authored Dec 16, 2024
1 parent 91a1ef2 commit 6e014ae
Show file tree
Hide file tree
Showing 27 changed files with 1,462 additions and 477 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/pr-build-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ permissions:

jobs:
build:
services:
db:
image: postgres:17
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: mysecurepass
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

runs-on: ubuntu-latest
timeout-minutes: 10

Expand Down Expand Up @@ -41,17 +56,18 @@ jobs:
- name: Run linting
run: uv run ruff check .

- name: Run type checks
run: uv run mypy .

- name: Run security checks
run: uv run bandit -c pyproject.toml -r .

- name: Run tests
run: uv run pytest
env:
FFC_OPERATIONS_POSTGRES_HOST: localhost
FFC_OPERATIONS_POSTGRES_PORT: 5432

- name: Save code coverage report in the artefacts
uses: actions/upload-artifact@v4
if: ${{ !env.ACT }}
with:
name: coverage-report
path: htmlcov
Expand All @@ -62,6 +78,7 @@ jobs:

- name: Save openapi.json the artefacts
uses: actions/upload-artifact@v4
if: ${{ !env.ACT }}
with:
name: openapi-spec
path: openapi.json
Expand Down
163 changes: 154 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,165 @@
# Python-generated files
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[oc]
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# Virtual environments
.venv/
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# Dev environment
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# Third party tools
# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# ruff
.ruff_cache/
.pytest_cache/
.coverage

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
28 changes: 0 additions & 28 deletions Makefile

This file was deleted.

115 changes: 115 additions & 0 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts.
# Use forward slashes (/) also on windows to provide an os agnostic path
script_location = migrations

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s

# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = .

# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python>=3.9 or backports.zoneinfo library.
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
# string value is passed to ZoneInfo()
# leave blank for localtime
# timezone =

# max length of characters to apply to the "slug" field
# truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# version location specification; This defaults
# to migrations/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
# version_locations = %(here)s/bar:%(here)s/bat:migrations/versions

# version path separator; As mentioned above, this is the character used to split
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
# Valid values for version_path_separator are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
# version_path_separator = newline
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.

# set to 'true' to search source files recursively
# in each "version_locations" directory
# new in Alembic version 1.10
# recursive_version_locations = false

# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8

sqlalchemy.url = driver://user:pass@localhost/dbname


[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME

# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
# hooks = ruff
# ruff.type = exec
# ruff.executable = %(here)s/.venv/bin/ruff
# ruff.options = --fix REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARNING
handlers = console
qualname =

[logger_sqlalchemy]
level = WARNING
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
4 changes: 4 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from app import models # noqa: F401
from app.conf import Settings

settings = Settings()
Loading

0 comments on commit 6e014ae

Please sign in to comment.