Skip to content

Commit 2c636f4

Browse files
committed
feat(72): Checking style in CI
Checking for style correctness in CI. This is done for every PR. job `lint` has been added and is a required job for all build.
1 parent 7a15696 commit 2c636f4

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

.circleci/config.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ commands:
4545
type: string
4646
default: "7"
4747
description: "Pytest version to use for testing"
48+
add_specific_requirements:
49+
type: string
50+
default: ""
51+
description: "Add specific requirements listed in a file to the environment. "
4852
extra_deps:
4953
type: string
5054
default: ""
51-
description: "Extra dependencies to install"
55+
description: "Extra dependencies to install (given as a space separated string)"
5256
channels:
5357
type: string
5458
default: "https://conda.anaconda.org/conda-forge"
@@ -75,6 +79,10 @@ commands:
7579
echo $dep >> requirements.txt
7680
done
7781
fi
82+
cat "" >> requirements.txt
83+
if [ "<< parameters.add_specific_requirements >>" != "" ]; then
84+
cat "<< parameters.add_specific_requirements >>" >> requirements.txt
85+
fi
7886
- run:
7987
name: "Create environment"
8088
command: |
@@ -107,6 +115,27 @@ commands:
107115
micromamba install -n project -y python=<< parameters.python >> $requirements -c $channels
108116
micromamba install -n project -y << parameters.extra_deps >> -c $channels
109117
118+
lint-project:
119+
description: "Check code style"
120+
steps:
121+
- run:
122+
name: "Check formatting (black)"
123+
command: |
124+
eval "$(micromamba shell hook --shell=bash)"
125+
micromamba activate project
126+
black .
127+
- run:
128+
name: "Check code style (flake8)"
129+
command: |
130+
eval "$(micromamba shell hook --shell=bash)"
131+
micromamba activate project
132+
flake8 .
133+
- run:
134+
name: "Check import order (isort)"
135+
command: |
136+
eval "$(micromamba shell hook --shell=bash)"
137+
micromamba activate project
138+
isort .
110139
test-project:
111140
description: "Run all the test and store the results"
112141
parameters:
@@ -164,10 +193,13 @@ commands:
164193
workflows:
165194
PR:
166195
jobs:
196+
- lint
167197
- build:
168198
matrix: *build-matrix
169199
name: "build-py<< matrix.python >>-pytest << matrix.pytest >>"
170200
filters: *PR-only
201+
requires:
202+
- lint
171203

172204
deploy:
173205
jobs:
@@ -186,6 +218,12 @@ workflows:
186218

187219

188220
jobs:
221+
lint:
222+
docker: *image
223+
steps:
224+
- make-env:
225+
add_specific_requirements: requirements.dev.txt
226+
- lint-project
189227
build:
190228
docker: *image
191229
parameters:

requirements.dev.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
black
22
isort
3-
flake8==6.0.0
4-
flake8-builtins==2.1.0
5-
flake8-simplify==0.19.3
6-
flake8-comprehensions==3.10.1
7-
flake8-pytest-style==1.6.0
8-
flake8-return==1.2.0
9-
flake8-no-pep-420==2.3.0
10-
flake8-pyprojecttoml==0.0.2
11-
flake8-debugger==4.1.2
12-
flake8-simplify==0.19.3
3+
flake8=6.0.0
4+
flake8-builtins=2.1.0
5+
flake8-simplify=0.19.3
6+
flake8-comprehensions=3.10.1
7+
flake8-pytest-style=1.6.0
8+
flake8-return=1.2.0
9+
flake8-no-pep420=2.7.0
10+
flake8-pyproject=1.2.3
11+
flake8-simplify=0.19.3

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ psutil>=5.1.0
22
memory_profiler>=0.58
33
pytest
44
requests
5+
black
6+
isort

0 commit comments

Comments
 (0)