Skip to content

Commit 0dc498b

Browse files
Rodrigo AlmeidaSRM
andauthored
Add CI/CD in Github Actions (#451)
* Add linting with flake8, black & isort - Remove python-env from tox.ini files, use gh-actions matrix for running different python versions - Define tox runs as `tox -e [lint/format/flake8/test]` * Change basepython to python3 from python3.9. Add test run with tox. * Add python3.10 to the github runner matrix * Use ubuntu-small osgeo container - Tested github-actions locally using act. - osgeo ubuntu-large images are 1.4 GB in size, takes some time to run this locally - Replacing this with ubuntu-small runs it faster with no side effects * Add release Actions workflow (#449) * Uncomment tox * Update job name to test * Add release workflow only on main and with tag * Fix flake8 (#450) * lint is flake8 * Remove - in order to not ignore exit code * Add extended ignores for flake8 * Rm unused vars * Remove extra # * Rm unused var * Add rio-cogeo dependency * Fix undefined variable, ignore ambigous name * Rm flake8 * Fix unused imports F401 * Remove - * Add cv2 dependencies * Format * Check if formatting passes * Move black/isort/flake8 config to setup.cfg * Add pre-commit config with isort, balck and flake8 * Add pre-commit dep Co-authored-by: SRM <soumya@developmentseed.org>
1 parent ec4e0ef commit 0dc498b

File tree

29 files changed

+125
-75
lines changed

29 files changed

+125
-75
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release Python package
2+
3+
on:
4+
workflow_run:
5+
workflows: [tests]
6+
branches: [main]
7+
types: [completed]
8+
9+
jobs:
10+
release:
11+
needs: test
12+
runs-on: ubuntu-latest
13+
name: Release package to PyPi
14+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
15+
steps:
16+
- uses: actions/checkout@master
17+
- name: Set up Python 3.8
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: 3.8
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
python -m pip install tox tox-gh-actions
25+
- name: Build and release 📦 to PyPI
26+
with:
27+
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
29+
run: |
30+
tox -e release
31+

.github/workflows/tests.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ on:
44
- push
55

66
jobs:
7-
build:
7+
test:
88
runs-on: ubuntu-latest
99
name: Docker | GDAL=${{ matrix.gdal-version }} | python=${{ matrix.python-version }}
10-
container: osgeo/gdal:ubuntu-full-${{ matrix.gdal-version }}
10+
container: osgeo/gdal:ubuntu-small-${{ matrix.gdal-version }}
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.8", "3.9"]
14+
python-version: ["3.8", "3.9", "3.10"]
1515
gdal-version: ["3.4.0", "3.3.3"]
1616
include:
1717
- python-version: "3.8"
@@ -38,10 +38,16 @@ jobs:
3838
python${{ matrix.python-version }}-dev \
3939
python${{ matrix.python-version }}-venv \
4040
python3-pip \
41-
g++
41+
g++ \
42+
libgl1
4243
- name: Install dependencies
4344
run: |
4445
python -m pip install --upgrade pip
45-
python -m pip install tox tox-gh-actions
46+
python -m pip install tox
47+
- name: Lint with tox
48+
run: tox -e lint
49+
- name: Format with tox
50+
run: tox -e format
4651
- name: Test with tox
47-
run: tox
52+
run: tox -e test
53+

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/pycqa/isort
3+
rev: 5.10.1
4+
hooks:
5+
- id: isort
6+
- repo: https://github.com/ambv/black
7+
rev: 22.1.0
8+
hooks:
9+
- id: black
10+
language_version: python3.9
11+
- repo: https://gitlab.com/pycqa/flake8
12+
rev: 3.9.2
13+
hooks:
14+
- id: flake8

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import sys
1515

1616
sys.path.insert(0, os.path.abspath(".."))
17-
import numpy as np
17+
import numpy as np # noqa: F401
1818
import sphinx_bootstrap_theme
1919

2020
# -- Project information -----------------------------------------------------
@@ -25,7 +25,7 @@
2525
license = "MIT"
2626
import time
2727

28-
copyright = u"2018-{}, CosmiQ Works: an IQT Lab".format(time.strftime("%Y"))
28+
copyright = "2018-{}, CosmiQ Works: an IQT Lab".format(time.strftime("%Y"))
2929

3030
# The full version, including alpha/beta/rc tags
3131
release = "0.0.1"

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ pytest
2222
tox
2323
isort
2424
flake8
25+
pre-commit

setup.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[flake8]
2+
extend-ignore =
3+
E203, # whitespace before ':'
4+
E501, # line too long
5+
C901, # is too complex
6+
E402, # module level import not at top of file (for docs)
7+
E741, # ambiguous variable name
8+
9+
exclude =
10+
.git,
11+
__pycache__,
12+
docs/source/conf.py,
13+
old,
14+
build,
15+
dist,
16+
.tox
17+
max-line-length = 88
18+
max-complexity = 10
19+
count=true
20+
21+
[isort]
22+
profile = black
23+
24+
[black]
25+
line-length = 88
26+
target-version = ['py37', 'py38', 'py39', 'py310']
27+
experimental_string_processing = true

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def check_output(cmd):
5252
"pyproj>=2.1",
5353
"PyYAML>=5.4",
5454
"rasterio>=1.0.23",
55+
"rio-cogeo>=3.0.2",
5556
"requests==2.22.0",
5657
"rtree>=0.9.3",
5758
"scikit-image>=0.16.2",
@@ -79,7 +80,7 @@ def check_output(cmd):
7980
"Programming Language :: Python :: 3.10",
8081
"Topic :: Scientific/Engineering :: GIS",
8182
],
82-
author=u"Ryan Avery",
83+
author="Ryan Avery",
8384
author_email="ryan@developmentseed.org",
8485
url="https://github.com/CosmiQ/solaris",
8586
license="MIT",

solaris/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import data, utils, vector
1+
from . import data, utils, vector # noqa: F401
22

33
# data, eval, preproc, raster, tile, have gdal in them need to replace with rasterio
44
__version__ = "0.0.1"

solaris/eval/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from . import base, iou, pixel, vector
1+
from . import base, iou, pixel, vector # noqa: F401

solaris/eval/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ def eval_iou_spacenet_csv(
111111
scoring_dict_list = []
112112
self.ground_truth_GDF[iou_field] = 0.0
113113
iou_index = self.ground_truth_GDF.columns.get_loc(iou_field)
114-
id_cols = 2
115-
ground_truth_ids = self.ground_truth_GDF.iloc[:, :id_cols]
116114

117115
for imageID in tqdm(imageIDList):
118116
self.ground_truth_GDF_Edit = self.ground_truth_GDF[

0 commit comments

Comments
 (0)