Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: 2.1

orbs:
codecov: codecov/codecov@3.0.0

jobs:
build:
docker:
- image: cimg/python:3.10.0
environment:
PIPENV_VENV_IN_PROJECT: true
resource_class: medium
steps:
- checkout
- restore_cache:
keys:
- pipenv-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- pipenv-{{ .Branch }}-
- pipenv-
- run: pipenv sync --dev
- save_cache:
key: pipenv-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
paths:
- .venv
- run: pipenv run ./lint.sh
- run: pipenv run pytest
- codecov/upload:
file: coverage.xml
- run: pipenv run ./build.sh
- run: pip install dist/*
- run: if [[ -z "${CIRCLE_TAG}" ]]; then circleci-agent step halt; fi
- run: pipenv run twine upload dist/*

workflows:
default:
jobs:
- build:
filters:
branches:
only: /.*/
tags:
only: /.*/
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
exclude = .venv,dist
ignore = E501, W503
max-line-length = 88
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.coverage
changedifferently.egg-info
coverage.xml
dist
htmlcov
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"changedifferently"
]
}
9 changes: 9 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: default

ignore: |
.venv

rules:
document-start: disable
line-length:
max: 88
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include changedifferently/version/VERSION
20 changes: 20 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]
black = "==21.9b0"
flake8 = "*"
isort = "*"
mypy = "*"
pytest = "*"
pytest-cov = "*"
twine = "*"
shellcheck-py = "*"
yamllint = "*"

[requires]
python_version = "3.10"
611 changes: 611 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/env bash

set -euo pipefail

if [[ -n ${1:-} ]]; then
version=${1}
elif [[ -n ${CIRCLE_TAG:-} ]]; then
version=${CIRCLE_TAG}
else
version="-1.-1.-1"
fi

echo "${version}" > changedifferently/version/VERSION
rm -rf dist
python setup.py bdist_wheel
rm -rf build
Empty file added changedifferently/__init__.py
Empty file.
Empty file added changedifferently/py.typed
Empty file.
1 change: 1 addition & 0 deletions changedifferently/version/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1.-1.-1
7 changes: 7 additions & 0 deletions changedifferently/version/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import importlib.resources as pkg_resources


def get_version() -> str:
"""Gets the package version."""
with pkg_resources.open_text(__package__, "VERSION") as t:
return t.readline().strip()
Empty file.
22 changes: 22 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/env bash
set -euo pipefail

find . -name "*.sh" -not -path "*/.venv/*" -exec shellcheck -o all --severity style -x {} +

yamllint --strict .

if [ "${CI:=}" == "true" ]; then
isort . --check-only --diff
else
isort .
fi

if [ "${CI:=}" == "true" ]; then
black . --check --diff
else
black .
fi

flake8 .
mypy changedifferently
mypy tests
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
pretty = True
strict = True
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tool.black]
exclude = '.venv'

[tool.isort]
profile = 'black'
skip = '.venv'

[tool.pytest.ini_options]
addopts = '--cov=changedifferently --cov-branch --cov-report=html --cov-report=term-missing:skip-covered --cov-report=xml --no-cov-on-fail'
log_cli = 1
testpaths = 'tests'
56 changes: 56 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from pathlib import Path

from setuptools import setup # pyright: reportMissingTypeStubs=false

from changedifferently.version import get_version

readme_path = Path(__file__).parent / "README.md"

with open(readme_path, encoding="utf-8") as f:
long_description = f.read()

classifiers = [
"Environment :: Console",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Utilities",
"Typing :: Typed",
]

version = get_version()

if "a" in version:
classifiers.append("Development Status :: 3 - Alpha")
elif "b" in version:
classifiers.append("Development Status :: 4 - Beta")
else:
classifiers.append("Development Status :: 5 - Production/Stable")

classifiers.sort()

setup(
author="Cariad Eccleston",
author_email="cariad@cariad.earth",
classifiers=classifiers,
description="Visualises the changes described by an Amazon Web Services CloudFormation change set",
include_package_data=True,
license="MIT",
long_description=long_description,
long_description_content_type="text/markdown",
name="changedifferently",
packages=[
"changedifferently",
"changedifferently.version",
],
package_data={
"changedifferently": ["py.typed"],
"changedifferently.version": ["py.typed"],
},
python_requires=">=3.8",
url="https://github.com/cariad/changedifferently",
version=version,
)
Empty file added tests/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from changedifferently.version import get_version


def test_get_version() -> None:
assert get_version() == "-1.-1.-1"