Skip to content

Commit

Permalink
Merge pull request #152 from JonathonReinhart/setup-github-workflow
Browse files Browse the repository at this point in the history
Setup GitHub workflows
  • Loading branch information
JonathonReinhart committed Feb 25, 2020
2 parents f6511a2 + e08e3da commit e35c349
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 84 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
fail-fast: False

steps:
- uses: actions/checkout@v2

# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- run: git fetch --prune --unshallow

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
docker version
sudo apt-get update
sudo apt-get install -y musl-tools
ci/test_setup.sh
pip install wheel
- name: Run tests
run: |
python setup.py bdist_wheel
pip install dist/scuba-*-py2.py3-none-any.whl
./run_nosetests.py --no-local-import
./run_full_tests.py
39 changes: 39 additions & 0 deletions .github/workflows/publish-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Upload to Test PyPI

# On every push to master, push to Test PyPI
on:
push:
branches:
- master

# TODO: De-duplicate with python-publish-release.yml

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- run: git fetch --prune --unshallow

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build and publish
env:
CC: /usr/bin/musl-gcc
CI_VERSION_BUILD_NUMBER: ${{ github.run_id }}
TWINE_USERNAME: ${{ secrets.PYPI_TEST_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
34 changes: 34 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Upload to PyPI

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- run: git fetch --prune --unshallow

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build and publish
env:
CC: /usr/bin/musl-gcc
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

6 changes: 1 addition & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
PyYAML
nose

# Keep coverage at a lower version to prevent TravisCI failures:
# https://github.com/travis-ci/travis-ci/issues/4866
coverage<4

coverage
mock; python_version < '3.3'
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def read_project_file(path):
# Dynamic versioning

def get_version():
# Travis builds
# If we're not building for a tag, then append the build number
build_num = os.getenv('TRAVIS_BUILD_NUMBER')
build_tag = os.getenv('TRAVIS_TAG')
if (not build_tag) and (build_num != None):
# CI builds
# If CI_VERSION_BUILD_NUMBER is set, append that to the base version
build_num = os.getenv('CI_VERSION_BUILD_NUMBER')
if build_num:
return '{}.{}'.format(scuba.version.BASE_VERSION, build_num)

# Otherwise, use the auto-versioning
return scuba.version.__version__

################################################################################
Expand Down
2 changes: 2 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def _setup_test_tty(self):
f.write('if [ -t 1 ]; then echo "isatty"; else echo "notatty"; fi\n')
make_executable('check_tty.sh')

@skipUnlessTty()
def test_with_tty(self):
'''Verify docker allocates tty if stdout is a tty.'''
self._setup_test_tty()
Expand All @@ -261,6 +262,7 @@ def test_with_tty(self):

assert_str_equalish(out, 'isatty')

@skipUnlessTty()
def test_without_tty(self):
'''Verify docker doesn't allocate tty if stdout is not a tty.'''
self._setup_test_tty()
Expand Down
5 changes: 5 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def isatty(self):
return True


def skipUnlessTty():
return unittest.skipUnless(sys.stdin.isatty(),
"Can't test docker tty if not connected to a terminal")


class InTempDir(object):
def __init__(self, suffix='', prefix='tmp', delete=True):
self.delete = delete
Expand Down

0 comments on commit e35c349

Please sign in to comment.