Skip to content

Commit

Permalink
Refactor versioning to be static rather than dynamic
Browse files Browse the repository at this point in the history
* For some reason importlib_metadata can go stale with its cache.
* Bump version to 1.1
* Fix GH Actions CI $HOME path to tilde
* Fix Codecov coverage upload (add env vars)
* Rotate cache keys
* Remove importlib_metadata as dependency
  • Loading branch information
adithyabsk committed Nov 3, 2020
1 parent 606fb89 commit 4effc81
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 64 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ jobs:
run: |
pip install --upgrade pip
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
- name: Add Poetry to Path
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Add Poetry to Path Unix
run: |
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
echo "POETRY_VENV=$HOME/.virtualenvs" >> $GITHUB_ENV
- name: Configure Poetry
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
poetry config virtualenvs.path ${{ env.POETRY_VENV }}
- name: Cache Poetry virtualenv
uses: actions/cache@v2.0.0
id: cache-poetry
id: cache-poetry-lint
with:
path: ~/.virtualenvs
key: poetry|pre-commit|${{ env.PY }}|${{ hashFiles('poetry.lock') }}
path: ${{ env.POETRY_VENV }}
key: poetry-lint|${{ env.PY }}|${{ hashFiles('poetry.lock') }}
- name: Install Project Dependencies (Poetry)
run: poetry install -vvv
if: steps.cache-poetry.outputs.cache-hit != 'true'
if: steps.cache-poetry-lint.outputs.cache-hit != 'true'
- name: Add poetry env to PATH
run: echo "$( poetry env info --path )/bin" >> $GITHUB_PATH
- name: Run Lint Steps
Expand All @@ -44,6 +46,9 @@ jobs:
matrix:
os: [ macos-latest, windows-latest, ubuntu-latest ]
python: [ ^3.7, ^3.8, ^3.9 ]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
steps:
- uses: actions/checkout@v2.3.3
- uses: actions/setup-python@v2
Expand All @@ -53,25 +58,37 @@ jobs:
run: |
pip install --upgrade pip
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
- name: Add Poetry to Path
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Add Poetry to Path Unix
run: |
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
echo "POETRY_VENV=$HOME/.virtualenvs" >> $GITHUB_ENV
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Add Poetry to Path Windows
run: |
echo "$env:USERPROFILE\.poetry\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "POETRY_VENV=$env:USERPROFILE\.virtualenvs" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if: runner.os == 'Windows'
- name: Debug Windows Path
run: $env:Path
if: runner.os == 'Windows'
- name: Configure Poetry
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
poetry config virtualenvs.path ${{ env.POETRY_VENV }}
- name: Cache Poetry virtualenv
uses: actions/cache@v2.0.0
id: cache-poetry
id: cache-poetry-build
with:
path: ~/.virtualenvs
key: poetry|build|${{ matrix.os }}|${{ env.PY }}|${{ hashFiles('poetry.lock') }}
path: ${{ env.POETRY_VENV }}
key: poetry-build|${{ matrix.os }}|${{ env.PY }}|${{ hashFiles('poetry.lock') }}
- name: Install Project Dependencies (Poetry)
run: poetry install -vvv
if: steps.cache-poetry.outputs.cache-hit != 'true'
if: steps.cache-poetry-build.outputs.cache-hit != 'true'
- name: Run Pytest
run: poetry run pytest --cov-report=xml
- uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
fail_ci_if_error: true
verbose: true
env_vars: OS,PYTHON
6 changes: 2 additions & 4 deletions keep2roam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Convert Google Takeout Dump to Roam Daily Notes."""

from keep2roam.__version__ import version as __version__
from keep2roam.cli import cli as k2r
from keep2roam.version import get_version


__version__ = get_version()
del get_version
__all__ = ["k2r"]
__all__ = ["k2r", "__version__"]
3 changes: 3 additions & 0 deletions keep2roam/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Package and CLI version."""

version = "1.1"
4 changes: 2 additions & 2 deletions keep2roam/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import click

from keep2roam.__version__ import version
from keep2roam.convert import convert
from keep2roam.version import get_version


CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
Expand All @@ -15,7 +15,7 @@ def print_version(ctx, param, value): # type: ignore
"""Print package version callback."""
if not value or ctx.resilient_parsing:
return
click.echo(get_version())
click.echo(version)
ctx.exit()


Expand Down
16 changes: 0 additions & 16 deletions keep2roam/version.py

This file was deleted.

18 changes: 9 additions & 9 deletions poetry.lock

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

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep2roam"
version = "1.0"
version = "1.1"
description = "Convert Google Keep Takeout Files to Roam Daily Notes Pages"
authors = ["Adithya Balaji <adithyabsk@gmail.com>"]
license = "MIT"
Expand All @@ -12,7 +12,6 @@ repository = "https://github.com/adithyabsk/keep2roam"
python = "^3.7"
marshmallow = "^3.9.0"
click = "^7.1.2"
importlib-metadata = { version = "^2.0.0", python = "<3.8" }

[tool.poetry.dev-dependencies]
flake8 = "3.8.4"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_cli_entry(monkeypatch):


def test_cli_version(monkeypatch):
monkeypatch.setattr("keep2roam.cli.get_version", lambda: "0.x")
monkeypatch.setattr("keep2roam.cli.version", "0.x")
from keep2roam.cli import cli

runner = CliRunner()
Expand Down
16 changes: 0 additions & 16 deletions tests/test_version.py

This file was deleted.

0 comments on commit 4effc81

Please sign in to comment.