From 716f0ba2a7fb3b20f3ae530a519a4942e86c1236 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 30 Mar 2021 11:13:51 +0200 Subject: [PATCH] publish releases from github actions and run tests on gha instead of travis --- .github/workflows/publish.yaml | 35 +++++++++++++++++++ .github/workflows/test.yaml | 64 ++++++++++++++++++++++++++++++++++ .travis.yml | 43 ----------------------- dev-requirements.txt | 2 +- release.sh | 5 +-- test.py | 5 ++- 6 files changed, 105 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/test.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..3dfe659 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,35 @@ +# Build releases and (on tags) publish to PyPI +name: Release + +# always build releases (to make sure wheel-building works) +# but only publish to PyPI on tags +on: + push: + pull_request: + +jobs: + build-release: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: install build package + run: | + pip install --upgrade pip + pip install build + pip freeze + + - name: build release + run: | + python -m build --sdist --wheel . + ls -l dist + + - name: publish to pypi + uses: pypa/gh-action-pypi-publish@v1.4.1 + if: startsWith(github.ref, 'refs/tags/') + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..4683932 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,64 @@ +name: Test + +on: + pull_request: + push: + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: pre-commit/action@v2.0.0 + + test: + runs-on: ${{ matrix.os }} + + strategy: + # Keep running even if one variation of the job fail + fail-fast: false + matrix: + os: + - ubuntu-20.04 + python: + - "2.7" + - "3.6" + - "3.7" + - "3.8" + - "3.9" + include: + - os: macos-latest + python: 3.8 + + steps: + - uses: actions/checkout@v2 + + - name: Install Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + # preserve pip cache to speed up installation + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-pip-${{ hashFiles('*requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Python dependencies + run: | + pip install --upgrade pip + pip install --upgrade --pre -r dev-requirements.txt . + pip freeze + + - name: Run tests + run: | + pytest -v --color=yes --cov=wurlitzer test.py + + - name: Submit codecov report + run: | + codecov diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e0877ca..0000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: python -python: - - 2.7 - - 3.4 - - 3.5 - - 3.6 - - nightly -branches: - only: - - master -before_install: - - | - # setup mac virtualenv - if [[ $(uname) == "Darwin" ]]; then - brew install python - python3 -m pip install virtualenv - virtualenv -p $(which python$PY) ./test-env - source ./test-env/bin/activate - fi -install: - - pip install --upgrade setuptools pip - - pip install --upgrade . -r dev-requirements.txt - - pip freeze -script: - - py.test --cov wurlitzer test.py -after_success: - - codecov -env: - global: - - HOMEBREW_NO_AUTO_UPDATE=1 -matrix: - include: - - os: osx - language: generic - env: - - PY=2 - - os: osx - language: generic - env: - - PY=3 - - os: linux - dist: xenial - python: 3.7 diff --git a/dev-requirements.txt b/dev-requirements.txt index 2439385..3b6b044 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,4 @@ codecov -mock +mock # python_version < '3.0' pytest>=2.8 pytest-cov diff --git a/release.sh b/release.sh index 695e12a..278a64d 100755 --- a/release.sh +++ b/release.sh @@ -2,8 +2,5 @@ set -e bumpversion release --tag -py.test test.py -python setup.py sdist bdist_wheel -twine upload dist/* bumpversion patch - +git push --follow-tags diff --git a/test.py b/test.py index 8efee9b..995882b 100644 --- a/test.py +++ b/test.py @@ -6,7 +6,10 @@ import time from tempfile import TemporaryFile -import mock +try: + from unitest import mock +except ImportError: + import mock from wurlitzer import ( PIPE,