Skip to content

Commit 398bcdc

Browse files
Adds github actions build process (#79)
1 parent dc261a0 commit 398bcdc

File tree

5 files changed

+139
-44
lines changed

5 files changed

+139
-44
lines changed

Diff for: .github/workflows/release.yaml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: build
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- synchronize
7+
push:
8+
tags:
9+
- 'v[0-9]+.[0-9]+.[0-9]+*'
10+
11+
jobs:
12+
13+
test-suite:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
python-version: [3.6, 3.7, 3.8]
18+
os: [ubuntu-latest, macos-latest]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python ${{ matrix.python-version }} ${{ matrix.os }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements.txt
30+
pip install -r tests/requirements.txt
31+
- name: Test with pytest
32+
run: |
33+
pytest
34+
35+
36+
release:
37+
needs:
38+
- test-suite
39+
if: startsWith(github.ref, 'refs/tags/')
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v2
43+
- name: Create Release
44+
id: create_release
45+
uses: actions/create-release@v1
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
tag_name: ${{ github.ref }}
50+
release_name: Release ${{ github.ref }}
51+
draft: false
52+
prerelease: false
53+
54+
55+
deploy:
56+
needs:
57+
- release
58+
if: startsWith(github.ref, 'refs/tags/')
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- uses: actions/checkout@v2
63+
- name: Set up Python
64+
uses: actions/setup-python@v2
65+
with:
66+
python-version: '3.8'
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install setuptools wheel
71+
- name: Build and publish
72+
run: |
73+
python setup.py sdist bdist_wheel
74+
- name: Publish package
75+
uses: pypa/gh-action-pypi-publish@master
76+
with:
77+
user: __token__
78+
password: ${{ secrets.PYPI_DEPLOYMENT_TOKEN }}

Diff for: README.md

+12-21
Original file line numberDiff line numberDiff line change
@@ -87,36 +87,27 @@ Aside from basic unit tests, the test suite is configured to use [pyflakes](http
8787

8888
Note that the test suite has additional dependencies that must be installed for them to successfully run: `pip install -r tests/requirements.txt`.
8989

90-
## Documentation
91-
92-
The project documentation is written in reStructuredText and is built using Sphinx, which also includes the docstring documentation from the `btrdb` Python package. For your convenience, the `Makefile` includes a target for building the documentation:
93-
94-
$ make html
95-
96-
This will build the HTML documentation in `docs/build`, which can be viewed using `open docs/build/index.html`. Other formats (PDF, epub, etc) can be built using `docs/Makefile`. The documentation is automatically built when pushed to GitHub and hosted on [Read The Docs](https://btrdb.readthedocs.io/en/latest/).
90+
## Releases
9791

98-
Note that the documentation also requires Sphix and other dependencies to successfully build: `pip install -r docs/requirements.txt`.
99-
100-
## Branches / Git Workflow
92+
This codebase uses github actions to control the release process. To create a new release of the software, run `release.sh` with arguments for the new version as shown below. Make sure you are in the master branch when running this script.
10193

102-
When working on this codebase, keep in mind that the project is set up in a typical production/release/development cycle as described in _[A Successful Git Branching Model](http://nvie.com/posts/a-successful-git-branching-model/)_. A typical workflow is as follows:
94+
```
95+
./release.sh 5 11 4
96+
```
10397

104-
1. Select an issue from the [issues page](https://github.com/BTrDB/btrdb-python/issues) - preferably one that is "ready" then move it to "in-progress" using labels or just comment that you are working on it.
98+
This will tag and push the current commit and github actions will run the test suite, build the package, and push it to pypi. If any issues are encountered with the automated tests, the build will fail and you will have a tag with no corresponding release.
10599

106-
2. Create a branch off of develop called "feature-[feature name]", work and commit into that branch.
100+
After a release is created, you can manually edit the release description through github.
107101

108-
~$ git checkout -b feature-myfeature develop
102+
## Documentation
109103

110-
3. Once you are done working (and everything is tested) merge your feature into develop.
104+
The project documentation is written in reStructuredText and is built using Sphinx, which also includes the docstring documentation from the `btrdb` Python package. For your convenience, the `Makefile` includes a target for building the documentation:
111105

112-
~$ git checkout develop
113-
~$ git merge --no-ff feature-myfeature
114-
~$ git branch -d feature-myfeature
115-
~$ git push origin develop
106+
$ make html
116107

117-
4. Repeat. Releases will be routinely pushed into master via release branches, then deployed to the server.
108+
This will build the HTML documentation locally in `docs/build`, which can be viewed using `open docs/build/index.html`. Other formats (PDF, epub, etc) can be built using `docs/Makefile`. The documentation is automatically built on every GitHub release and hosted on [Read The Docs](https://btrdb.readthedocs.io/en/latest/).
118109

119-
Note that this process may change with the next major release of BTrDB with development moving to version branches and develop/integration branches from each version branch.
110+
Note that the documentation also requires Sphix and other dependencies to successfully build: `pip install -r docs/requirements.txt`.
120111

121112
## Versioning
122113

Diff for: btrdb/version.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@
1515
## Module Info
1616
##########################################################################
1717

18-
__version_info__ = {
19-
'major': 5,
20-
'minor': 10,
21-
'micro': 0,
22-
'releaselevel': 'final',
23-
'serial': 15,
24-
}
18+
__version_info__ = { 'major': 5, 'minor': 10, 'micro': 2, 'releaselevel': 'final'}
2519

2620
##########################################################################
2721
## Helper Functions
@@ -36,6 +30,5 @@ def get_version(short=False):
3630
if __version_info__['micro']:
3731
vers.append(".%(micro)i" % __version_info__)
3832
if __version_info__['releaselevel'] != 'final' and not short:
39-
vers.append('%s%i' % (__version_info__['releaselevel'][0],
40-
__version_info__['serial']))
33+
vers.append('%s%i' % (__version_info__['releaselevel'][0]))
4134
return ''.join(vers)

Diff for: release.sh

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# helper function used to promot the user for how they would like to proceed
6+
function checkYN {
7+
while true
8+
do
9+
read -p "$1 (Y/N): " action
10+
case $action in
11+
n|N|no)
12+
return 1
13+
;;
14+
y|Y|yes)
15+
return 0
16+
;;
17+
*)
18+
echo "type Y or N"
19+
;;
20+
esac
21+
done
22+
}
23+
24+
if [[ "$1" == "" ]]
25+
then
26+
echo "Missing version e.g 5 11 2"
27+
echo -e "\nUsage:\n ./release.sh 5 11 2 \n"
28+
exit 1
29+
fi
30+
31+
if ! checkYN "Add new release 'v$1.$2.$3'?"; then
32+
echo exiting
33+
exit 1
34+
fi
35+
36+
echo "Setting version to v$1.$2.$3"
37+
38+
VERION_CODE="__version_info__ = { 'major': $1, 'minor': $2, 'micro': $3, 'releaselevel': 'final'}"
39+
sed -i "s/^__version_info__.*$/${VERION_CODE}/g" btrdb/version.py
40+
41+
git add btrdb/version.py
42+
git commit -m "Release v$1.$2.$3"
43+
git tag v$1.$2.$3
44+
git push origin v$1.$2.$3
45+
46+
sleep 10
47+
git push

Diff for: tests/btrdb/test_base.py

-14
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,11 @@
2222
from btrdb import connect, __version__, BTRDB_ENDPOINTS, BTRDB_API_KEY
2323
from btrdb.exceptions import ConnectionError
2424

25-
##########################################################################
26-
## Test Constants
27-
##########################################################################
28-
29-
EXPECTED_VERSION = "5.10"
30-
3125

3226
##########################################################################
3327
## Initialization Tests
3428
##########################################################################
3529

36-
class TestPackage(object):
37-
38-
def test_version(self):
39-
"""
40-
Assert that the test version matches the library version.
41-
"""
42-
assert __version__ == EXPECTED_VERSION
43-
4430
class TestConnect(object):
4531

4632
def setup(self):

0 commit comments

Comments
 (0)