Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Jan 4, 2022
2 parents ec03a75 + c14e247 commit 2febb09
Show file tree
Hide file tree
Showing 33 changed files with 479 additions and 218 deletions.
4 changes: 4 additions & 0 deletions .flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FLASK_APP=pypnnomenclature:create_app
FLASK_ENV=development
FLASK_DEBUG=1
NOMENCLATURE_SETTINGS=settings.py
84 changes: 84 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: pytest

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
build:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- name: "Debian 10"
python-version: "3.7"
postgres-version: "11-stretch"
- name: "Debian 11"
python-version: "3.9"
postgres-version: "13-bullseye"

name: ${{ matrix.name }}

services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Add database extensions
run: |
psql -h localhost -U postgres -d postgres -tc 'CREATE EXTENSION "uuid-ossp";'
psql -h localhost -U postgres -d postgres -tc 'CREATE EXTENSION "pg_trgm";'
env:
PGPASSWORD: postgres
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install \
pytest-cov \
-e .[tests] \
-e file:dependencies/Utils-Flask-SQLAlchemy#egg=utils-flask-sqlalchemy \
-e file:dependencies/TaxHub#egg=taxhub \
-e file:dependencies/UsersHub-authentification-module#egg=pypnusershub
- name: Install database
run: |
flask db upgrade nomenclatures@head
flask db upgrade nomenclatures_inpn_data@head
flask db upgrade nomenclatures_taxonomie@head
flask db upgrade nomenclatures_taxonomie_inpn_data@head
env:
NOMENCLATURE_SETTINGS: test_settings.py
- name: Test with pytest
run: |
pytest -v --cov --cov-report xml
env:
NOMENCLATURE_SETTINGS: test_settings.py
- name: Upload coverage to Codecov
if: ${{ matrix.name == 'Debian 11' }}
uses: codecov/codecov-action@v2
with:
flags: pytest
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,8 @@ ENV/

# mypy
.mypy_cache/

*.swp
*.swo

/*settings.py
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "dependencies/Utils-Flask-SQLAlchemy"]
path = dependencies/Utils-Flask-SQLAlchemy
url = https://github.com/PnX-SI/Utils-Flask-SQLAlchemy.git
[submodule "dependencies/TaxHub"]
path = dependencies/TaxHub
url = https://github.com/PnX-SI/TaxHub.git
[submodule "dependencies/UsersHub-authentification-module"]
path = dependencies/UsersHub-authentification-module
url = https://github.com/PnX-SI/UsersHub-authentification-module.git
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Nomenclature-api-module

[![pytest](https://github.com/PnX-SI/Nomenclature-api-module/actions/workflows/pytest.yml/badge.svg)](https://github.com/PnX-SI/Nomenclature-api-module/actions/workflows/pytest.yml)
[![codecov](https://codecov.io/gh/PnX-SI/Nomenclature-api-module/branch/master/graph/badge.svg?token=KGZRGXFWCK)](https://codecov.io/gh/PnX-SI/Nomenclature-api-module)

Flask (Python) module for Nomenclature API.

It is used in [GeoNature](https://github.com/PnX-SI/GeoNature) but can also be used as a standalone API service to manage and returns various nomenclatures with their hierarchy.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.5
1.5.0
13 changes: 0 additions & 13 deletions admin.py

This file was deleted.

1 change: 1 addition & 0 deletions dependencies/TaxHub
Submodule TaxHub added at 11fbe5
1 change: 1 addition & 0 deletions dependencies/UsersHub-authentification-module
1 change: 1 addition & 0 deletions dependencies/Utils-Flask-SQLAlchemy
Submodule Utils-Flask-SQLAlchemy added at df44a2
19 changes: 19 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
CHANGELOG
=========

1.5.0 (2022-01-04)
------------------

**🚀 Nouveautés**

* Possibilité de lancer l’API Nomenclature de manière autonome
* Possibilité de créer son schéma de base de données de manière autonome
* Mise en place des tests unitaires
* Mise en place de l’intégration continue
* Intégration des dépendances en tant que sous-module Git

* Utils-Flask-SQLAlchemy
* TaxHub (pour la taxonomie)
* UsersHub-authentification-module (car requis par TaxHub)

**🐛 Corrections**

* Suppression d’anciens fichiers devenus inutiles suite au paquetage

1.4.5 (2021-01-03)
------------------

Expand Down
15 changes: 0 additions & 15 deletions install_app.sh

This file was deleted.

17 changes: 0 additions & 17 deletions models.py

This file was deleted.

14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = [
"src",
]

[tool.coverage.run]
source = [
"pypnnomenclature",
]
omit = [
"*/tests/*",
"*/migrations/*",
]
17 changes: 0 additions & 17 deletions repository.py

This file was deleted.

5 changes: 4 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
python-dotenv
flask
Flask-Admin
flask-sqlalchemy
flask-migrate
psycopg2
utils-flask-sqlalchemy
utils-flask-sqlalchemy>=0.2.6
flask-marshmallow
marshmallow-sqlalchemy

17 changes: 0 additions & 17 deletions routes.py

This file was deleted.

30 changes: 0 additions & 30 deletions server.py

This file was deleted.

2 changes: 1 addition & 1 deletion config.py.sample → settings.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COOKIE_EXPIRATION = 3600
COOKIE_AUTORENEW = True

# Ajouter les filtres taxonomiques à l'API
# Nécessite d'avoir exécuté le script 'data/nomenclature_taxonomie.sql' qui installe les tables nécessaires
# Nécessite d'avoir monté la branche alembic nomenclature_taxonomie
ENABLE_NOMENCLATURE_TAXONOMIC_FILTERS = True

# URL de l'interface d'administration
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
with (root_dir / 'requirements.in').open() as f:
requirements = f.read().splitlines()


setuptools.setup(
name='pypnnomenclature',
version=version,
Expand All @@ -23,6 +24,9 @@
package_dir={'': 'src'},
package_data={'pypnnomenclature.migrations': ['data/*.sql']},
install_requires=requirements,
extras_require={
'tests': [ 'pytest', 'pytest-flask', ],
},
entry_points={
'alembic': [
'migrations = pypnnomenclature.migrations:versions',
Expand Down
34 changes: 33 additions & 1 deletion src/pypnnomenclature/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
__version__ = "1.1.1"
from pathlib import Path
from itertools import chain
from pkg_resources import iter_entry_points

from flask import Flask
from flask_migrate import Migrate

from pypnnomenclature.env import db, ma
from pypnnomenclature.routes import routes


migrate = Migrate()


@migrate.configure
def configure_alembic(alembic_config):
version_locations = alembic_config.get_main_option('version_locations', default='').split()
for entry_point in chain(iter_entry_points('alembic', 'migrations')):
_, migrations = str(entry_point).split('=', 1)
version_locations += [ migrations.strip() ]
alembic_config.set_main_option('version_locations', ' '.join(version_locations))
return alembic_config


def create_app():
app = Flask('Habref')
app.config.from_envvar('NOMENCLATURE_SETTINGS')
ma.init_app(app)
db.init_app(app)
migrate.init_app(app, db, directory=Path(__file__).parent / 'migrations')
app.register_blueprint(routes, url_prefix='/nomenclatures')
# TODO admin
return app
Loading

0 comments on commit 2febb09

Please sign in to comment.