Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint YAML files #1039

Merged
merged 16 commits into from
Jul 24, 2018
Merged

Lint YAML files #1039

merged 16 commits into from
Jul 24, 2018

Conversation

guillett
Copy link
Member

  • Amélioration technique.
  • Détails :
    • Ajout d'un linter pour les fichiers YAML

@guillett
Copy link
Member Author

Cette PR est une étape vers la normalisation des fichiers YAML. Il y a des warnings non bloquants pour cette PR mais à traiter avant de pouvoir manipuler systématiquement les fichiers YAML.

@guillett guillett requested review from fpagnoux and Anna-Livia July 13, 2018 14:40
guillett added 7 commits July 13, 2018 16:43
* Required to pass ruamel.yaml roundtrip test
* ' false' 840 matches across 259 files
* ' False' 84 matches across 20 files
* ' true' 500 matches across 276 files
* ' True' 186 matches across 24 files
Copy link
Contributor

@Anna-Livia Anna-Livia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on the linting !
I would add a make lint that would run yamllint on test and parameter.

@@ -23,19 +23,24 @@ jobs:
name: Install dependencies
command: |
pip install --upgrade pip twine wheel
pip install --editable .[test] --upgrade
pip install --editable .[test,lint] --upgrade
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put the linter with the test dependencies ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour apporter de la granularité aux niveaux des dépendances.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dans quel cas concret cette granularité est-elle souhaitable?
Le package yamllint est-il connu pour être difficile à installer dans certains environnements?
S'agit-il d'un package très lourd qui ralentit significativement l'installation?

Un linter me paraît être typiquement une dépendance de développement, au même titre que nose ou flake8. S'il n'y a pas de raison particulière, je suis pour qu'on le mette dans test, avec les autres dépendances de dev.

(Il y a déjà bien trop d'extra-dépendances sur France.)

# pip install --editable git+https://github.com/openfisca/openfisca-core.git@BRANCH_NAME#egg=OpenFisca-Core # use a specific branch of OpenFisca-Core

- save_cache:
key: v1-py2-{{ checksum "setup.py" }}
paths:
- /tmp/venv/openfisca_france

- run:
name: Lint YAML files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, why not put it in the run test part ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and why not run the linter on all yaml files (expecially the parameters ?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it seems to me that a test with a unvalid yaml fails with openfisca-run-test. Is this to fail faster ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Un linter (comme flake8) fait plus que détecter les erreurs de syntaxe, il impose aussi des bonnes pratiques et une consistence qui permettent d'avoir un code plus propre.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les règles de gestion du yamllintme paraissent trop "relaxées" pour jouer ce rôle de bonne pratiques. C'est pour cela que je posait la question que peut être il était surtout utilisait comme validateur.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Anna-Livia je ne comprends pas ta remarque, as-tu un lien vers CircleCI ?

Copy link
Member Author

@guillett guillett Jul 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contrairement à ce qu'on peut passer circleci tests glob "**/*.yaml" correspond à ls **/*.yaml et non pas ls tests/**/*/yaml. L'outil fourni par CircleCI est initialement fait pour les tests ; c'est de là que vient le préfix circleci tests dans les commandes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'espérais que cette PR soit mergée dans la semaine et itérer sur une nouvelle base cette semaine. yamllint génére aujourd'hui beaucoup d'avertissements qui restent à être gérés. Une fois les modifications nécessaires apportées aux fichiers YAML les problèmes de format généreront des erreurs et non plus des avertissements.

- run:
name: Run tests
command: |
nosetests `circleci tests glob "tests/**/*.py" | circleci tests split`
openfisca-run-test `circleci tests glob "tests/**/*.{yaml,yml}" | circleci tests split`
openfisca-run-test `circleci tests glob "tests/**/*.yaml" | circleci tests split`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it me or do we not pass flake8 on circle ci ? (cc @fpagnoux )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas sur OpenFisca-France. Personne n'a eu la motivation/volonté pour ajuster la configuration flake et corriger les 3644 erreurs flake présentes aujourd'hui.

- run:
name: Run tests
command: |
nosetests `circleci tests glob "tests/**/*.py" | circleci tests split`
openfisca-run-test `circleci tests glob "tests/**/*.{yaml,yml}" | circleci tests split`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quel avantage à ne plus gérer les fichiers avec une extension .yml ? Il n'y a pas un risque qu'un contributeur en créé un par accident?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'oublie toujours la forme que doit prendre l'expression régulière qui effectue un OU.
Ne pas gérer les deux c'est simplifier.

Copy link
Member

@fpagnoux fpagnoux Jul 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le risque qu'un contributeur créé un fichier de test en .yml et que ça ne soit pas détecté à la revue (qui regarde les extensions?) me paraît loin d'être anecdotique.

La simplification de cette ligne, plutôt compréhensible à la lecture, me paraît un gain léger comparé aux problèmes que pourraient poser la présence de tests non exécutés.

@Anna-Livia
Copy link
Contributor

Anna-Livia commented Jul 17, 2018

Pour info, en faisant passer le script de performance (et en augmentant la standard deviationà 13 (la denière PR sur France qui augmente le nombre de test) à augmenté sensiblemement le temps d'exécution ) donne ceci :

python  openfisca_france/scripts/performance_tests/test_circleci_builds.py 2209 2208 

WARNING:root:The master branch has 13 builds available for analysis.
INFO:root:current build = 314555.5 ; mean is = 230761.61538461538
This build makes the test performance more than 13% worst : 36.31188162542698%

@guillett
Copy link
Member Author

Merci @Anna-Livia et @fpagnoux pour vos commentaires.
Pouvez-vous signaler vos remarques bloquantes :)

Copy link
Member

@fpagnoux fpagnoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Points bloquants pour moi:

  • Retrait du support des fichiers .yml
  • Ajout d'une extra dépendance

@guillett guillett requested a review from fpagnoux July 23, 2018 19:17
@guillett guillett merged commit e8ddf14 into master Jul 24, 2018
@guillett guillett deleted the lint branch July 24, 2018 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants