Skip to content

Commit

Permalink
Update test configs (#80)
Browse files Browse the repository at this point in the history
Update test configs
  • Loading branch information
techalchemy authored Jan 7, 2020
2 parents 23f005e + 9d5629c commit fbd35fa
Show file tree
Hide file tree
Showing 8 changed files with 594 additions and 382 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/pypi_upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Create Release & Upload To PyPI

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- v?[0-9]+.[0-9]+.[0-9]+ # add .* to allow dev releases

jobs:
build:
name: pythonfinder PyPI Upload
runs-on: ubuntu-latest
env:
CI: "1"

steps:
- name: Checkout code
uses: actions/checkout@v1

- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Create Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install latest tools for build
run: |
python -m pip install --upgrade pip setuptools wheel pipenv invoke
python -m pipenv install --dev --pre
python -m pipenv run pip install invoke
- name: Build wheels
run: |
python -m pipenv run inv build
- name: Upload to PyPI via Twine
# to upload to test pypi, pass --repository-url https://test.pypi.org/legacy/ and use secrets.TEST_PYPI_TOKEN
run: |
python -m pipenv run twine upload --verbose -u '__token__' -p '${{ secrets.PYPI_TOKEN }}' dist/*
# git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:master
# we need to use a deploy key for this to get around branch protection as the default token fails
- name: Pre-bump
run: |
git config --local user.name 'Github Action'
git config --local user.email [email protected]
python -m pipenv run inv bump-version -t dev
git commit -am 'pre-bump'
git push [email protected]:${{ github.repository }}.git HEAD:master
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
language: python
sudo: false
cache: pip
dist: trusty
dist: bionic

matrix:
fast_finish: true

install:
- "git submodule update --init --recursive"
- "pip install --upgrade setuptools pip==19.0.3 pipenv --upgrade-strategy=eager"
- "pipenv run python -m pip install pip==19.0.3"
- "pip install --upgrade setuptools pip==19.3.1 pipenv --upgrade-strategy=eager"
- "pipenv run python -m pip install pip==19.3.1"
- "pipenv install --dev"
script:
# Remove Windows specific helper from Unix test runs
Expand All @@ -19,19 +19,19 @@ script:
jobs:
include:
- stage: test
python: "3.7"
python: "3.8"
dist: xenial
sudo: required
- python: "3.6"
- python: "3.7"
- python: "2.7"
- python: "3.6"
- python: "3.5"
- python: "3.4"
- stage: packaging
python: "3.6"
python: "3.8"
script:
- "python setup.py sdist"
- "twine check dist/*"
- stage: coverage
python: "3.6"
python: "3.8"
script:
- "pipenv run pytest --cov=pythonfinder --cov-report=term-missing --cov-report=xml --cov-report=html tests"
786 changes: 436 additions & 350 deletions Pipfile.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ environment:
# Unit and integration tests.
- PYTHON: "C:\\Python27"
RUN_INTEGRATION_TESTS: "True"
- PYTHON: "C:\\Python36-x64"
- PYTHON: "C:\\Python37-x64"
RUN_INTEGRATION_TESTS: "True"
# Unit tests only.
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python34-x64"
- PYTHON: "C:\\Python37-x64"
- PYTHON: "C:\\Python36-x64"
- PYTHON: "C:\\Python35-x64"

install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "python --version"
- "pip install --upgrade pip==19.0.3 pytest pytest-xdist"
- "pip install --upgrade pip==19.3.1 pytest pytest-xdist"
- "pip install -e .[tests,dev]"

build: off
Expand Down
2 changes: 1 addition & 1 deletion src/pythonfinder/_vendor/pep514tools/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_PYTHONCORE_COMPATIBILITY_TAGS = {
'2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7',
'3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7',
'3.8'
'3.8', '3.9'
}

_IS_64BIT_OS = None
Expand Down
95 changes: 79 additions & 16 deletions tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# -*- coding=utf-8 -*-
import os
import datetime
import pathlib
import re
import shutil
import subprocess
import time
from pathlib import Path

import invoke
import parver
from towncrier._builder import find_fragments, render_fragments, split_fragments
from towncrier._settings import load_config

from . import vendoring

ROOT = pathlib.Path(__file__).resolve().parent.parent

PACKAGE_NAME = "pythonfinder"
Expand Down Expand Up @@ -39,30 +38,53 @@ def typecheck(ctx):
ctx.run(f"mypy {src_dir} --config-file={config_file}", env=env)



def _get_git_root(ctx):
return Path(ctx.run("git rev-parse --show-toplevel", hide=True).stdout.strip())


def _get_branch(ctx):
return ctx.run("git rev-parse --abbrev-ref HEAD", hide=True).stdout.strip()


@invoke.task()
def clean(ctx):
"""Clean previously built package artifacts."""
ctx.run(f"python setup.py clean")
"""Clean previously built package artifacts.
"""
dist = ROOT.joinpath("dist")
build = ROOT.joinpath("build")
print(f"[clean] Removing {dist} and {build}")
print("[clean] Removing dist and build dirs")
if dist.exists():
shutil.rmtree(str(dist))
shutil.rmtree(dist.as_posix())
if build.exists():
shutil.rmtree(str(build))
shutil.rmtree(build.as_posix())


def _read_version():
out = subprocess.check_output(["git", "tag"], encoding="ascii")
versions = [line.strip() for line in out.splitlines() if line]
_unparsed = [v for v in versions if v.startswith("v")]
try:
version = max(parver.Version.parse(v.lstrip("v")).normalize() for v in versions)
version = max(
parver.Version.parse(v.lstrip("v")).normalize()
for v in (line.strip() for line in out.split("\n"))
if v
)
except ValueError:
version = parver.Version.parse("0.0.0")
return version


def _read_text_version():
lines = INIT_PY.read_text().splitlines()
match = next(iter(line for line in lines if line.startswith("__version__")), None)
if match is not None:
_, _, version_text = match.partition("=")
version_text = version_text.strip().strip('"').strip("'")
version = parver.Version.parse(version_text).normalize()
return version
else:
return _read_version()


def _write_version(v):
lines = []
with INIT_PY.open() as f:
Expand All @@ -85,13 +107,19 @@ def _render_log():
None,
definitions,
)
project_options = {
"name": config["package"],
"version": _read_text_version(),
"date": datetime.date.today().isoformat(),
}
rendered = render_fragments(
pathlib.Path(config["template"]).read_text(encoding="utf-8"),
config["issue_format"],
split_fragments(fragments, definitions),
definitions,
config["underlines"][1:],
False, # Don't add newlines to wrapped text.
project_options,
)
return rendered

Expand All @@ -103,7 +131,11 @@ def _bump_release(version, type_, log=False):
if type_ not in REL_TYPES:
raise ValueError(f"{type_} not in {REL_TYPES}")
index = REL_TYPES.index(type_)
next_version = version.base_version().bump_release(index=index)
current_version = version.base_version()
if version.is_prerelease and type_ == "patch":
next_version = current_version
else:
next_version = current_version.bump_release(index=index)
if log:
print(f"[bump] {version} -> {next_version}")
print(f"{next_version}")
Expand Down Expand Up @@ -182,16 +214,47 @@ def tag_release(ctx, version=None, type_="patch", yes=False, dry_run=False):
ctx.run(git_tag_cmd)


@invoke.task(optional=["version", "type_"])
def release(ctx, version=None, type_="patch", yes=False, dry_run=False):
if version is None:
version = bump_version(ctx, type_, log=not dry_run, dry_run=dry_run)
else:
_write_version(version)
tag_content = get_changelog(ctx)
current_branch = _get_branch(ctx)
generate_news(ctx, yes=yes, dry_run=dry_run)
git_commit_cmd = f'git commit -am "Release {version}"'
git_tag_cmd = f'git tag -a {version} -m "Version {version}\n\n{tag_content}"'
git_push_cmd = f"git push origin {current_branch}"
git_push_tags_cmd = "git push --tags"
if dry_run:
print("Would run commands:")
print(f" {git_commit_cmd}")
print(f" {git_tag_cmd}")
print(f" {git_push_cmd}")
print(f" {git_push_tags_cmd}")
else:
ctx.run(git_commit_cmd)
ctx.run(git_tag_cmd)
ctx.run(git_push_cmd)
print("Waiting 5 seconds before pushing tags...")
time.sleep(5)
ctx.run(git_push_tags_cmd)


@invoke.task(pre=[clean])
def release(ctx, type_, repo, prebump=PREBUMP, yes=False):
"""Make a new release."""
def full_release(ctx, type_, repo, prebump=PREBUMP, yes=False):
"""Make a new release.
"""
if prebump not in REL_TYPES:
raise ValueError(f"{type_} not in {REL_TYPES}")
prebump = REL_TYPES.index(prebump)

version = bump_version(ctx, type_, log=True)

# Needs to happen before Towncrier deletes fragment files.
tag_release(ctx, version, yes=yes)

tag_release(version, yes=yes)

ctx.run(f"python setup.py sdist bdist_wheel")

Expand Down
8 changes: 5 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,14 @@ def setup_pythons(isolated_envdir, monkeypatch):
@pytest.fixture
def special_character_python(tmpdir):
finder = pythonfinder.Finder(
global_search=True, system=False, ignore_unsupported=True
global_search=False, system=True, ignore_unsupported=True,
sort_by_path=True
)
python = finder.find_python_version("2")
python_name = "{0}+".format(python.name)
python = finder.find_python_version()
python_name = "2+"
python_folder = tmpdir.mkdir(python_name)
bin_dir = python_folder.mkdir("bin")
vistir.path.set_write_bit(bin_dir.strpath)
python_path = bin_dir.join("python")
os.link(python.path.as_posix(), python_path.strpath)
return python_path
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
docs, packaging, py27, py35, py36, py37, coverage-report
docs, packaging, py27, py35, py36, py37, py38, coverage-report

[testenv]
passenv = CI GIT_SSL_CAINFO
Expand Down

0 comments on commit fbd35fa

Please sign in to comment.