Skip to content

Commit

Permalink
MEP v2.0.0 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucileRainteau authored Sep 28, 2023
1 parent c616414 commit c2458aa
Show file tree
Hide file tree
Showing 149 changed files with 2,173 additions and 5,081 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/reusable_api_reco_coverage_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: 3.7
python-version: "3.10"
- name : Install requirements
run: |
python -m pip install --upgrade pip
pip install -r api-dev-requirements.txt
pip install -r requirements.txt
- name : Install psql client
run: sudo apt update && sudo apt install -y postgresql-client
- name : Run tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_api_reco_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
with:
secrets: API_RECO_TOKEN:${{ env.DATA_GCP_PROJECT }}/${{ env.API_RECO_SECRET_NAME }}
- name: Run tests collection
run: newman run api_integration_tests.postman_collection.json --environment ${{ inputs.TARGET_ENV }}.postman_environment.json --env-var "api_token=${{ steps.secrets.outputs.API_RECO_TOKEN }}"
run: newman run api_integration_tests.postman_collection.json --environment ${{ inputs.TARGET_ENV }}.postman_environment.json
- name: Post to a Slack channel
id: slack
if: ${{ failure() }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ venv/
ENV/
env.bak/
venv.bak/
.env.local

# Spyder project settings
.spyderproject
Expand Down
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Guide de contribution

## Gestion des branches

Les branches sont divisées en 4 catégories :

- Branches de suivi des environnements ( main, staging et production)

- Branches pour l'implémentation des nouvelles évolutions

- Branches pour la correction d'anomalies

- Branches pour corriger un bug critique en production (HotFix)

### Branches d'environnements

Chaque branche correspond à un environnement :

- `main`
- Branche de développement, à partir de laquelle sont créées les branches d'évolutions
- Reçoit le code des évolutions et correctifs
- Fusion avec un Merge commit : `git merge --no-ff [ID]-[Description-courte]`
- Le code fusioné dans main déclenche un workflow de déploiement sur l'environement de Dev
- Porte tous les tags
- `staging`
- Reçoit le code validé dans `main`
- Fusion avec un Merge commit : `git merge --no-ff main`
- Le code fusioné dans Staging déclenche un workflow de déploiement sur l'environement de Staging
- `production`
- Reçoit le code validé dans `staging`
- Fusion avec un Merge commit : `git merge --no-ff staging`
- Le code fusionné dans Production déclenche un workflow de déploiement sur l'environement de Prod


#### Gitlab Flow

![Gitlab Flow](assets/gitlab-flow.jpg)

> Dans le cas d'un Hotfix le correctif doit être fusionné à la fois dans la branche d'environnement et dans main.


### Branches d'évolutions & de corrections

Chaque branche correspond à l'implémentation d'une évolution ou une correction

- Nomenclature : `[ID]-[Description courte]`
- `ID` corresspond au numéro de ticket de l'évolution dans `JIRA`
- La `Description courte` ne doit pas dépasser les 5 mots
- Source : `main` : `git checkout -b [ID]-[Description courte] main`
- Chaque branche doit faire l'objet d'une PR

### Tags

Les tags matérialisent le code source livré en production, ils sont créés quand le code est mergé et déployé en production

Les tags sont créés avec annotation avec la commande : `git tag v[Version] -a`

La version est de la forme [Majeure].[Intermédiaire].[Mineure] :

[Majeure] : version incrémentée lors d'une évolution importante de l'API
[Intermédiaire] : version incrémentée lors d'une évolution intermédiaire
[Mineure] : version incrémentée lors d'une évolution mineure


### Déploiement manuellement sur l'environement de dev

Pour tester sa branche sur l'environement de DEV avant de merger sur Main il est possible de lancer un déploiement manuel :

1) Aller dans l'onglet [Action](https://github.com/pass-culture/api-data/actions) sur le repo
2) Selectioner le worfkflow en question ( deeploy API Compliance / Deploy API Reco )
3) Dans Menu `Run Workflow` vous selectioner votre branche et cliquer sur `run workflow`


### Réferences

https://github.com/jadsonjs/gitlab-flow

https://about.gitlab.com/topics/version-control/what-is-gitlab-flow/

https://about.gitlab.com/topics/version-control/what-are-gitlab-flow-best-practices/
1 change: 1 addition & 0 deletions apps/recommendation/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reco_fastapi
8 changes: 0 additions & 8 deletions apps/recommendation/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions apps/recommendation/api/.coveragerc

This file was deleted.

7 changes: 0 additions & 7 deletions apps/recommendation/api/.dockerignore

This file was deleted.

19 changes: 10 additions & 9 deletions apps/recommendation/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM python:3.7-slim
FROM python:3.9-slim

ENV PYTHONUNBUFFERED True

ENV APP_HOME /app
WORKDIR $APP_HOME
COPY src/app.py ./
COPY api-requirements.txt ./

COPY src/pcreco/ ./pcreco/

RUN pip install -r api-requirements.txt

CMD exec gunicorn --bind :$PORT --workers 1 --threads 10 --preload --timeout 0 app:app
# Install libraries
COPY ./requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Copy local code to the container
COPY ./src .
COPY ./src/huggy ./huggy
EXPOSE 8080
CMD exec gunicorn -k uvicorn.workers.UvicornWorker --bind :8080 --workers 1 --threads 10 --preload --timeout 0 main:app
131 changes: 0 additions & 131 deletions apps/recommendation/api/README.md

This file was deleted.

Empty file.
19 changes: 0 additions & 19 deletions apps/recommendation/api/api-dev-requirements.txt

This file was deleted.

16 changes: 0 additions & 16 deletions apps/recommendation/api/api-requirements.txt

This file was deleted.

File renamed without changes.
9 changes: 4 additions & 5 deletions apps/recommendation/api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ version: "3.7"

services:
testdb:
image: kartoza/postgis:12.4
ports:
image: postgis/postgis:12-3.3
container_name: testdb
ports:
- "${DATA_GCP_TEST_POSTGRES_PORT}:5432"
environment:
- POSTGRES_PASS=postgres
- POSTGRES_USER=postgres
- POSTGRES_DBNAME=db
- POSTGRES_PASSWORD=postgres
Loading

0 comments on commit c2458aa

Please sign in to comment.