Skip to content

Commit

Permalink
DS-30: Refactor git workflow (#31)
Browse files Browse the repository at this point in the history
* DS-30: Add bump2version to handle version increasing

* DS-30: Add .yml filetype to editorconfig

* DS-30: Add new git workflow and autopublish in circleci

* DS-30: Update contribution docs

* DS-30: Fix circleci config
  • Loading branch information
JavierLuna authored Nov 2, 2019
1 parent fe49b6b commit c4dbb7a
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 36 deletions.
62 changes: 62 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ workflows:
name: Run all tests under emulator
- static-analysis:
name: Run linting and type hinting checks

release-workflow:
jobs:
- tests:
filters:
tags:
only: /[0-9]+(\.[0-9]+)*a[0-9]+/
branches:
ignore: /.*/

- static-analysis:
filters:
tags:
only: /[0-9]+(\.[0-9]+)*a[0-9]+/
branches:
ignore: /.*/

- release-on-tag:
requires:
- tests
- static-analysis
filters:
tags:
only: /[0-9]+(\.[0-9]+)*a[0-9]+/
branches:
ignore: /.*/
jobs:

tests:
Expand Down Expand Up @@ -49,3 +75,39 @@ jobs:
command: |
. env/bin/activate
make type-check
release-on-tag:
docker:
- image: circleci/python:3.6

steps:
- checkout
- run:
name: Install dependencies
command: |
python3 -m venv env
. env/bin/activate
pip install poetry
make dependencies
- run:
name: Publishing to PyPi
command: |
. env/bin/activate
make ci-publish
- add_ssh_keys:
fingerprints:
- "45:09:1d:20:95:a8:67:cf:85:26:70:8e:98:10:76:82"
- run:
name: Configure git credentials
command: |
git config user.email "ci@circleci.com"
git config user.name "CI bot"
- run:
name: Bump version
command: |
git checkout -b "release-${CIRCLE_TAG}"
. env/bin/activate
make ci-bump-version
git checkout master
git merge "release-${CIRCLE_TAG}"
git push
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ max_line_length = 120
indent_size = 2
insert_final_newline = ignore

[*.yml]
indent_size = 2

[Makefile]
indent_style = tab
indent_style = tab
21 changes: 5 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,13 @@ Docker is preferred, as the `Makefile` has targets to run the tests under a dock

### Git workflow

#### Repository branches
This repository follows a modified [Github workflow](https://guides.github.com/introduction/flow/).

This repository has two main branches:
* `master`: Latest stable version released.
* `develop`: Latest version released, including pre-releases.
Differences:
* Branches will follow the naming: `DS-<issue id>-short-descriptive-name`. Example: `DS-11-pytests`
* Releases will happen when a `0.0.0a0` tag is pushed. This tag will be created manually by the project administrator.

**Note:** At the moment, no stable version has been released, so master and develop are being used as "latest version released" and "next version" respectively.

#### Branch naming

Please, create a separate branch to do your work, no important how little it'd be.
Use the following naming:

* **Features**: `feature/DS-<issue id>-<issue keywords>`. Example: `feature/DS-11-pytests`
* **Bugs**: `bug/DS-<issue id>-<issue keyworkds>`. Example: `bug/DS-14-list-dict-serialization`


Please branch from `develop` and target your PR to `develop` as well.
**Note:** The `0.0.0a0` will be active until it is decided to abandon the alpha state, then it will be `0.0.0`.

#### Commits

Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ build: tests lint
publish: build
poetry publish

# CI

ci-publish:
poetry publish --build --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" --no-interaction

ci-bump-version:
poetry run bump2version build

# Docker

Expand Down
21 changes: 5 additions & 16 deletions docs/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,13 @@ Docker is preferred, as the `Makefile` has targets to run the tests under a dock

### Git workflow

#### Repository branches
This repository follows a modified [Github workflow](https://guides.github.com/introduction/flow/).

This repository has two main branches:
* `master`: Latest stable version released.
* `develop`: Latest version released, including pre-releases.
Differences:
* Branches will follow the naming: `DS-<issue id>-short-descriptive-name`. Example: `DS-11-pytests`
* Releases will happen when a `0.0.0a0` tag is pushed. This tag will be created manually by the project administrator.

**Note:** At the moment, no stable version has been released, so master and develop are being used as "latest version released" and "next version" respectively.

#### Branch naming

Please, create a separate branch to do your work, no important how little it'd be.
Use the following naming:

* **Features**: `feature/DS-<issue id>-<issue keywords>`. Example: `feature/DS-11-pytests`
* **Bugs**: `bug/DS-<issue id>-<issue keyworkds>`. Example: `bug/DS-14-list-dict-serialization`


Please branch from `develop` and target your PR to `develop` as well.
**Note:** The `0.0.0a0` will be active until it is decided to abandon the alpha state, then it will be `0.0.0`.

#### Commits

Expand Down
11 changes: 10 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pytest-cov = "^2.8"
flake8 = "^3.7"
pre-commit = "^1.20"
mypy = "^0.740.0"
bump2version = "^0.5.11"

[build-system]
requires = ["poetry>=0.12"]
Expand Down
22 changes: 20 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,29 @@ max-line-length = 120

[mypy]
python_version = 3.6
strict_optional=True
no_implicit_optional=True
strict_optional = True
no_implicit_optional = True

[mypy-google.cloud]
ignore_missing_imports = True

[mypy-google.cloud.datastore]
ignore_missing_imports = True


[bumpversion]
commit = True
tag = False
message = Bump version: {current_version} → {new_version} [ci skip]
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(a(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}a{build}
current_version = 0.0.0a7

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:jluna-test-package/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'

0 comments on commit c4dbb7a

Please sign in to comment.