Skip to content

Commit 26211fb

Browse files
authored
Merge pull request #39 from kristinazvolanek/switch_ci
Update CircleCI configuration, add pre-commit
2 parents 772ab8e + 14e11bb commit 26211fb

File tree

9 files changed

+232
-202
lines changed

9 files changed

+232
-202
lines changed

.circleci/config.yml

Lines changed: 88 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,200 +1,123 @@
1-
# Python CircleCI 2.1 configuration file
2-
#
3-
#
4-
#
1+
# Use the latest 2.1 version of CircleCI pipeline process engine.
2+
# See: https://circleci.com/docs/2.0/configuration-reference
53
version: 2.1
6-
orbs:
7-
codecov: codecov/[email protected]
8-
jobs:
94

10-
makeenv_37:
11-
docker:
12-
- image: continuumio/miniconda3
13-
working_directory: /tmp/src/phys2denoise
14-
steps:
15-
- checkout
16-
- persist_to_workspace:
17-
root: /tmp
18-
paths:
19-
- src/phys2denoise
20-
- restore_cache:
21-
key: conda-py37-v1-{{ checksum "setup.cfg" }}
22-
- run:
23-
name: Generate environment
24-
command: |
25-
if [[ -e /opt/conda/envs/py36_env ]]; then
26-
echo "Restoring environment from cache"
27-
source activate phys2denoise_py37
28-
else
29-
conda create -yq -n phys2denoise_py37 python=3.7
30-
source activate phys2denoise_py37
31-
pip install -e ".[test,doc]"
32-
fi
33-
- save_cache:
34-
key: conda-py37-v1-{{ checksum "setup.cfg" }}
35-
paths:
36-
- /opt/conda/envs/phys2denoise_py37
37-
38-
unittest_36:
39-
docker:
40-
- image: continuumio/miniconda3
41-
working_directory: /tmp/src/phys2denoise
42-
steps:
43-
- checkout
44-
- restore_cache:
45-
key: conda-py36-v1-{{ checksum "setup.cfg" }}
46-
- run:
47-
name: Generate environment
48-
command: |
49-
apt-get install -yqq make
50-
if [ ! -d /opt/conda/envs/phys2denoise_py36 ]; then
51-
conda create -yq -n phys2denoise_py36 python=3.6
52-
source activate phys2denoise_py36
53-
pip install -e ".[test]"
54-
fi
55-
- run:
56-
name: Running unit tests
57-
command: |
58-
source activate phys2denoise_py36
59-
make unittest
60-
mkdir /tmp/src/coverage
61-
mv /tmp/src/phys2denoise/.coverage /tmp/src/coverage/.coverage.py36
62-
- save_cache:
63-
key: conda-py36-v1-{{ checksum "setup.cfg" }}
64-
paths:
65-
- /opt/conda/envs/phys2denoise_py36
66-
- persist_to_workspace:
67-
root: /tmp
68-
paths:
69-
- src/coverage/.coverage.py36
70-
71-
unittest_37:
72-
docker:
73-
- image: continuumio/miniconda3
74-
working_directory: /tmp/src/phys2denoise
75-
steps:
76-
- checkout
77-
- restore_cache:
78-
key: conda-py37-v1-{{ checksum "setup.cfg" }}
79-
- run:
80-
name: Running unit tests
81-
command: |
82-
apt-get install -y make
83-
source activate phys2denoise_py37 # depends on makeenv_37
84-
make unittest
85-
mkdir /tmp/src/coverage
86-
mv /tmp/src/phys2denoise/.coverage /tmp/src/coverage/.coverage.py37
87-
- persist_to_workspace:
88-
root: /tmp
89-
paths:
90-
- src/coverage/.coverage.py37
5+
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
6+
# See: https://circleci.com/docs/2.0/orb-intro/
7+
orbs:
8+
# The python orb contains a set of prepackaged CircleCI configuration you can use repeatedly in your configuration files
9+
# Orb commands and jobs help you with common scripting around a language/tool
10+
# so you dont have to copy and paste it everywhere.
11+
# See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python
12+
python: circleci/[email protected]
13+
codecov: codecov/[email protected]
9114

