-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1002 from MTES-MCT/build-only-changed-projects
Test only changed projects
- Loading branch information
Showing
18 changed files
with
3,407 additions
and
411 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
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 |
---|---|---|
|
@@ -26,6 +26,8 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
lerna-debug.log | ||
|
||
# Misc | ||
.DS_Store | ||
|
||
|
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 |
---|---|---|
|
@@ -2,136 +2,114 @@ | |
|
||
[Fiche produit](https://beta.gouv.fr/startups/zero-logement-vacant.html) | ||
|
||
## Développement | ||
## Getting started en 5 minutes | ||
|
||
### Prérequis | ||
|
||
* node | ||
* npm | ||
* serveur Postgres (sur macOS, possible d'utiliser [postgresapp](https://postgresapp.com>)) | ||
* commande psql dans le PATH (pour le chargement des données) | ||
* serveur mail (par exemple [mailDev](https://github.com/maildev/maildev)) | ||
|
||
### Base de données | ||
|
||
Créer une base de données vide pour l'application (par exemple `zlv`) et une autre pour les tests (par exemple `test_zlv`). | ||
|
||
La création des tables et autres structures SQL se fera automatiquement lors du lancement de l'application via les migrations [KnexJS](http://knexjs.org/#Migrations) contenues dans le répertoire `/database/migrations` | ||
|
||
### Installation de Postgres avec Docker | ||
|
||
Voici comment lancer Postgres avec l'extension PostGIS dans un conteneur Docker sur votre machine locale avec Docker: | ||
### Installation de l'application | ||
|
||
```bash | ||
docker run --name zlv-postgres -e POSTGRES_PASSWORD=zlv -p 5432:5432 -d postgis/postgis | ||
``` | ||
|
||
### Installation de mailDev avec Docker | ||
|
||
MailDev est un outil de test SMTP simple pour les développeurs. Il permet de capturer et de visualiser les emails envoyés pendant le développement d'applications sans avoir besoin de les envoyer à un serveur de mail réel. Voici comment lancer MailDev dans un conteneur Docker sur votre machine locale avec Docker: | ||
git clone https://github.com/MTES-MCT/zero-logement-vacant.git | ||
|
||
```bash | ||
docker run -p 1080:1080 -p 1025:1025 maildev/maildev | ||
cd zero-logement-vacant && yarn | ||
``` | ||
|
||
Les emails seront consultables sur `http://0.0.0.0:1080/#/` | ||
### Lancement des dépendances | ||
|
||
#### Avec Docker compose | ||
Pour lancer les services, migrer et remplir la base de données en une seule | ||
commande : | ||
|
||
Nous utilisons Docker Compose pour configurer et lancer trois services essentiels : une base de données PostgreSQL avec l'extension PostGIS, un service de mail pour le développement avec MailDev, ainsi qu'Adminer, un outil de gestion de base de données via une interface web. Voici comment déployer ce conteneur en local: | ||
|
||
```bash | ||
cd .docker | ||
|
||
DATABASE_URL=postgres://postgres@postgres@localhost/zlv bash setup.sh | ||
```shell | ||
export DEV_DB=postgres://postgres:postgres@localhost/dev | ||
export TEST_DB=postgres://postgres:postgres@localhost/test | ||
bash .docker/setup.sh | ||
``` | ||
|
||
### Installation de l'application | ||
Lancer **tous les services** : | ||
|
||
```bash | ||
git clone https://github.com/MTES-MCT/zero-logement-vacant.git | ||
```shell | ||
docker compose -f .docker/docker-compose.yml up -d | ||
``` | ||
|
||
cd zero-logement-vacant | ||
npm i | ||
Lancer **un service spécifique** : | ||
|
||
cd frontend | ||
npm i | ||
```shell | ||
docker compose -f .docker/docker-compose.yml up -d <service> | ||
``` | ||
|
||
### Variables d'environnement | ||
|
||
Pour configurer votre environnement, commencez par créer un fichier nommé `.env` au sein du dossier `zero-logement-vacant`, en prenant exemple sur le contenu de `.env.example`. | ||
|
||
Vous avez également la possibilité de personnaliser les valeurs des variables d'environnement déjà définies dans le fichier `/server/utils/config.ts` en les ajustant dans ce même fichier `.env`. | ||
|
||
De plus, créez un fichier .env dans le sous-dossier `zero-logement-vacant/frontend`, en vous référant à nouveau à `zero-logement-vacant/frontend/.env.example` pour guider sa structure. | ||
Chaque application peut définir ses propres variables d’environnement. | ||
Des exemples sont disponibles comme ici pour l’API : [server/.env.example](server/.env.example). | ||
|
||
### Chargement des données | ||
|
||
**Développement / Staging** | ||
|
||
Si vous avez choisi de ne pas charger les données via `docker compose`, vous | ||
pouvez les charger manuellement : | ||
|
||
```bash | ||
yarn run migrate | ||
cd src/infra/database/scripts | ||
psql [DATABASE_URL] -f 001-load-establishments_com_epci_reg_dep.sql -v filePath=../data/common/com_epci_dep_reg.csv | ||
psql [DATABASE_URL] -f 002-load-establishments_direction_territoriale.sql -v filePath=../data/common/direction_territoriale.csv | ||
psql [DATABASE_URL] -f 003-load-establishment_kinds.sql -v filePath=../data/common/nature_juridique.csv | ||
psql [DATABASE_URL] -f 004-load-data.sql -v filePath=../data/dummy/dummy_data.csv -v dateFormat="'MM/DD/YY'" | ||
psql [DATABASE_URL] -f 006-load-locality-taxes.sql -v filePath=../data/common/taxe.csv | ||
npm run seed | ||
yarn workspace @zerologementvacant/server migrate | ||
yarn workspace @zerologementvacant/server seed | ||
``` | ||
|
||
**Note :** vous pouvez définir la variable d’environnement `DATABASE_URL` | ||
pour utiliser une base de données spécifique. | ||
Sinon une base de donnée locale sera utilisée par défaut. | ||
La base de données **doit exister**. | ||
|
||
Permet le chargement de données minimales pour faire fonctionner l'application avec des données anonymisées pour les collectivités suivantes : | ||
|
||
- Eurométropole de Strasbourg | ||
- CA Saint-Lô Agglo | ||
|
||
et trois utilisateurs dont les mots de passes sont partagés sur https://vaultwarden.incubateur.net/: | ||
|
||
- [email protected] => utilisateur avec des droits pour Eurométropole de Strasbourg | ||
- [email protected] => utilisateur avec des droits pour Saint-Lô | ||
- [email protected] => utilisateur avec des droits d'administration | ||
- [email protected] => utilisateur lecture seule France entière | ||
|
||
**Production** | ||
|
||
Le chargement des données se fait à partir de fichier d'extractions de données au format csv. | ||
|
||
```bash | ||
cd database/scripts | ||
psql [DATABASE_URL] -f 001-load-establishments_com_epci_reg_dep.sql -v filePath=../data/common/com_epci_dep_reg.csv | ||
psql [DATABASE_URL] -f 002-load-establishments_direction_territoriale.sql -v filePath=../data/common/direction_territoriale.csv | ||
psql [DATABASE_URL] -f 003-load-establishment_kinds.sql -v filePath=../data/common/nature_juridique.csv | ||
psql [DATABASE_URL] -f 004-load-data.sql -v filePath=[DATA_CSV_FILE] -v dateFormat=[DATE_FORMAT] | ||
psql [DATABASE_URL] -f 005-load-buildings.sql -v filePath=[BUILDING_CSV_FILE] | ||
psql [DATABASE_URL] -f 006-load-locality-taxes.sql -v filePath=../data/common/taxe.csv | ||
npm run seed | ||
``` | ||
|
||
### Lancement de l'application en local | ||
|
||
```bash | ||
npm run start-local | ||
Chaque application peut être lancée indépendamment. | ||
|
||
```shell | ||
yarn workspace @zerologementvacant/front dev # localhost:3000 | ||
yarn workspace @zerologementvacant/server dev # localhost:3001/api | ||
``` | ||
|
||
L'application est accessible à l'adresse sur <http://localhost:3000> et il est possible de se connecter avec l'un des trois comptes utilisateurs cités plus haut. | ||
|
||
### Lancement des tests | ||
|
||
**Frontend** | ||
Lancer tous les tests : | ||
|
||
```bash | ||
npm run frontend:test | ||
```shell | ||
yarn test | ||
``` | ||
|
||
**Backend** | ||
Lancer les tests d’un workspace en particulier : | ||
|
||
```bash | ||
npm run test | ||
```shell | ||
# Avec yarn | ||
yarn workspace <workspace> test | ||
# Avec lerna | ||
yarn lerna run test --scope <workspace> [--include-dependents] | ||
|
||
# Exemple | ||
yarn workspace @zerologementvacant/server test | ||
yarn lerna run test --scope @zerologementvacant/server --include-dependents | ||
yarn test --scope @zerologementvacant/server --include-dependents | ||
# yarn test == yarn lerna run test | ||
``` | ||
|
||
La commande échoue si le package ne comporte pas de commande `test`, ou si un | ||
test échoue. | ||
|
||
## Démo | ||
|
||
La version de démo de l'application est accessible à l'adresse <https://zerologementvacant-staging.incubateur.net> | ||
|
||
## Production | ||
|
||
La version de production de l'application est accessible à l'adresse <https://zerologementvacant.beta.gouv.fr> | ||
La version de production de l'application est accessible à l'adresse <https://zerologementvacant.beta.gouv.fr> |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"version": "0.0.1", | ||
"npmClient": "yarn" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"references": [{ "path": "../utils/tsconfig.build.json" }], | ||
"exclude": ["node_modules", "dist", "src/**/*.test.ts"] | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"name": "@zerologementvacant/models", | ||
"version": "0.0.1", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
|
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
Oops, something went wrong.