Skip to content

Commit 471318f

Browse files
authored
Add a readme (#1)
Add a readme describing how to set up the library, as well as set up services for CI, code coverage and code quality
1 parent 28ebcb7 commit 471318f

File tree

4 files changed

+112
-38
lines changed

4 files changed

+112
-38
lines changed

.circleci/config.yml

+8-38
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,15 @@ run_pytest: &run_pytest
66
name: install
77
command: |
88
source venv/bin/activate
9+
pip install pytest coverage pytest-cov codecov
910
pip install -e .[test]
1011
- run:
1112
name: test
1213
command: |
1314
source venv/bin/activate
1415
mkdir -p test-report/pytest
15-
py.test --cov=coecms --cov-report xml \
16-
--junit-xml=test-report/pytest/sqlite.xml --junit-prefix='sqlite'
17-
- run:
18-
name: coverage-collect
19-
command: |
20-
mkdir coverage
21-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > cc-test-reporter
22-
chmod +x cc-test-reporter
23-
./cc-test-reporter format-coverage --output "coverage/coverage.${CIRCLE_STAGE}.json"
24-
cat "coverage/coverage.${CIRCLE_STAGE}.json"
25-
- store_test_results:
26-
path: test-report
27-
- store_artifacts:
28-
path: test-report
29-
- persist_to_workspace:
30-
root: coverage
31-
paths:
32-
- coverage.*.json
16+
py.test --cov=coecms --cov-report xml
17+
codecov
3318
3419
run_conda: &run_conda
3520
docker:
@@ -44,12 +29,13 @@ run_conda: &run_conda
4429
- run:
4530
name: setup
4631
command: |
47-
~/miniconda/bin/conda install --yes conda-build anaconda-client
32+
~/miniconda/bin/conda install --yes conda-build conda-verify anaconda-client
4833
~/miniconda/bin/conda config --system --add channels conda-forge
4934
- run:
5035
name: build
5136
command: |
52-
~/miniconda/bin/conda build conda/
37+
source ~/miniconda/bin/activate root
38+
~/miniconda/bin/conda build --python=${PYTHON_VER} -c conda-forge conda/
5339
5440
version: 2
5541

@@ -63,21 +49,9 @@ jobs:
6349
- image: circleci/python:3
6450
<<: *run_pytest
6551
conda3:
52+
environment:
53+
PYTHON_VER=3
6654
<<: *run_conda
67-
coverage-report:
68-
docker:
69-
- image: circleci/python
70-
steps:
71-
- attach_workspace:
72-
at: workspace
73-
- run:
74-
name: coverage-report
75-
command: |
76-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > cc-test-reporter
77-
chmod +x cc-test-reporter
78-
./cc-test-reporter sum-coverage --parts 2 workspace/coverage.*.json -o coverage.json
79-
./cc-test-reporter upload-coverage --input coverage.json
80-
cat coverage.json
8155

8256
workflows:
8357
version: 2
@@ -86,7 +60,3 @@ workflows:
8660
- python2
8761
- python3
8862
- conda3
89-
- coverage-report:
90-
requires:
91-
- python2
92-
- python3

README.rst

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
CLEX CMS Utility Library
2+
========================
3+
4+
.. image:: https://img.shields.io/readthedocs/coecms-util/stable.svg
5+
:target: https://coecms-util.readthedocs.io
6+
.. image:: https://img.shields.io/circleci/project/github/coecms/coecms-util.svg
7+
:target: https://circleci.com/gh/coecms/coecms-util/tree/master
8+
.. image:: https://img.shields.io/codecov/c/github/coecms/coecms-util.svg
9+
:target: https://codecov.io/gh/coecms/coecms-util
10+
.. image:: https://img.shields.io/codacy/grade/3706e7a283fd439fa8b8d2f707f814e4.svg
11+
:target: https://www.codacy.com/app/ScottWales/coecms-util
12+
.. image:: https://img.shields.io/conda/v/coecms/coecms-util.svg
13+
:target: https://anaconda.org/coecms/coecms-util
14+
15+
Development
16+
-----------
17+
18+
To add to the repository, first create your own fork on Github at https://github.com/coecms/coecms-util/fork, then download new forked repository (either to Raijin or your own computer)
19+
20+
Create and activate a new conda environment so you can work on the library without affecting your other environments, then install the library in development mode using ``pip``::
21+
22+
# # On Raijin/VDI only:
23+
# module use /g/data3/hh5/public/modules
24+
# module load conda
25+
26+
# This creates an environment named 'coecms'
27+
conda env create -f conda/dev-environment.yml
28+
29+
conda activate coecms
30+
31+
# '-e' installs in editable mode
32+
pip install -e .
33+
34+
You can then run the tests to confirm everything is working correctly using::
35+
36+
py.test
37+
38+
Making Changes
39+
--------------
40+
41+
Changes need to be done in a new branch as a pull request::
42+
43+
git checkout -b my-branch
44+
45+
# Make changes...
46+
47+
git push --set-upstream origin my-branch
48+
49+
Then make a pull request at https://github.com/coecms/coecms-util/pull/new
50+
51+
Please make sure code changes include tests and documentation
52+
53+
Changes must be reviewed by someone in the CMS team before they are committed to master
54+
55+
Adding Dependencies
56+
-------------------
57+
58+
To add a dependency, you need to edit two files:
59+
60+
* conda/meta.yaml: This has the conda package names of dependencies. They might not be the same as the actual Python library names. This is used by `conda build` to create the conda package. Add dependencies to the ``requirements: run:`` list.
61+
62+
* setup.py: This has the Python name of dependencies. This is used if you `pip install` the package locally for testing. Add dependencies to the ``install_requires`` list.
63+
64+
Creating new versions
65+
---------------------
66+
67+
To create a new version of the library, use the Github interface at https://github.com/coecms/coecms-util/releases/new
68+
69+
Versions should be named like ``v1.2.3``, using `semantic versioning <https://semver.org/>`_.
70+
71+
The Python and Conda packages will automatically set their version based on the tag that Github creates (you may need to ``git fetch`` the tag first)
72+
73+
To upload a new version to conda, check out the tag (e.g. ``git checkout v1.2.3``) then run::
74+
75+
conda build --user coecms --python=3.7 ./conda
76+
77+
setting the python version as desired (you will need to be a member of the coecms group on https://anaconda.org to do this)
File renamed without changes.

conda/meta.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package:
2+
name: coecms-util
3+
version: {{ GIT_DESCRIBE_TAG }}
4+
5+
source:
6+
git_url: ../
7+
8+
build:
9+
number: {{ GIT_DESCRIBE_NUMBER }}
10+
script: python setup.py install --single-version-externally-managed --record=record.txt
11+
12+
requirements:
13+
build:
14+
- python
15+
run:
16+
- python
17+
18+
test:
19+
requires:
20+
- pytest
21+
source_files:
22+
- setup.cfg
23+
- test
24+
commands:
25+
- py.test
26+
imports:
27+
- coecms

0 commit comments

Comments
 (0)