From fe99a9201b2c7217bce8a80193f31b53377f29ed Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Mon, 24 Feb 2020 20:36:13 -0500 Subject: [PATCH 1/8] Remove .travis.yml --- .travis.yml | 74 ----------------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6bc71ee1..00000000 --- a/.travis.yml +++ /dev/null @@ -1,74 +0,0 @@ -services: - - docker -dist: xenial - -language: python -python: - - "2.7" - - "3.5" - - "3.6" - - "3.7" - - "nightly" - -matrix: - allow_failures: - - python: "nightly" - -env: - global: - - MUSL_PATH=$HOME/musl - - CC=$MUSL_PATH/bin/musl-gcc - -cache: - directories: - - $MUSL_PATH - -before_script: - - ci/install_musl-libc.sh - - docker version - - ci/test_setup.sh - - pip install wheel - -script: - # Build and install a wheel - # This is the preferred installation mechanism (see #71) - - python setup.py bdist_wheel - - pip install dist/scuba-*-py2.py3-none-any.whl - - # Run the unit tests in isolation - - ./run_nosetests.py --no-local-import - - ./run_full_tests.py - -after_success: - - bash <(curl -s https://codecov.io/bash) - - -jobs: - include: - - stage: deploy - python: 3.6 - script: echo "Deploying to PyPI..." - deploy: - - # Test PyPI (on any push to master) - - provider: pypi - server: https://test.pypi.org/legacy/ - user: jreinhart - password: - secure: "BYbUHbV3G2lsvDDR9LrYCRFz/g+LAI/pmfa+d+KMlXbY+s7v+pYsENRmwVbhpc1oDSn0UnKgJyc3ZyGAEkmlV0Cog9YxWnoVQgmsT321jIuQur1SjeQ70mgkwS3fRh1hdzrfKkJ3SghFfFyrXzK1kyn8TzDBg7sSyymep2MgO+kRsYxIKP2e8GCTPLmXhifxAPDQZ6rDtRCl4fDgSoakLNsaHQPeaEgEN7E4699edce0lWN2g+2w3NGAmO6jdx3Ly64XX6MoM47/Pjdmi/xncqAqVQ37CCTIM2HRNClujy35KVnTOpjN0ZSsPuCYfx0aIOBzR3cCo7II2VBziQhQ09o1gJOEnd/q2/4rUoaa9Plu1SeO0yQxvjtBS+7iSDnZEDzqQvah/XidZzv6efmvNrme5ueTGnFUt+v4bq03Nu661Jat9FbaDb8NCi1qhnUG+ebJ4t3EIXqd4vIdu6M+1RdNqU5Wmf4j6IUutrjnF8qOexG0hh/MkdiSO6o+cEbltiMhr+Z+F6Y7j9snsqqYvnZ42mjf7KNKfX56/hfi8do2Z9Lb3V9xTHqiL9reRPQdq5s+iXmC75/Ca9rZv6UtNRPt56FdBtEEWGuFcbenZRk/av2baX/MFbqGZbToQ0KbiDcDQNKZGNeaH6+6YfSvjhmFUtM/duhmQaCfcXjhoZA=" - distributions: "sdist bdist_wheel" - on: - branch: master - tags: false - repo: JonathonReinhart/scuba - - # Production PyPI (only on tags) - - provider: pypi - user: jreinhart - password: - secure: "kbjV+UQNXYZbW3jGMaEvK4wYUorVMyrzn5fdVqKmTMLVB6Rl/MwABi5O8ciVHf0bAZzi1xuGud399zLEMWG0P5fYE5UfJplRTg22p/urwZ7OoLQGgD8v5QcOfyyPOGxriapE0I05VdrVi1MUeD6mwQLVOnrVPOSBW/PWvgguyyW9tqWkHCo7flhx8Me5EgD3+39d9027Uaw8IGZFvwCiB6xghOJn8vr2ADhGA/yZtx674UOkmiVMrh7eFLnbSHxiWemTCsf1UiqKF7UyQ7Z6j5qTno+HWPX++Z8nsAdma48jYJQt6OIfXgz8TIStuJxzile5l67TqEZ8QNN7bjggkUKSMSS+v91E0fkc35saGZqKIXQ1Mj3xDgCk91kyaahNfo+pnrxb/wyc/3PaXkTnm517v/b8J6tUR583pYnNcfhiPQWnNGCYI3T0I2JSAvVaCMc3ab0B9jSxia5maiL9AtuPNHa1aB97hgTxQHYazCd8a7X0Bnvl/eiFsr9XQudDM8AG2U8wvKmbf/MCZlMMvptD7UNP1KXEhoUih4XtOKnYeCrpgW9ID83RSae6ClqtQBxTZlRoh9nzxBQMa6NbM3+I6cpDUgfP3oMzMrqaJ38eVlgT7ReFUcfNVb7MworCkca1lNKPLNo1zib0+sWwqbqLSTwP/7+gW5EGkO1fPzU=" - distributions: "sdist bdist_wheel" - on: - branch: master - tags: true - repo: JonathonReinhart/scuba From 37cf1e5baa0c4f780496023949d10082957865e9 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Fri, 21 Feb 2020 20:31:52 -0500 Subject: [PATCH 2/8] Set up initial GitHub workflow for Python Based loosely on https://github.com/actions/starter-workflows/blob/48ae89ff/ci/python-package.yml --- .github/workflows/build-test.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/build-test.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..a3675b12 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -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 From baf75a2536929f76324cf737a1e0dc747f16b0c8 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Fri, 21 Feb 2020 22:13:45 -0500 Subject: [PATCH 3/8] Implement skipUnlessTty and apply to tty tests --- tests/test_main.py | 2 ++ tests/utils.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index c2ad9637..892b8bdf 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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() @@ -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() diff --git a/tests/utils.py b/tests/utils.py index 5621efee..37be80f7 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -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 From 85e72441b79b1ca14ad39bbca338c2ff24f299e0 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Sun, 23 Feb 2020 19:44:28 -0500 Subject: [PATCH 4/8] Don't pin coverage at <4 --- requirements.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2d89270b..67b4c4a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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' From 18bad1de25b951c16790590463080221f1c251d6 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Mon, 24 Feb 2020 19:53:58 -0500 Subject: [PATCH 5/8] Add publish-release workflow Based on https://github.com/actions/starter-workflows/blob/48ae89ff988026eaeb436a3f0f3502a3e7dcc6ab/ci/python-publish.yml --- .github/workflows/publish-release.yml | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..be10c5f0 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,33 @@ +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: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From 9dbbacd104a4298d6dd181218f0cd0875c202dc5 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Mon, 24 Feb 2020 20:07:59 -0500 Subject: [PATCH 6/8] Add publish-master workflow --- .github/workflows/publish-master.yml | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/publish-master.yml diff --git a/.github/workflows/publish-master.yml b/.github/workflows/publish-master.yml new file mode 100644 index 00000000..514b9844 --- /dev/null +++ b/.github/workflows/publish-master.yml @@ -0,0 +1,37 @@ +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: + 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/* From 2845028ce86606b8113678fe4cd57f960379197c Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Mon, 24 Feb 2020 21:00:12 -0500 Subject: [PATCH 7/8] Build python packages with musl-gcc --- .github/workflows/publish-master.yml | 1 + .github/workflows/publish-release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/publish-master.yml b/.github/workflows/publish-master.yml index 514b9844..fbb9ddf1 100644 --- a/.github/workflows/publish-master.yml +++ b/.github/workflows/publish-master.yml @@ -30,6 +30,7 @@ jobs: - name: Build and publish env: + CC: /usr/bin/musl-gcc TWINE_USERNAME: ${{ secrets.PYPI_TEST_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }} run: | diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index be10c5f0..37cdb93c 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -26,6 +26,7 @@ jobs: - name: Build and publish env: + CC: /usr/bin/musl-gcc TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | From e08e3da14526176ce2998a6c737b523f1cfb2fc7 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Mon, 24 Feb 2020 21:02:46 -0500 Subject: [PATCH 8/8] Set version for master publish to github run_id --- .github/workflows/publish-master.yml | 1 + setup.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-master.yml b/.github/workflows/publish-master.yml index fbb9ddf1..b1dd6527 100644 --- a/.github/workflows/publish-master.yml +++ b/.github/workflows/publish-master.yml @@ -31,6 +31,7 @@ jobs: - 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: | diff --git a/setup.py b/setup.py index 5e6d49c8..0d990d2f 100644 --- a/setup.py +++ b/setup.py @@ -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__ ################################################################################