Skip to content

Commit 675d12b

Browse files
authored
ci(linting): Initial GitHub actions for linting (#954)
Reformat code using black with 79 character line length. Initial GitHub action uses miniconda and has first cut at running autotests on GitHub actions.
1 parent 49b4aa2 commit 675d12b

File tree

208 files changed

+47393
-25171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+47393
-25171
lines changed

.flake8

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ignore =
1515
E126, # continuation line over-indented for hanging indent
1616
E127, # continuation line over-indented for visual indent
1717
E128, # continuation line under-indented for visual indent
18+
E203, # whitespace before
1819
E221, # multiple spaces before operator
1920
E222, # multiple spaces after operator
2021
E226, # missing whitespace around arithmetic operator
@@ -24,10 +25,13 @@ ignore =
2425
E501, # line too long (> 79 characters)
2526
E502, # backslash is redundant between brackets
2627
E722, # do not use bare 'except'
28+
E741, # ambiguous variable name
2729
W291, # trailing whitespace
2830
W292, # no newline at end of file
2931
W293, # blank line contains whitespace
3032
W391, # blank line at end of file
3133
W503, # line break before binary operator
32-
W504 # line break after binary operator
34+
W504, # line break after binary operator
35+
W605 # invalid escape sequence
36+
3337
statistics = True

.github/workflows/ci.yml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: flopy continuous integration
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
9+
flopy_lint:
10+
name: linting
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
steps:
15+
16+
# check out repo
17+
- name: Checkout flopy repo
18+
uses: actions/checkout@v2
19+
20+
# Standard python fails on windows without GDAL installation. Using
21+
# standard python here since only linting on linux.
22+
# Use standard bash shell with standard python
23+
- name: Setup Python 3.8
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.8
27+
28+
- name: Print python version
29+
shell: bash
30+
run: |
31+
python --version
32+
33+
- name: Install Python 3.8 packages
34+
shell: bash
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -r requirements.pip.txt
38+
39+
- name: Run black
40+
shell: bash
41+
run: |
42+
echo "if black check fails run"
43+
echo " black --line-length 79 ./flopy"
44+
echo "and then commit the changes."
45+
black --check --line-length 79 ./flopy
46+
47+
- name: Run flake8
48+
shell: bash
49+
run: |
50+
flake8 --count --show-source --exit-zero ./flopy
51+
52+
- name: Run pylint
53+
shell: bash
54+
run: |
55+
pylint --jobs=2 --errors-only --exit-zero ./flopy
56+
57+
flopyScriptNotebookCI:
58+
name: additional tests
59+
needs: flopy_lint
60+
runs-on: ubuntu-latest
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
test-file: [autotest_notebooks.py, autotest_scripts.py]
65+
steps:
66+
# check out repo
67+
- name: Checkout flopy repo
68+
uses: actions/checkout@v2
69+
70+
# Standard python fails on windows without GDAL installation
71+
# Using custom bash shell ("shell: bash -l {0}") with Miniconda
72+
- name: Setup Miniconda
73+
uses: goanpeca/setup-miniconda@v1.6.0
74+
with:
75+
python-version: 3.8
76+
activate-environment: flopy
77+
auto-update-conda: true
78+
environment-file: environment.yml
79+
80+
- name: Determine python environment
81+
shell: bash -l {0}
82+
run: |
83+
conda info
84+
conda list
85+
86+
- name: Install additional Python 3.8 packages
87+
if: matrix.test-file == 'autotest_notebooks.py'
88+
shell: bash -l {0}
89+
run: |
90+
conda install nbconvert jupyter
91+
92+
- name: Install xmipy, pymake, and flopy
93+
shell: bash -l {0}
94+
run: |
95+
pip install xmipy
96+
pip install .
97+
pip install https://github.com/modflowpy/pymake/zipball/master
98+
99+
- name: Download executables needed for tests
100+
shell: bash -l {0}
101+
run: |
102+
python ./autotest/get_exes.py
103+
104+
- name: Add executables directory to path
105+
shell: bash
106+
run: |
107+
echo "::add-path::$HOME/.local/bin"
108+
109+
- name: Run ${{ matrix.test-file }} CI
110+
shell: bash -l {0}
111+
run: |
112+
coverage run -m nose -v ${{ matrix.test-file }} --with-id --with-timer \
113+
--with-coverage --cover-package=flopy --cover-xml \
114+
--cover-xml-file=../coverage.xml -w ./autotest
115+
116+
- name: List files in the root directory
117+
shell: bash
118+
run: |
119+
ls -l
120+
121+
- name: Upload coverage to Codecov
122+
uses: codecov/codecov-action@v1.0.12
123+
with:
124+
file: ./coverage.xml
125+
126+
flopyCI:
127+
name: autotests
128+
needs: flopy_lint
129+
runs-on: ${{ matrix.os }}
130+
strategy:
131+
fail-fast: false
132+
matrix:
133+
python-version: [3.8, 3.7, 3.6]
134+
os: [ubuntu-latest, macos-latest, windows-latest]
135+
136+
steps:
137+
# check out repo
138+
- name: Checkout flopy repo
139+
uses: actions/checkout@v2
140+
141+
# Standard python fails on windows without GDAL installation
142+
# Using custom bash shell ("shell: bash -l {0}") with Miniconda
143+
- name: Setup Miniconda
144+
uses: goanpeca/setup-miniconda@v1.6.0
145+
with:
146+
python-version: ${{ matrix.python-version }}
147+
activate-environment: flopy
148+
auto-update-conda: true
149+
environment-file: environment.yml
150+
151+
- name: Determine python environment
152+
shell: bash -l {0}
153+
run: |
154+
conda info
155+
conda list
156+
157+
- name: Install xmipy, pymake, and flopy
158+
shell: bash -l {0}
159+
run: |
160+
pip install xmipy
161+
pip install .
162+
pip install https://github.com/modflowpy/pymake/zipball/master
163+
164+
- name: Download executables needed for tests
165+
shell: bash -l {0}
166+
run: |
167+
python ./autotest/get_exes.py
168+
169+
- name: Add executables directory to path
170+
shell: bash
171+
run: |
172+
echo "::add-path::$HOME/.local/bin"
173+
174+
- name: Run nosetests
175+
shell: bash -l {0}
176+
run: |
177+
coverage run -m nose -v --with-id --with-timer \
178+
--with-coverage --cover-package=flopy --cover-xml \
179+
--cover-xml-file=../coverage.xml -w ./autotest
180+
181+
- name: List files in the root directory
182+
shell: bash
183+
run: |
184+
ls -l
185+
186+
- name: Upload coverage to Codecov
187+
uses: codecov/codecov-action@v1.0.12
188+
with:
189+
file: ./coverage.xml

0 commit comments

Comments
 (0)