Skip to content

Commit

Permalink
version command, git providers, travis CD
Browse files Browse the repository at this point in the history
(and hating jinja)
  • Loading branch information
aogier committed Feb 27, 2020
1 parent 11bd382 commit 23ef3d9
Show file tree
Hide file tree
Showing 12 changed files with 1,498 additions and 76 deletions.
40 changes: 32 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
dist: xenial
dist: bionic
language: python

cache: pip

python:
- "3.6"
- "3.7"
- "3.8"
- "3.6"
- "3.7"
- "3.8"

install:
- pip install -U -r requirements-dev.txt
- sudo apt-get -y install upx-ucl
- pip install -U -r requirements-dev.txt

script:
- scripts/test
- scripts/test
- pyinstaller -s -F chachacha/main.py -n chachacha

env:
global:
- secure: "DHj2ma1AYFPuZh53Wnv9OPlMUboWOkBhvlJkN9vvW3ApthWbpQuegfJCQXrZFr2vFx10B9qdkj+NKCd1iy2PVPzYu4OFtb8xDBM8keYwbAK7gQ+EdCivFLOGU+n00FgJiKv0vFwtgKR7NAW/iTGVDSvviWDjs9kIrjIK3/ELSlmuBoOJ7qvxqnDeNqmU+LkR3ShETOY7KGkgpuE6UUEG/kfDUa0M6JUkGI/3i6iMbuyOUJn+gzADPDoBc0bnjEA6AsOF5f048vlfL57w3CyuV4qfbybHyU2phojOtTPKGt1I0jVN9lvQq4015jeoG1Qrc3oKaYXbo0NM2ah2aOpoq6wGMMBKnW4g+bEX9k+QScGLhuozMeMLAHYB4BIzwWv/E7aneI13uBogt2YT2DY64z9MwvRLJ3TUFJArh6NfbEzqCn4YabuzOMeOIQER5NwH0yrl/SFpQkQ3nfGm4qs1Cxa9Wga9RZ8DeeqUxT0LbuEXBjQsHaXDe/EFAo6cbDVL3eRsbrEK3LjsX54+412L5DF89WAcu4Y26XsZXofUuSO2ASgPKwve903JSw+9kWhz6BNLWdYdkuoc4e5Tp3uL8jPm0BebD88pmGdSvQkkfY7PxUFBqWGpszcxXIbI8yIPLMFavQVLOF80ACqMrX/RrZWq8hDDE+fyZy5Ci8QSpyw="

after_script:
- pip install codecov
- codecov
- pip install codecov
- codecov

.deploy_condition: &deploy_condition
on:
python: '3.7'
tags: true
repo: aogier/chachacha

deploy:
- provider: releases
skip_cleanup: true
api_key:
secure: isyzqPx8WxC2J4ND+2f2wqx+lBtM2fqlxBofk1DpY10BEAA3o98zyCBc3fbjFjkGSakcfBKDLMOK3iSMj/yV4bxQboFT1BmNPbkFjMZIotuZ7kIsOvboYvlEGlVcYY6UL7YZtp3GCSsc/sDrrEmNmow+owhMuFBZsLOdwj1eLBwKv3rBBoqM3qI+QFvgzGHuDrBN7jeOWPx3zC6zZGG7sSPlT82vfR85h8FHKg1qsWnfZ8j+MW/SULDvd9ZwuRhwO6BOjgMmxbQh5ffSGhLtNXxcI7MKknVhkhxgWh/mekoyDSaYqqdqcuLpVYlNTIrT0JTvd2VaH1PzjBYyUchszVGM6SL0scFTdjulfsLbr0J04GvfGvqKV0ixwkabYgas80l4vgMBaaDYY5+Hm6UGeqnFx4/uECoXqOk8q+Lh9+8b5gPVMo8HCOsGb/X1tKUsCxTuF/6ZBvPLBQRfrdRFndr7H3drae4EcMHso+jFmuH9JLJq2I1nBmgWKcAIXlzh4SpQUhNKxkct9PdKYtNvFyL0R0uM94Ti8s4tRaISg5+6Rh/1aSRDT8RkwLOJxGVy/cOc6MnlOt3pxN8Tx2IaDUfd8n3QJMrlLKK4Z4LxkR+K30SzO/RaJiivgseQ9ckvQ3bvrVvou/8YJKnYTqSjbD+HzAbta93XgMDb4nCTzEs=
file: dist/chachacha
<<: *deploy_condition

- provider: script
script: python setup.py bdist_wheel && twine upload -u __token__ dist/*whl --skip-existing
<<: *deploy_condition
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.5] - 2020-02-27

### Added

- Version command.
- Git providers.
- Travis CD.

## [0.1.4] - 2020-02-26

### Fixed
Expand Down Expand Up @@ -44,7 +52,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- tests
- a changelog :D

[Unreleased]: https://github.com/aogier/chachacha/compare/v0.1.4...HEAD
[Unreleased]: https://github.com/aogier/chachacha/compare/v0.1.5...HEAD
[0.1.5]: https://github.com/aogier/chachacha/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/aogier/chachacha/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/aogier/chachacha/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/aogier/chachacha/compare/v0.1.1...v0.1.2
Expand Down
2 changes: 1 addition & 1 deletion chachacha/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.4"
__version__ = "0.1.5"
46 changes: 46 additions & 0 deletions chachacha/drivers/git_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Created on 27 feb 2020
@author: Alessandro Ogier <[email protected]>
"""

PROVIDERS = {
"GH": {
"desc": "Github.com template",
"compare": "https://github.com/{repo_name}/compare/{new}...{old}",
"tag": "https://github.com/{repo_name}/releases/tag/{tag}",
},
"GL": {
"desc": "Gitlab.com template",
"compare": "https://gitlab.com/{repo_name}/-/compare/{new}...{old}",
"tag": "https://gitlab.com/{repo_name}/-/tags/{tag}",
},
}


class Provider:
def __init__(self, changelog, config):

self.changelog = changelog
self.config = config

def compare(self):

last = "HEAD"
self.changelog.pop("Unreleased", None)
# xxx: emit warning?
if not all((self.config.repo_name, self.config.tag_template)):
return
for release in self.changelog:
yield last if last != "HEAD" else "Unreleased", PROVIDERS[
self.config.git_provider
]["compare"].format(
repo_name=self.config.repo_name,
new=self.config.tag_template.format(t=release),
old=self.config.tag_template.format(t=last) if last != "HEAD" else last,
)
last = release

yield last, PROVIDERS[self.config.git_provider]["tag"].format(
repo_name=self.config.repo_name, tag=self.config.tag_template.format(t=last)
)
Empty file.
37 changes: 0 additions & 37 deletions chachacha/drivers/git_providers/github.py

This file was deleted.

21 changes: 9 additions & 12 deletions chachacha/drivers/kac.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from jinja2 import Template

from chachacha.configuration import CONFIG_SIGNATURE, Configuration
from chachacha.drivers.git_providers import github
from chachacha.drivers.git_provider import Provider

DEFAULT_HEADER = """
# Changelog
Expand Down Expand Up @@ -50,7 +50,8 @@
{%- endfor %}
{%- endif %}
{%- if config is defined %}
{{ '\n' + config }}
{{ config }}
{%- endif %}
""".strip()
)
Expand Down Expand Up @@ -83,7 +84,7 @@ def init(self, overwrite: bool = False):

print("changelog created")

def _write(self, *, current: dict = None, config: Configuration = None) -> None:
def write(self, *, current: dict = None, config: Configuration = None) -> None:
if not config:
config = self.get_config(init=True)
config.driver = "KAC"
Expand All @@ -92,13 +93,9 @@ def _write(self, *, current: dict = None, config: Configuration = None) -> None:

ctx = dict(header=DEFAULT_HEADER, current=current)

# TODO: will decouple
try:
if config.git_provider == "GH":
git_provider = github.Provider(current, config)
ctx["git_provider"] = git_provider
except:
pass
if config.git_provider:
git_provider = Provider(current, config)
ctx["git_provider"] = git_provider

if config:
ctx["config"] = config.marshal()
Expand Down Expand Up @@ -129,7 +126,7 @@ def add_entry(

section.append(_changelog_line)

self._write(current=current)
self.write(current=current)

def release(self, mode: str) -> None:

Expand Down Expand Up @@ -161,7 +158,7 @@ def release(self, mode: str) -> None:
changelog[last]["release_date"] = datetime.now().isoformat().split("T")[0]
changelog.update(current)

self._write(current=changelog)
self.write(current=changelog)

def get_config(self, *, init=False):

Expand Down
13 changes: 9 additions & 4 deletions chachacha/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import click
from click.core import Context

from chachacha import drivers
from chachacha import __version__, drivers
from chachacha.drivers.kac import ChangelogFormat

try:
Expand All @@ -32,10 +32,10 @@ def list_commands_for_help(self, ctx):
commands = (
command
for command in super().list_commands(ctx)
if command not in ("init", "release", "config")
if command not in ("init", "release", "config", "version")
)

return ["init", "config", "release"] + sorted(commands)
return ["init", "config", "release"] + sorted(commands) + ["version"]


@click.group(cls=CCCGroup)
Expand Down Expand Up @@ -135,7 +135,12 @@ def config(

if value:
setattr(config, key, value)
driver._write(config=config)
driver.write(config=config)


@main.command(help="show version and exit")
def version(): # pragma: no cover
print(f"v{__version__}")


if __name__ == "__main__": # pragma: no cover
Expand Down
Loading

0 comments on commit 23ef3d9

Please sign in to comment.