Skip to content

Commit

Permalink
Merge pull request #20 from d3b-center/fixsplit
Browse files Browse the repository at this point in the history
馃悰 Don't fail on non-semver tags
  • Loading branch information
fiendish committed Jun 16, 2020
2 parents 571b79e + 568e4f9 commit 845ce57
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 16 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/lint.yml
Expand Up @@ -5,16 +5,13 @@ on:

jobs:
lint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
- name: Install
run: |
python -m pip install --upgrade pip
pip install flake8 black
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,20 @@
name: Python application

on:
pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install
run: |
python -m pip install --upgrade pip
pip install pytest .
- name: Test
run: |
pytest tests
20 changes: 10 additions & 10 deletions d3b_release_maker/release_maker.py
Expand Up @@ -41,8 +41,12 @@ def split_at_pattern(text, pattern):
"""
Split a string where a pattern begins
"""
start = regex.search(pattern, text).start()
return text[0:start], text[start:]
obj = regex.search(pattern, text)
if obj:
start = obj.start()
return text[0:start], text[start:]
else:
return text, ""


def delay_until(datetime_of_reset):
Expand Down Expand Up @@ -284,14 +288,10 @@ def build_release_notes(self, repo, blurb=None):
print(markdown)
print("=" * 33 + "END DELTA" + "=" * 33)

while True:
release_type = input(
f"What type of semantic versioning release is this {RELEASE_OPTIONS}? "
).lower()
if release_type in RELEASE_OPTIONS:
break
else:
print(f"'{release_type}' is not one of {RELEASE_OPTIONS}")
release_type = click.prompt(
"What type of semantic versioning release is this?",
type=click.Choice(RELEASE_OPTIONS),
)

# Update release version
prefix, prev_version = split_at_pattern(latest_tag["name"], r"\d")
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
@@ -1,4 +1,3 @@
setuptools_scm
Click==7.0
d3b_utils @ git+https://git@github.com/d3b-center/d3b-utils-python.git
emoji
Expand Down
22 changes: 22 additions & 0 deletions tests/test_preview.py
@@ -0,0 +1,22 @@
#!/usr/bin/env python
from click.testing import CliRunner

import pytest
from d3b_release_maker.cli import preview_changelog_cmd


@pytest.mark.parametrize(
"type,index", [("foo\nmajor", 0), ("foo\nminor", 1), ("foo\npatch", 2)]
)
def test_version(type, index):
runner = CliRunner()
result = runner.invoke(
preview_changelog_cmd,
args='--repo d3b-center/d3b-release-maker --blurb_file ""',
input=f"{type}",
)
assert result.exit_code == 0
lastlines = result.output.splitlines()[-2:]
versions = [line.split(": ")[1] for line in lastlines]
version_parts = [int(v.split(".")[index]) for v in versions]
assert version_parts[1] == version_parts[0] + 1

0 comments on commit 845ce57

Please sign in to comment.