diff --git a/.circleci/config.yml b/.circleci/config.yml index 65c7cc31f5..ba46b4e1b1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,7 @@ # CircleCI 2.0 configuration file. See . version: 2 jobs: - build: - parallelism: 2 # Speed up the tests, while letting two containers available for other builds. + install: docker: - image: python:3.7 @@ -21,27 +20,72 @@ jobs: - run: name: Install dependencies - command: | - make build - # pip install --editable git+https://github.com/openfisca/openfisca-core.git@BRANCH_NAME#egg=OpenFisca-Core # use a specific branch of OpenFisca-Core + command: make install + + # - run: + # name: Use a specific branch of OpenFisca-Core for testing purposes + # command: pip install --editable git+https://github.com/openfisca/openfisca-core.git@BRANCH_NAME#egg=OpenFisca-Core - save_cache: key: v1-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} paths: - /tmp/venv/openfisca_france + lint_files: + docker: + - image: python:3.7 + + steps: + - checkout + + - restore_cache: + key: v1-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} + + - run: + name: Activate virtualenv + command: echo "source /tmp/venv/openfisca_france/bin/activate" >> $BASH_ENV + + - run: make check-syntax-errors + + - run: make check-style + + - run: + name: Lint Python files + command: .circleci/lint-changed-python-files.sh + + - run: + name: Lint YAML tests + command: .circleci/lint-changed-yaml-tests.sh + + build: + docker: + - image: python:3.7 + + steps: + - checkout + + - restore_cache: + key: v1-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} + + - run: + name: Activate virtualenv + command: echo "source /tmp/venv/openfisca_france/bin/activate" >> $BASH_ENV + + - run: + name: Build package + command: make build + + - save_cache: + key: v2-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} + paths: + - /tmp/venv/openfisca_france + - save_cache: key: v1-py3-build-{{ .Revision }} paths: - dist - - run: - name: Run tests - command: | - pytest `circleci tests glob "tests/**/[^_]*.py" | circleci tests split` - openfisca test `circleci tests glob "tests/**/*.{yaml,yml}" | circleci tests split` - - lint_yaml_files: + test_python: # Python tests are separated from YAML tests, because the latter take longer. This allows Python tests to use any other available container and yield it, once finished, to another job instead of relying only on the two containers assigned to the YAML tests. docker: - image: python:3.7 @@ -49,19 +93,18 @@ jobs: - checkout - restore_cache: - key: v1-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} + key: v2-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} - run: name: Activate virtualenv - command: | - echo "source /tmp/venv/openfisca_france/bin/activate" >> $BASH_ENV + command: echo "source /tmp/venv/openfisca_france/bin/activate" >> $BASH_ENV - run: - name: Lint files - command: | - .circleci/lint-changed-yaml-tests.sh + name: Run Python tests + command: pytest `circleci tests glob "tests/**/[^_]*.py"` - lint_python_files: + test_yaml: + parallelism: 2 # Speed up the yaml tests, while letting two containers available for other jobs. docker: - image: python:3.7 @@ -69,18 +112,15 @@ jobs: - checkout - restore_cache: - key: v1-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} + key: v2-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} - run: name: Activate virtualenv - command: | - echo "source /tmp/venv/openfisca_france/bin/activate" >> $BASH_ENV + command: echo "source /tmp/venv/openfisca_france/bin/activate" >> $BASH_ENV - run: - name: Lint files - command: | - make check-syntax-errors check-style - .circleci/lint-changed-python-files.sh + name: Run YAML tests + command: openfisca test `circleci tests glob "tests/**/*.{yaml,yml}" | circleci tests split` test_api: docker: @@ -90,7 +130,7 @@ jobs: - checkout - restore_cache: - key: v1-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} + key: v2-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} - run: name: Activate virtualenv @@ -99,8 +139,7 @@ jobs: - run: name: Test the Web API - command: | - .circleci/test-api.sh + command: .circleci/test-api.sh check_version_and_changelog: docker: @@ -126,7 +165,7 @@ jobs: - checkout - restore_cache: - key: v1-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} + key: v2-py3-deps-{{ .Branch }}-{{ checksum "setup.py" }} - restore_cache: key: v1-py3-build-{{ .Revision }} @@ -153,24 +192,31 @@ workflows: version: 2 build_and_deploy: jobs: - - check_version_and_changelog - - build - - test_api: + - install + - lint_files: + requires: + - install + - build: + requires: + - install + - test_python: requires: - build - - lint_yaml_files: + - test_yaml: requires: - build - - lint_python_files: + - test_api: requires: - build + - check_version_and_changelog: + requires: + - lint_files + - test_python + - test_yaml + - test_api - deploy: requires: - check_version_and_changelog - - build - - test_api - - lint_yaml_files - - lint_python_files filters: branches: only: master diff --git a/.circleci/lint-changed-python-files.sh b/.circleci/lint-changed-python-files.sh index a1be79cf0a..72d8aad639 100755 --- a/.circleci/lint-changed-python-files.sh +++ b/.circleci/lint-changed-python-files.sh @@ -4,8 +4,8 @@ last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-pa if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "*.py") then - echo "Hello boss, I'm linting the following changed files:" + echo "Linting the following Python files:" echo $changes flake8 $changes -else echo "Could't find changed files, come visit again!" +else echo "No changed Python files to lint" fi diff --git a/.circleci/lint-changed-yaml-tests.sh b/.circleci/lint-changed-yaml-tests.sh index b23451f810..16e99432b6 100755 --- a/.circleci/lint-changed-yaml-tests.sh +++ b/.circleci/lint-changed-yaml-tests.sh @@ -4,8 +4,8 @@ last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-pa if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "tests/*.yaml") then - echo "Hello boss, I'm linting the following changed files:" + echo "Linting the following changed YAML tests:" echo $changes yamllint $changes -else echo "Could't find changed files, come visit again!" +else echo "No changed YAML tests to lint" fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 06bd05cc29..7abc914ac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +### 72.1.2 [#1650](https://github.com/openfisca/openfisca-france/pull/1650) + +* Amélioration technique. +* Zones impactées : configuration de l'intégration continue. +* Détails : + - Sépare les jobs `test_python` et `test_yaml` du `build`. + - Sépare le job `install` du job `build`. + - Regroupe les deux jobs `lint_python_files` et `lint_yaml_files` dans un seul job. + - Rend le job `check-version-and-changelog` dépendant de tous les autres jobs. + ## 72.1.1 [#1657](https://github.com/openfisca/openfisca-france/pull/1657) * Changement mineur. diff --git a/setup.py b/setup.py index 7bd47260ac..4e2d44899e 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name = "OpenFisca-France", - version = "72.1.1", + version = "72.1.2", author = "OpenFisca Team", author_email = "contact@openfisca.fr", classifiers = [