Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate github actions instead of travis-ci. #27

Merged
merged 1 commit into from
Jul 16, 2021
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
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint

on:
push:
pull_request:
type: [ "opened", "reopened", "synchronize" ]

env:
FORCE_COLOR: 1

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/pre-commit
key:
lint-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
lint-v1-
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install pre-commit
- name: Lint
run: |
pre-commit run --all-files --show-diff-on-failure
env:
PRE_COMMIT_COLOR: always
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This is a basic workflow to help you get started with Actions

name: Unit tests

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
pull_request:
type: [ "opened", "reopened", "synchronize" ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]

# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# Runs a set of commands using the runners shell
- name: Setup
run: pip install tox

- name: Show environment
run: set

- name: Test
run: tox -e py -- -vv
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-yapf
rev: 'v0.30.0' # Use the sha / tag you want to point at
hooks:
- id: yapf
args: [-i, -p]
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ $ time ./ducker wikpedia
the Python 3 interpreter available in your PATH as `python3` and then can
either detect the newest Python or select the best python of your choice.

Two disable the automatic detection of the newest version and provide a
Two disable the automatic detection of the newest version and provide a
list of acceptable Python versions (tried in the order you list them)
add the following line to your requirements.txt file:

```
# appenv-python-preference: 3.1,3.9,3.4
# appenv-python-preference: 3.6,3.9,3.8
```

The best version that is found on the system will be used to re-spawn appenv
and then also used to manage the virtual environments for your application.

AppEnv itself is tested against Python 3.4+.
AppEnv itself is tested against Python 3.6+.

## Learning more about appenv

Expand All @@ -84,3 +84,12 @@ positional arguments:
options:
-h, --help show this help message and exit
```

## Testing

If you want to contribute, please install `tox` and run it.

```
$ tox

```
2 changes: 0 additions & 2 deletions pyproject.toml

This file was deleted.

2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
addopts = -W error --tb=native --flake8 --cov=appenv --cov-report=html
addopts = -W error --tb=native --cov=appenv --cov-report=html
testpaths = tests
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
-e .
pytest==4.6.10
pytest
pytest-cov
pytest-flake8
more-itertools==7.2.0
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[yapf]
based_on_style = pep8
column_limit = 79
split_before_expression_after_opening_paren = true
split_before_closing_bracket = false
SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET = false
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from setuptools import setup, find_packages


setup(
name='appenv',
version='0.2.dev0',
Expand All @@ -22,6 +21,7 @@
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3 :: Only
"""[:-1].split('\n'),
description=__doc__.strip(),
Expand All @@ -30,4 +30,5 @@
include_package_data=True,
zip_safe=True,
python_requires='>=3.6',
)
extras_require={'test': {
'pytest',}})
22 changes: 9 additions & 13 deletions src/appenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,8 @@ def ensure_venv(target):

print("Ensuring pip ...")
cmd("{target}/bin/python -m ensurepip --default-pip".format(target=target))
if python_maj_min == "3.4":
# Last version of Pip supporting Python 3.4
cmd('{target}/bin/python -m pip install --upgrade "pip<19.2"'.format(
target=target))
else:
cmd("{target}/bin/python -m pip install --upgrade pip".format(
target=target))
cmd("{target}/bin/python -m pip install --upgrade pip".format(
target=target))


def ensure_best_python():
Expand Down Expand Up @@ -205,8 +200,8 @@ def meta(self):
# Parse the appenv arguments
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
p = subparsers.add_parser("update-lockfile",
help="Update the lock file.")
p = subparsers.add_parser(
"update-lockfile", help="Update the lock file.")
p.set_defaults(func=self.update_lockfile)

p = subparsers.add_parser("init", help="Create a new appenv project.")
Expand Down Expand Up @@ -264,8 +259,8 @@ def _prepare(self):
b"".join(hash_content)).hexdigest()[:8]
env_dir = os.path.join(self.appenv_dir, env_hash)

whitelist = set(
[env_dir, os.path.join(self.appenv_dir, "unclean")])
whitelist = set([
env_dir, os.path.join(self.appenv_dir, "unclean")])
for path in glob.glob(
"{appenv_dir}/*".format(appenv_dir=self.appenv_dir)):
if not path in whitelist:
Expand Down Expand Up @@ -382,8 +377,9 @@ def update_lockfile(self, args=None, remaining=None):
import pkg_resources

extra_specs = []
result = cmd("{tmpdir}/bin/python -m pip freeze".format(tmpdir=tmpdir),
merge_stderr=False).decode('ascii')
result = cmd(
"{tmpdir}/bin/python -m pip freeze".format(tmpdir=tmpdir),
merge_stderr=False).decode('ascii')
pinned_versions = {}
for line in result.splitlines():
if line.strip().startswith('-e '):
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest


@pytest.yield_fixture
@pytest.fixture
def workdir(tmpdir):
old = os.getcwd()
os.chdir(str(tmpdir))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ def test_bootstrap_and_run_python_with_lockfile(workdir, monkeypatch):
with open("ducker", "w") as f:
f.write(script)

output = subprocess.check_output('./appenv python -c "print(1)"',
shell=True)
output = subprocess.check_output(
'./appenv python -c "print(1)"', shell=True)
assert output == b"1\n"
24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tox]
envlist =
py36, py37, py38, py39, pre-commit
skip_missing_interpreters = true
allowlist_externals=git

[testenv]
usedevelop = true
setenv =
APPENV_BEST_PYTHON = {envpython}
extras = test
deps =
pytest-cov
commands = pytest {posargs}


[testenv:pre-commit]
basepython = python3.9
description = This env runs all linters configured in .pre-commit-config.yaml
skip_install = true
deps =
pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure