Skip to content

Commit a729850

Browse files
author
Mauko Quiroga
committed
Update readme & circle
1 parent addf465 commit a729850

File tree

3 files changed

+137
-61
lines changed

3 files changed

+137
-61
lines changed

.circleci/config.yml

Lines changed: 105 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
version: 2
22
jobs:
3-
run_tests:
3+
check_version:
4+
docker:
5+
- image: python:3.7
6+
7+
steps:
8+
- checkout
9+
10+
- run:
11+
name: Check version number has been properly updated
12+
command: |
13+
git fetch
14+
.circleci/is-version-number-acceptable.sh
15+
16+
install:
417
docker:
518
- image: python:3.7
619

@@ -24,26 +37,84 @@ jobs:
2437
# pip install --editable git+https://github.com/openfisca/country-template.git@BRANCH_NAME#egg=OpenFisca-Country-Template # use a specific branch of OpenFisca-Country-Template
2538
# pip install --editable git+https://github.com/openfisca/extension-template.git@BRANCH_NAME#egg=OpenFisca-Extension-Template # use a specific branch of OpenFisca-Extension-Template
2639
40+
- run:
41+
name: Delete compiled python files
42+
command: make clean
43+
44+
- run:
45+
name: Compile python files to check for syntax errors
46+
command: make check-syntax-errors
47+
2748
- save_cache:
2849
key: v1-py3-{{ .Branch }}-{{ checksum "setup.py" }}
2950
paths:
3051
- /tmp/venv/openfisca_core
3152

53+
lint_style:
54+
docker:
55+
- image: python:3.7
56+
57+
steps:
58+
- checkout
59+
60+
- restore_cache:
61+
key: v1-py3-{{ .Branch }}-{{ checksum "setup.py" }}
62+
63+
- run:
64+
name: Activate virtualenv
65+
command: echo "source /tmp/venv/openfisca_core/bin/activate" >> $BASH_ENV
66+
67+
- run:
68+
name: Lint style
69+
command: make lint-style
70+
71+
lint_types:
72+
docker:
73+
- image: python:3.7
74+
75+
steps:
76+
- checkout
77+
78+
- restore_cache:
79+
key: v1-py3-{{ .Branch }}-{{ checksum "setup.py" }}
80+
81+
- run:
82+
name: Activate virtualenv
83+
command: echo "source /tmp/venv/openfisca_core/bin/activate" >> $BASH_ENV
84+
85+
- run:
86+
name: Lint types
87+
command: make lint-types
88+
89+
- run:
90+
name: Lint NumPy typing against latest 3 minor versions
91+
command: for i in {1..3}; do VERSION=$(.circleci/get-numpy-version.py prev) && pip install numpy==$VERSION && make lint-types; done
92+
93+
test_code:
94+
docker:
95+
- image: python:3.7
96+
97+
steps:
98+
- checkout
99+
100+
- restore_cache:
101+
key: v1-py3-{{ .Branch }}-{{ checksum "setup.py" }}
102+
32103
- run:
33-
name: Run Core tests
34-
command: env PYTEST_ADDOPTS="--exitfirst" make test
104+
name: Activate virtualenv
105+
command: echo "source /tmp/venv/openfisca_core/bin/activate" >> $BASH_ENV
35106

36107
- run:
37-
name: Check NumPy typing against latest 3 minor versions
38-
command: for i in {1..3}; do VERSION=$(.circleci/get-numpy-version.py prev) && pip install numpy==$VERSION && make check-types; done
108+
name: Run core & web-api tests
109+
command: PYTEST_ADDOPTS="--exitfirst" make test-code
39110

40111
- persist_to_workspace:
41112
root: .
42113
paths:
43114
- .coverage
44115

45116
- run:
46-
name: Run Country Template tests
117+
name: Run country template tests
47118
command: |
48119
COUNTRY_TEMPLATE_PATH=`python -c "import openfisca_country_template; print(openfisca_country_template.CountryTaxBenefitSystem().get_package_metadata()['location'])"`
49120
openfisca test $COUNTRY_TEMPLATE_PATH/openfisca_country_template/tests/
@@ -85,20 +156,6 @@ jobs:
85156
name: Run doc tests
86157
command: make test-doc-build
87158

88-
89-
check_version:
90-
docker:
91-
- image: python:3.7
92-
93-
steps:
94-
- checkout
95-
96-
- run:
97-
name: Check version number has been properly updated
98-
command: |
99-
git fetch
100-
.circleci/is-version-number-acceptable.sh
101-
102159
submit_coverage:
103160
docker:
104161
- image: python:3.7
@@ -112,10 +169,13 @@ jobs:
112169
- restore_cache:
113170
key: v1-py3-{{ .Branch }}-{{ checksum "setup.py" }}
114171

172+
- run:
173+
name: Activate virtualenv
174+
command: echo "source /tmp/venv/openfisca_core/bin/activate" >> $BASH_ENV
175+
115176
- run:
116177
name: Submit coverage to Coveralls
117178
command: |
118-
source /tmp/venv/openfisca_core/bin/activate
119179
pip install coveralls
120180
coveralls
121181
@@ -127,6 +187,7 @@ jobs:
127187
deploy:
128188
docker:
129189
- image: python:3.7
190+
130191
environment:
131192
PYPI_USERNAME: openfisca-bot
132193
# PYPI_PASSWORD: this value is set in CircleCI's web interface; do not set it here, it is a secret!
@@ -137,15 +198,17 @@ jobs:
137198
- restore_cache:
138199
key: v1-py3-{{ .Branch }}-{{ checksum "setup.py" }}
139200

201+
- run:
202+
name: Activate virtualenv
203+
command: echo "source /tmp/venv/openfisca_core/bin/activate" >> $BASH_ENV
204+
140205
- run:
141206
name: Check for functional changes
142207
command: if ! .circleci/has-functional-changes.sh ; then circleci step halt ; fi
143208

144209
- run:
145210
name: Upload a Python package to Pypi
146-
command: |
147-
source /tmp/venv/openfisca_core/bin/activate
148-
.circleci/publish-python-package.sh
211+
command: .circleci/publish-python-package.sh
149212

150213
- run:
151214
name: Publish a git tag
@@ -160,17 +223,30 @@ workflows:
160223
version: 2
161224
build_and_deploy:
162225
jobs:
163-
- run_tests
164-
- test_docs
165226
- check_version
227+
- install
228+
- lint_style:
229+
requires:
230+
- install
231+
- lint_types:
232+
requires:
233+
- install
234+
- test_code:
235+
requires:
236+
- install
237+
- test_docs:
238+
requires:
239+
- install
166240
- submit_coverage:
167241
requires:
168-
- run_tests
242+
- test_code
169243
- deploy:
170244
requires:
171-
- run_tests
172-
- test_docs
173245
- check_version
246+
- lint_style
247+
- lint_types
248+
- test_code
249+
- test_docs
174250
filters:
175251
branches:
176252
only: master

Makefile

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ branch = $(shell git branch --show-current)
66
all: test
77

88
## Run tests, type and style linters.
9-
test: clean check-syntax-errors test-python test-types test-style test-doc
9+
test: clean check-syntax-errors lint-style lint-types test-code test-doc
1010

1111
## Install project dependencies.
1212
install:
@@ -39,47 +39,47 @@ check-syntax-errors: .
3939
@$(call help,$@:)
4040
@python -m compileall -q $?
4141

42-
## Run openfisca-core tests.
43-
test-python:
42+
## Run linters to check for syntax and style errors.
43+
lint-style: \
44+
lint-style-all \
45+
lint-style-doc-commons \
46+
lint-style-doc-entities \
47+
lint-style-doc-types \
48+
;
49+
50+
## Run linters to check for syntax and style errors.
51+
lint-style-all:
4452
@$(call help,$@:)
45-
@PYTEST_ADDOPTS="${PYTEST_ADDOPTS}" pytest --cov=openfisca_core --cov=openfisca_web_api
53+
@flake8 `git ls-files | grep "\.py$$"`
54+
55+
## Run linters to check for syntax and style errors.
56+
lint-style-doc-%:
57+
@$(call help,$@:)
58+
@flake8 --select=D101,D102,D103,DAR openfisca_core/$*
59+
@pylint --enable=classes,exceptions,imports,miscellaneous,refactoring --disable=W0201,W0231 openfisca_core/$*
4660

4761
## Run static type checkers for type errors.
48-
test-types: \
49-
test-types-all \
50-
test-types-strict-commons \
51-
test-types-strict-entities \
52-
test-types-strict-types \
62+
lint-types: \
63+
lint-types-all \
64+
lint-types-strict-commons \
65+
lint-types-strict-entities \
66+
lint-types-strict-types \
5367
;
5468

5569
## Run static type checkers for type errors.
56-
test-types-all:
70+
lint-types-all:
5771
@$(call help,$@:)
5872
@mypy --package openfisca_core --package openfisca_web_api
5973

6074
## Run static type checkers for type errors.
61-
test-types-strict-%:
75+
lint-types-strict-%:
6276
@$(call help,$@:)
6377
@mypy --cache-dir .mypy_cache-openfisca_core.$* --implicit-reexport --strict --package openfisca_core.$*
6478

65-
## Run linters to check for syntax and style errors.
66-
test-style: \
67-
test-style-all \
68-
test-style-doc-commons \
69-
test-style-doc-entities \
70-
test-style-doc-types \
71-
;
72-
73-
## Run linters to check for syntax and style errors.
74-
test-style-all:
79+
## Run openfisca core & web-api tests.
80+
test-code:
7581
@$(call help,$@:)
76-
@flake8 `git ls-files | grep "\.py$$"`
77-
78-
## Run linters to check for syntax and style errors.
79-
test-style-doc-%:
80-
@$(call help,$@:)
81-
@flake8 --select=D101,D102,D103,DAR openfisca_core/$*
82-
@pylint --enable=classes,exceptions,imports,miscellaneous,refactoring --disable=W0201,W0231 openfisca_core/$*
82+
@PYTEST_ADDOPTS="${PYTEST_ADDOPTS}" pytest --cov=openfisca_core --cov=openfisca_web_api
8383

8484
## Check that the current changes do not break the doc.
8585
test-doc:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ make test
4545
To run all the tests defined on a test file:
4646

4747
```sh
48-
pytest tests/core/test_parameters.py
48+
openfisca test tests/core/test_parameters.py
4949
```
5050

5151
To run a single test:
5252

5353
```sh
54-
pytest tests/core/test_parameters.py -k test_parameter_for_period
54+
PYTEST_ADDOPTS="$PYTEST_ADDOPTS -k test_parameter_for_period" openfisca test tests/core/test_parameters.py
5555
```
5656

5757
## Types
@@ -63,7 +63,7 @@ As NumPy introduced the `typing` module in 1.20.0, to ensure type hints do not b
6363
Type checking is already run with `make test`. To run the type checker alone:
6464

6565
```sh
66-
make check-types
66+
make lint-types
6767
```
6868

6969
## Style
@@ -73,7 +73,7 @@ This repository adheres to a [certain coding style](STYLEGUIDE.md), and we invit
7373
Style checking is already run with `make test`. To run the style checker alone:
7474

7575
```sh
76-
make check-style
76+
make lint-style
7777
```
7878

7979
To automatically style-format your code changes:

0 commit comments

Comments
 (0)