From 1d907de22752cfe5d608adeb164c39701a7155e9 Mon Sep 17 00:00:00 2001 From: Dean Jackson Date: Thu, 21 May 2020 00:04:34 +0200 Subject: [PATCH] Add GitHub Action for tests & coverage --- .github/workflows/run-tests.yml | 45 +++++++++++++++++++++++++++++++++ .travis.yml | 3 ++- README.md | 9 ++++++- bin/travis-install-deps.sh | 27 -------------------- requirements-ci.txt | 2 ++ requirements-test.txt | 14 +++++----- tests/test_util_lockfile.py | 2 +- 7 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/run-tests.yml delete mode 100755 bin/travis-install-deps.sh create mode 100644 requirements-ci.txt diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..65b05b6a --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,45 @@ +name: "build" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + run: + name: "tests & coverage" + runs-on: macos-latest + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 2.7 + + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-test.txt + + - name: Lint + run: ./run-tests.sh -l + + - name: Unit tests + run: ./run-tests.sh + + - name: Install coverage dependencies + run: pip install -r requirements-ci.txt + + - name: Codacy + run: python-codacy-coverage -r coverage.xml -c ${{ github.sha }} || exit 0 + + - name: Coveralls + run: coveralls || exit 0 + + - name: Codecov + run: bash <(curl -s https://codecov.io/bash) || exit 0 diff --git a/.travis.yml b/.travis.yml index e0158ef8..9eae351b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,8 @@ install: - git clone https://github.com/MacPython/terryfy - source terryfy/travis_tools.sh - get_python_environment $SOURCE $VERSION venv - - bin/travis-install-deps.sh + - pip install -r requirements-test.txt + - pip install -r requirements-ci.txt script: - ./run-tests.sh diff --git a/README.md b/README.md index 8e7c2a18..89be00e7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,12 @@ Alfred-Workflow A helper library in Python for authors of workflows for [Alfred 3 and 4][alfred]. -[![Build Status][shield-travis]][travis] [![Coverage Status][shield-coveralls]][coveralls] [![Latest Version][shield-version]][pypi] [![Development Status][shield-status]][pypi] [![Supported Python Versions][shield-pyversions]][pypi] + +[![Build Status][shield-github]][action-github] +[![Coverage Status][shield-coveralls]][coveralls] +[![Development Status][shield-status]][pypi] +[![Latest Version][shield-version]][pypi] +[![Supported Python Versions][shield-pyversions]][pypi] @@ -335,6 +340,8 @@ Workflows using Alfred-Workflow [shield-coveralls]: https://coveralls.io/repos/github/deanishe/alfred-workflow/badge.svg?branch=master [shield-docs]: https://readthedocs.org/projects/alfredworkflow/badge/?version=latest&style=flat [shield-download]: https://img.shields.io/pypi/dm/Alfred-Workflow.svg?style=flat +[shield-github]: https://github.com/deanishe/alfred-workflow/workflows/build/badge.svg +[action-github]: https://github.com/deanishe/alfred-workflow/actions?query=workflow%3Abuild [shield-health]: https://landscape.io/github/deanishe/alfred-workflow/master/landscape.png?style=flat [shield-licence]: https://pypip.in/license/Alfred-Workflow/badge.svg?style=flat [shield-status]: https://img.shields.io/pypi/status/Alfred-Workflow.svg?style=flat diff --git a/bin/travis-install-deps.sh b/bin/travis-install-deps.sh deleted file mode 100755 index 1f27999f..00000000 --- a/bin/travis-install-deps.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# Install Python dependencies for Travis-CI.org - -set -e - -log() { - echo "$@" > /dev/stderr -} - -export CC=clang - -log "----------------- Test dependencies ----------------" -pip install \ - pytest \ - coveralls \ - codacy-coverage \ - pytest_cov \ - pytest_httpbin \ - pytest_localserver - -if [[ "$VERSION" =~ ^2.7.* ]]; then - log "----------------------- PyObc ----------------------" - pip install pyobjc-core - pip install pyobjc-framework-Cocoa -fi - -log "---------------------- Done ------------------------" diff --git a/requirements-ci.txt b/requirements-ci.txt new file mode 100644 index 00000000..71c6786e --- /dev/null +++ b/requirements-ci.txt @@ -0,0 +1,2 @@ +codacy-coverage==1.3.11 +coveralls==1.11.1 diff --git a/requirements-test.txt b/requirements-test.txt index 80df6f3b..4e5a9c6c 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,9 +1,9 @@ -pyobjc-framework-Cocoa==5.2 -pytest==4.4.1 -pytest-cov==2.7.1 +pyobjc-framework-Cocoa==5.3 +pytest==4.6.10 +pytest-cov==2.8.1 pytest-httpbin==1.0.0 pytest-localserver==0.5.0 -tox==3.9.0 -twine==1.13.0 -flake8==3.7.7 -flake8-docstrings==1.3.0 +# tox==3.15.1 +# twine==1.15.0 +flake8==3.8.1 +flake8-docstrings==1.5.0 diff --git a/tests/test_util_lockfile.py b/tests/test_util_lockfile.py index c8d0943b..8241bbd5 100644 --- a/tests/test_util_lockfile.py +++ b/tests/test_util_lockfile.py @@ -102,7 +102,7 @@ def test_concurrent_access(paths): assert not os.path.exists(paths.lockfile) with open(paths.testfile) as fp: - lines = [l.strip() for l in fp.readlines()] + lines = [line.strip() for line in fp.readlines()] for line in lines: assert len(set(line)) == 1