92-
integrationtest_36:
15+
# Define a job to be invoked later in a workflow.
16+
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
17+
jobs:
18+
test37: # This is the name of the job, feel free to change it to better match what you're trying to do!
19+
# These next lines defines a Docker executors: https://circleci.com/docs/2.0/executor-types/
20+
# You can specify an image from Dockerhub or use one of the convenience images from CircleCI's Developer Hub
21+
# A list of available CircleCI Docker convenience images are available here: https://circleci.com/developer/images/image/cimg/python
22+
# The executor is the environment in which the steps below will be executed - below will use a python 3.6.14 container
23+
# Change the version below to your required version of python
9324
docker:
94-
- image: continuumio/miniconda3
25+
- image: cimg/python:3.7
9526
working_directory: /tmp/src/phys2denoise
27+
resource_class: medium
28+
# Checkout the code as the first step. This is a dedicated CircleCI step.
29+
# The python orb's install-packages step will install the dependencies from a Pipfile via Pipenv by default.
30+
# Here we're making sure we use just use the system-wide pip. By default it uses the project root's requirements.txt.
31+
# Then run your tests!
32+
# CircleCI will report the results back to your VCS provider.
9633
steps:
9734
- checkout
98-
- restore_cache:
99-
key: conda-py36-v1-{{ checksum "setup.cfg" }}
35+
# Install Pillow first to avoid jpsg and zlib issues
36+
- python/install-packages:
37+
path-args: .[test]
38+
pypi-cache: false
39+
venv-cache: false
40+
pkg-manager: pip-dist
41+
# app-dir: ~/project/package-directory/ # If you're requirements.txt isn't in the root directory.
42+
# pip-dependency-file: test-requirements.txt # if you have a different name for your requirements file, maybe one that combines your runtime and test requirements.
10043
- run:
101-
name: Generate environment
44+
name: Run tests
45+
# This assumes pytest is installed via the install-package step above
10246
command: |
103-
apt-get install -yqq make
104-
if [ ! -d /opt/conda/envs/phys2denoise_py36 ]; then
105-
conda create -yq -n phys2denoise_py36 python=3.6
106-
source activate phys2denoise_py36
107-
pip install -e ".[test]"
108-
fi
109-
- run:
110-
name: Run integration tests
111-
no_output_timeout: 10m
112-
command: |
113-
source activate phys2denoise_py36
114-
make integration
47+
pytest --cov=./phys2denoise
11548
mkdir /tmp/src/coverage
116-
mv /tmp/src/phys2denoise/.coverage /tmp/src/coverage/.coverage.integration36
49+
mv ./.coverage /tmp/src/coverage/.coverage.py37
11750
- store_artifacts:
118-
path: /tmp/data
51+
path: /tmp/src/coverage
52+
# Persist the specified paths (workspace/echo-output) into the workspace for use in downstream job.
11953
- persist_to_workspace:
54+
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
55+
# taken to be the root directory of the workspace.
12056
root: /tmp
57+
# Must be relative path from root
12158
paths:
122-
- src/coverage/.coverage.integration36
59+
- src/coverage/.coverage.py37
12360

124-
integrationtest_37:
61+
test310:
12562
docker:
126-
- image: continuumio/miniconda3
63+
- image: cimg/python:3.10
12764
working_directory: /tmp/src/phys2denoise
65+
resource_class: medium
12866
steps:
12967
- checkout
130-
- restore_cache:
131-
key: conda-py37-v1-{{ checksum "setup.cfg" }}
68+
- python/install-packages:
69+
path-args: .[test]
70+
pypi-cache: false
71+
venv-cache: false
72+
pkg-manager: pip-dist
13273
- run:
133-
name: Run integration tests
134-
no_output_timeout: 10m
74+
name: Run tests
13575
command: |
136-
apt-get install -yqq make
137-
source activate phys2denoise_py37 # depends on makeenv_37
138-
make integration
76+
pytest --cov=./phys2denoise
13977
mkdir /tmp/src/coverage
140-
mv /tmp/src/phys2denoise/.coverage /tmp/src/coverage/.coverage.integration37
78+
mv ./.coverage /tmp/src/coverage/.coverage.py310
14179
- store_artifacts:
142-
path: /tmp/data
80+
path: /tmp/src/coverage
14381
- persist_to_workspace:
14482
root: /tmp
14583
paths:
146-
- src/coverage/.coverage.integration37
84+
- src/coverage/.coverage.py310
14785

