mirror of
https://github.com/djrobstep/migra.git
synced 2024-09-11 13:56:05 +03:00
fix tests, move to poetry
This commit is contained in:
parent
d1113d63d3
commit
03129e50ac
82
.circleci/config.yml
Normal file
82
.circleci/config.yml
Normal file
@ -0,0 +1,82 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
working_directory: ~/circleci
|
||||
docker:
|
||||
- image: circleci/python:3.7.0
|
||||
- image: circleci/postgres:10
|
||||
environment:
|
||||
POSTGRES_USER: circleci
|
||||
POSTGRES_DB: circleci
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: deps1-{{ .Branch }}-{{ checksum "pyproject.toml" }}
|
||||
- run:
|
||||
name: Wait for db
|
||||
command: dockerize -wait tcp://localhost:5432 -timeout 1m
|
||||
- run:
|
||||
name: Install poetry
|
||||
command: |
|
||||
sudo pip3 install poetry
|
||||
poetry config settings.virtualenvs.create false
|
||||
- run:
|
||||
command: |
|
||||
python3 -m venv ~/.venv
|
||||
. ~/.venv/bin/activate
|
||||
|
||||
poetry install
|
||||
- save_cache:
|
||||
key: deps1-{{ .Branch }}-{{ checksum "pyproject.toml" }}
|
||||
paths:
|
||||
- "~/.venv"
|
||||
- run:
|
||||
name: Check formatting
|
||||
command: |
|
||||
. ~/.venv/bin/activate
|
||||
make lint
|
||||
- run:
|
||||
command: |
|
||||
. ~/.venv/bin/activate
|
||||
make test
|
||||
- store_artifacts:
|
||||
path: test-reports/
|
||||
destination: tr1
|
||||
|
||||
publish:
|
||||
working_directory: ~/circleci
|
||||
docker:
|
||||
- image: circleci/python:3.7.0
|
||||
steps:
|
||||
- setup_remote_docker
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: deps1-{{ .Branch }}-{{ checksum "pyproject.toml" }}
|
||||
- run:
|
||||
name: Install poetry, deps
|
||||
command: |
|
||||
sudo pip3 install poetry
|
||||
poetry config settings.virtualenvs.create false
|
||||
python3 -m venv ~/.venv
|
||||
. ~/.venv/bin/activate
|
||||
poetry install
|
||||
- run:
|
||||
name: Bump version, build, install
|
||||
command: |
|
||||
. ~/.venv/bin/activate
|
||||
python deploy/vbump.py
|
||||
poetry build
|
||||
poetry publish --username $PYPI_USERNAME --password $PYPI_PASSWORD
|
||||
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build-then-publish:
|
||||
jobs:
|
||||
- build
|
||||
- publish:
|
||||
requires:
|
||||
- build
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,3 +42,4 @@ nosetests.xml
|
||||
docs/site
|
||||
|
||||
scratch
|
||||
poetry.lock
|
||||
|
28
Makefile
28
Makefile
@ -1,44 +1,26 @@
|
||||
.PHONY: docs
|
||||
|
||||
# test commands and arguments
|
||||
tcommand = PYTHONPATH=. py.test -x
|
||||
tcommand = py.test -x
|
||||
tmessy = -svv
|
||||
targs = --cov-report term-missing --cov migra
|
||||
|
||||
pip:
|
||||
pip install --upgrade pip
|
||||
pip install --upgrade -r requirements.txt
|
||||
|
||||
tox:
|
||||
tox tests
|
||||
|
||||
test:
|
||||
$(tcommand) $(targs) tests
|
||||
|
||||
stest:
|
||||
$(tcommand) $(tmessy) $(targs) tests
|
||||
|
||||
clean:
|
||||
gitclean:
|
||||
git clean -fXd
|
||||
|
||||
clean:
|
||||
find . -name \*.pyc -delete
|
||||
rm -rf .cache
|
||||
|
||||
docs:
|
||||
cd docs && mkdocs build
|
||||
|
||||
docsserve:
|
||||
cd docs && mkdocs serve
|
||||
|
||||
fmt:
|
||||
isort -rc .
|
||||
black .
|
||||
|
||||
lint:
|
||||
flake8 .
|
||||
|
||||
tidy: clean lint
|
||||
|
||||
all: tidy docs tox
|
||||
|
||||
publish:
|
||||
python setup.py sdist bdist_wheel --universal
|
||||
twine upload dist/*
|
||||
|
21
deploy/vbump.py
Normal file
21
deploy/vbump.py
Normal file
@ -0,0 +1,21 @@
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
|
||||
from toml import dumps, loads
|
||||
|
||||
PYPROJECT = "pyproject.toml"
|
||||
|
||||
p = Path(PYPROJECT)
|
||||
pyproject = loads(p.read_text())
|
||||
|
||||
v = pyproject["tool"]["poetry"]["version"]
|
||||
|
||||
parts = v.split(".")[:2]
|
||||
unix = str(int(time()))
|
||||
|
||||
parts.append(unix)
|
||||
|
||||
v_with_timestamp = ".".join(parts)
|
||||
pyproject["tool"]["poetry"]["version"] = v_with_timestamp
|
||||
|
||||
p.write_text(dumps(pyproject))
|
@ -1,10 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .util import differences
|
||||
from .statements import Statements
|
||||
from functools import partial
|
||||
from collections import OrderedDict as od
|
||||
from functools import partial
|
||||
|
||||
from .statements import Statements
|
||||
from .util import differences
|
||||
|
||||
THINGS = [
|
||||
"schemas",
|
||||
|
@ -1,10 +1,11 @@
|
||||
from __future__ import unicode_literals, print_function
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from sqlbag import S
|
||||
import argparse
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
|
||||
from sqlbag import S
|
||||
|
||||
from .migra import Migration
|
||||
from .statements import UnsafeMigrationException
|
||||
|
||||
@ -78,7 +79,7 @@ def run(args, out=None, err=None):
|
||||
try:
|
||||
if m.statements:
|
||||
if args.force_utf8:
|
||||
print(m.sql.encode('utf8'), file=out)
|
||||
print(m.sql.encode("utf8"), file=out)
|
||||
else:
|
||||
print(m.sql, file=out)
|
||||
except UnsafeMigrationException:
|
||||
|
@ -1,7 +1,8 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from schemainspect import DBInspector, get_inspector
|
||||
from sqlbag import raw_execute
|
||||
from schemainspect import get_inspector, DBInspector
|
||||
|
||||
from .changes import Changes
|
||||
from .statements import Statements
|
||||
|
||||
|
33
pyproject.toml
Normal file
33
pyproject.toml
Normal file
@ -0,0 +1,33 @@
|
||||
[tool.poetry]
|
||||
name = "migra"
|
||||
version = "1.0"
|
||||
authors = [ "Robert Lechte <robertlechte@gmail.com>",]
|
||||
license = "Unlicense"
|
||||
readme = "README.md"
|
||||
description = "Like `diff` but for PostgreSQL schemas"
|
||||
|
||||
repository = "https://github.com/djrobstep/migra"
|
||||
homepage = "https://migra.djrobstep.com/"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "*"
|
||||
sqlbag = "*"
|
||||
six = "*"
|
||||
schemainspect = "*"
|
||||
psycopg2-binary = { version="*", optional = true }
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
sqlbag = "*"
|
||||
pytest = "*"
|
||||
pytest-cov = "*"
|
||||
pytest-sugar = "*"
|
||||
psycopg2-binary = "*"
|
||||
flake8 = "*"
|
||||
isort = "*"
|
||||
black = {version = "*", python = ">=3.6"}
|
||||
|
||||
[tool.poetry.scripts]
|
||||
migra = 'migra:do_command'
|
||||
|
||||
[tool.poetry.extras]
|
||||
pg = ["psycopg2-binary"]
|
@ -1,24 +0,0 @@
|
||||
-e .
|
||||
|
||||
sqlbag
|
||||
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-xdist
|
||||
mock
|
||||
|
||||
pylint
|
||||
flake8
|
||||
|
||||
psycopg2-binary
|
||||
|
||||
tox
|
||||
yapf
|
||||
|
||||
pep8
|
||||
wheel
|
||||
twine
|
||||
|
||||
mkdocs
|
||||
doc2md
|
||||
black ; python_version > "3.0.0"
|
32
setup.py
32
setup.py
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import io
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
readme = io.open("README.md").read()
|
||||
setup(
|
||||
name="migra",
|
||||
version="1.0.1535509978",
|
||||
url="https://github.com/djrobstep/migra",
|
||||
description="Like diff but for PostgreSQL schemas",
|
||||
long_description=readme,
|
||||
long_description_content_type="text/markdown",
|
||||
author="Robert Lechte",
|
||||
author_email="robertlechte@gmail.com",
|
||||
install_requires=["sqlbag", "six", "schemainspect"],
|
||||
zip_safe=False,
|
||||
packages=find_packages(),
|
||||
classifiers=[
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"Natural Language :: English",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
],
|
||||
entry_points={"console_scripts": ["migra = migra:do_command"]},
|
||||
extras_require={"pg": ["psycopg2-binary"]},
|
||||
)
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@ -3,12 +3,11 @@ from __future__ import unicode_literals
|
||||
import io
|
||||
|
||||
from pytest import raises
|
||||
|
||||
from migra import Statements, UnsafeMigrationException, Migration
|
||||
from migra.command import run
|
||||
from sqlbag import temporary_database, S, load_sql_from_file
|
||||
from schemainspect import get_inspector
|
||||
from migra.command import parse_args
|
||||
from sqlbag import S, load_sql_from_file, temporary_database
|
||||
|
||||
from migra import Migration, Statements, UnsafeMigrationException
|
||||
from migra.command import parse_args, run
|
||||
|
||||
SQL = """select 1;
|
||||
|
||||
|
18
tox.ini
18
tox.ini
@ -1,18 +0,0 @@
|
||||
# Tox (http://tox.testrun.org/) is a tool for running tests
|
||||
# in multiple virtualenvs. This configuration file will run the
|
||||
# test suite on all supported python versions. To use it, "pip install tox"
|
||||
# and then run "tox" from this directory.
|
||||
|
||||
[tox]
|
||||
envlist = py27,py37
|
||||
toxworkdir = {homedir}/.toxfiles{toxinidir}
|
||||
|
||||
[testenv]
|
||||
commands = py.test \
|
||||
[] # substitute with tox positional arguments
|
||||
|
||||
deps =
|
||||
-rrequirements.txt
|
||||
|
||||
[flake8]
|
||||
ignore = E501
|
Loading…
Reference in New Issue
Block a user