14886
style_check:
14987
docker:
150-
- image: continuumio/miniconda3
88+
- image: cimg/python:3.7
15189
working_directory: /tmp/src/phys2denoise
90+
resource_class: small
15291
steps:
15392
- checkout
154-
- restore_cache:
155-
key: conda-py37-v1-{{ checksum "setup.cfg" }}
93+
- python/install-packages:
94+
path-args: .[style]
95+
pypi-cache: false
96+
venv-cache: false
97+
pkg-manager: pip-dist
15698
- run:
157-
name: Style check
158-
command: |
159-
apt-get install -yqq make
160-
source activate phys2denoise_py37 # depends on makeenv37
161-
make lint
162-
- store_artifacts:
163-
path: /tmp/data/lint
164-
165-
build_docs:
166-
working_directory: /tmp/src/phys2denoise
167-
docker:
168-
- image: continuumio/miniconda3
169-
steps:
170-
- attach_workspace: # get phys2denoise
171-
at: /tmp
172-
- restore_cache: # load environment
173-
key: conda-py37-v1-{{ checksum "setup.cfg" }}
174-
- run:
175-
name: Build documentation
176-
command: |
177-
apt-get install -yqq make
178-
source activate phys2denoise_py37 # depends on makeenv_37
179-
make -C docs html
180-
- store_artifacts:
181-
path: /tmp/src/phys2denoise/docs/_build/html
99+
name: Check style
100+
command: echo "Skipping for now" # |
101+
# isort --check .
102+
# black --check phys2denoise
103+
# flake8 ./phys2denoise
182104

183105
merge_coverage:
184106
working_directory: /tmp/src/phys2denoise
185107
docker:
186-
- image: continuumio/miniconda3
108+
- image: cimg/python:3.10
109+
resource_class: small
187110
steps:
188111
- attach_workspace:
189112
at: /tmp
190113
- checkout
191-
- restore_cache:
192-
key: conda-py37-v1-{{ checksum "setup.cfg" }}
114+
- python/install-packages:
115+
args: coverage
116+
pkg-manager: pip-dist
193117
- run:
194118
name: Merge coverage files
195119
command: |
196-
apt-get install -yqq curl
197-
source activate phys2denoise_py37 # depends on makeenv37
120+
sudo apt update && sudo apt install curl
198121
cd /tmp/src/coverage/
199122
coverage combine
200123
coverage xml
@@ -203,14 +126,20 @@ jobs:
203126
- codecov/upload:
204127
file: /tmp/src/coverage/coverage.xml
205128

129+
# Invoke jobs via workflows
130+
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
206131
workflows:
207-
version: 2.1
208-
build_test:
132+
build_test: # This is the name of the workflow, feel free to change it to better match your workflow.
133+
# Inside the workflow, you define the jobs you want to run.
209134
jobs:
210-
- makeenv_37
211-
- style_check:
135+
- style_check
136+
- test37:
212137
requires:
213-
- makeenv_37
214-
- merge_coverage:
138+
- style_check
139+
- test310:
215140
requires:
216141
- style_check
142+
- merge_coverage:
143+
requires:
144+
- test37
145+
- test310

.coveragerc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[run]
2+
omit =
3+
docs/*
4+
tests/*
5+
_version.py
6+
__init__.py
7+
**/__init__.py
8+
due.py
9+
.*rc
10+
versioneer.py
11+
setup.py
12+
phys2denoise/tests/*
13+
phys2denoise/_version.py
14+
phys2denoise/__init__.py
15+
phys2denoise/**/__init__.py
16+
phys2denoise/due.py
17+
phys2denoise/.*rc
18+
phys2denoise/versioneer.py
19+
phys2denoise/setup.py

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- id: check-case-conflict
12+
- id: check-merge-conflict
13+
- repo: https://github.com/psf/black
14+
rev: 22.10.0
15+
hooks:
16+
- id: black
17+
- repo: https://github.com/pycqa/isort
18+
rev: 5.10.1
19+
hooks:
20+
- id: isort
21+
- repo: https://github.com/pycqa/flake8
22+
rev: 6.0.0
23+
hooks:
24+
- id: flake8
25+
- repo: https://github.com/pycqa/pydocstyle
26+
rev: 6.1.1
27+
hooks:
28+
- id: pydocstyle
29+
- repo: https://github.com/pre-commit/pygrep-hooks
30+
rev: v1.9.0
31+
hooks:
32+
- id: rst-backticks
33+
- id: rst-directive-colons
34+
- id: rst-inline-touching-normal

.readthedocs.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
# Required
66
version: 2
77

8+
build:
9+
os: "ubuntu-20.04"
10+
tools:
11+
python: "3.7"
12+
813
# Build documentation in the docs/ directory with Sphinx
914
sphinx:
1015
configuration: docs/conf.py
1116

1217
python:
13-
version: 3.7
1418
install:
1519
- method: pip
1620
path: .
1721
extra_requirements:
1822
- doc
19-
system_packages: true
23+
system_packages: true

0 commit comments

Comments
 (0)