Repository: inveniosoftware/pynpm (language: python)

Issue:
global: migration to github-actions from travis



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml
new file mode 100644
index 0000000..a158b22
--- /dev/null
+++ b/.github/workflows/pypi-publish.yml
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of Invenio.
+# Copyright (C) 2020 CERN.
+#
+# Invenio is free software; you can redistribute it and/or modify it
+# under the terms of the MIT License; see LICENSE file for more details.
+
+name: Publish
+
+on:
+  push:
+    tags:
+      - v*
+
+jobs:
+  Publish:
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.7
+
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install setuptools wheel
+
+      - name: Build package
+        run: |
+          python setup.py sdist bdist_wheel
+
+      - name: Publish on PyPI
+        uses: pypa/gh-action-pypi-publish@v1.3.1
+        with:
+          user: __token__
+          password: ${{ secrets.pypi_token }}
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1c16f4a..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# This file is part of PyNPM
-# Copyright (C) 2017 CERN.
-#
-# PyNPM is free software; you can redistribute it and/or modify
-# it under the terms of the Revised BSD License; see LICENSE file for
-# more details.
-
-notifications:
-  email: false
-
-sudo: false
-
-language: python
-
-matrix:
-  fast_finish: true
-  allow_failures:
-    - env: REQUIREMENTS=devel
-    - python: 3.8
-
-cache:
-  - pip
-
-env:
-  - REQUIREMENTS=lowest
-  - REQUIREMENTS=release
-  - REQUIREMENTS=devel
-
-python:
-  - "3.6"
-  - "3.7"
-  - "3.8"
-
-before_install:
-  - "nvm install 6; nvm use 6"
-  # Install Yarn
-  - curl -o- -L https://yarnpkg.com/install.sh | bash
-  - export PATH="$HOME/.yarn/bin:$PATH"
-  - "travis_retry pip install --upgrade pip setuptools py"
-  - "travis_retry pip install twine wheel coveralls requirements-builder"
-  - "requirements-builder -e all --level=min setup.py > .travis-lowest-requirements.txt"
-  - "requirements-builder -e all --level=pypi setup.py > .travis-release-requirements.txt"
-  - "requirements-builder -e all --level=dev --req requirements-devel.txt setup.py > .travis-devel-requirements.txt"
-
-install:
-  - "travis_retry pip install -r .travis-${REQUIREMENTS}-requirements.txt"
-  - "travis_retry pip install -e .[all]"
-
-script:
-  - "./run-tests.sh"
-
-after_success:
-  - coveralls
-
-deploy:
-  provider: pypi
-  user: inveniosoftware
-  password:
-    secure: "pMGIcd7+R5ZkZ8Wv52mI9kK25sWH/Q6pZnCDESCtfZw9VUtdVQriei3Lv1gd7g3hVqLKyjWtPRZ1EuvQqKKogVJGxbvxrm1U3BHTuG/HjC22O4TAyK7xQEqVi0EwYySJYhl1oXlkkeyUuD2oxSEQ0FJoVCYGVCcv7Vn13aczRlaxk8aoR3U6K1Y2gASH/bFL4XWDM1M0nHIt/HTaCdrgcugKxq4wtDZaW6W1AD5JYMUgpVRzD+UheeZOIeJgSFGsB1Ah3gjsQ4xjbfDV1DR/d/vIVdHsFH31NRMEgUs4Qs2SGcpP9EZSICoz75egb4fIVS3TUkjyNWc3xk4SGc/qZTf7kKXlHdj43qim+lMlwfoYREKYYh33POjtrWls8P39q7OzCTjsM7FOLOXci9N7ncEmAN8wHweCUxwoIxQwS+C8P/Cs7bGaQsc1F05N25fAyrSAZhFAsqpyrhKg1uOAwMohawwYbsXuo71cKTriQXuVyZb8cM1LhTYPyXkhggJS2x4xgJxFc+t5dHRifd/XJyJ+8EbPkckqjqxM0VpDgXqAKKBLb6Rzp4vdD2o/toxyR+H2sDYkwsN5lTrcdApBv2CFF6BgJccKZ9Vj2mXXrcXBOkt8avUEIiu2AcyFILcXe/8iv0NW0xGMPQKEgLPAuEU42bkLuL456SrjvcyN/t8="
-  distributions: "sdist bdist_wheel"
-  on:
-    tags: true
-  skip_existing: true
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 0121dfb..aba4cdd 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -114,5 +114,5 @@ Before you submit a pull request, check that it meets these guidelines:
 2. If the pull request adds functionality, the docs should be updated. Put
    your new functionality into a function with a docstring.
 3. The pull request should work for Python 2.7, 3.3, 3.4 and 3.5. Check
-   https://travis-ci.org/inveniosoftware/pynpm/pull_requests
+   https://github.com/inveniosoftware/pynpm/actions?query=event%3Apull_request
    and make sure that the tests pass for all supported Python versions.
diff --git a/MANIFEST.in b/MANIFEST.in
index e1469ea..adf5154 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -24,3 +24,4 @@ recursive-include docs Makefile
 recursive-include tests *.js
 recursive-include tests *.json
 recursive-include tests *.py
+recursive-include .github/workflows *.yml
diff --git a/README.rst b/README.rst
index 6df80ff..b454ed2 100644
--- a/README.rst
+++ b/README.rst
@@ -2,8 +2,8 @@
  PyNPM
 =======
 
-.. image:: https://img.shields.io/travis/inveniosoftware/pynpm.svg
-        :target: https://travis-ci.org/inveniosoftware/pynpm
+.. image:: https://github.com/inveniosoftware/pynpm/workflows/CI/badge.svg
+        :target: https://github.com/inveniosoftware/pynpm/actions?query=workflow%3ACI
 
 .. image:: https://img.shields.io/coveralls/inveniosoftware/pynpm.svg
         :target: https://coveralls.io/r/inveniosoftware/pynpm
diff --git a/setup.py b/setup.py
index 6b6015f..f34462c 100644
--- a/setup.py
+++ b/setup.py
@@ -17,19 +17,13 @@
 history = open('CHANGES.rst').read()
 
 tests_require = [
-    'check-manifest>=0.25',
-    'coverage>=4.0',
-    'isort>=4.2.2',
-    'pydocstyle>=1.0.0',
     'pytest-cache>=1.0',
-    'pytest-cov>=1.8.0',
-    'pytest-pep8>=1.0.6',
-    'pytest>=2.8.0',
+    'pytest-invenio>=1.4.0'
 ]
 
 extras_require = {
     'docs': [
-        'Sphinx>=1.5.1',
+        'Sphinx>=3',
     ],
     'tests': tests_require,
 }


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..6112efa
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of Invenio.
+# Copyright (C) 2020 CERN.
+#
+# Invenio is free software; you can redistribute it and/or modify it
+# under the terms of the MIT License; see LICENSE file for more details.
+
+name: CI
+
+on:
+  push:
+    branches: master
+  pull_request:
+    branches: master
+  schedule:
+    # * is a special character in YAML so you have to quote this string
+    - cron:  '0 3 * * 6'
+  workflow_dispatch:
+    inputs:
+      reason:
+        description: 'Reason'
+        required: false
+        default: 'Manual trigger'
+
+jobs:
+  Tests:
+    runs-on: ubuntu-20.04
+    timeout-minutes: 20
+    strategy:
+      matrix:
+          python-version: [3.6, 3.7, 3.8]
+          requirements-level: [min, pypi]
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+
+      - name: Generate dependencies
+        run: |
+          python -m pip install --upgrade pip setuptools py wheel requirements-builder
+          requirements-builder -e all --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
+
+      - name: Cache pip
+        uses: actions/cache@v2
+        with:
+          path: ~/.cache/pip
+          key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}
+
+      - name: Install dependencies
+        run: |
+          pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
+          pip install .[all]
+          pip freeze
+
+      - name: Run tests
+        run: |
+          ./run-tests.sh
diff --git a/pytest.ini b/pytest.ini
index c4ed7f0..b3c4720 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -8,5 +8,5 @@
 # more details.
 
 [pytest]
-pep8ignore = docs/conf.py ALL
-addopts = --pep8 --doctest-glob="*.rst" --doctest-modules --cov=pynpm --cov-report=term-missing docs tests pynpm
+addopts = --isort --pydocstyle --pycodestyle --doctest-glob="*.rst" --doctest-modules --cov=pynpm --cov-report=term-missing
+testpaths = tests pynpm
\ No newline at end of file
diff --git a/run-tests.sh b/run-tests.sh
index 139e4a5..431dfff 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -1,14 +1,19 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
 #
-# This file is part of PyNPM
-# Copyright (C) 2017 CERN.
+# This file is part of Invenio.
+# Copyright (C) 2015-2020 CERN.
 #
-# PyNPM is free software; you can redistribute it and/or modify
-# it under the terms of the Revised BSD License; see LICENSE file for
-# more details.
+# Invenio is free software; you can redistribute it and/or modify it
+# under the terms of the MIT License; see LICENSE file for more details.
 
-pydocstyle pynpm tests docs && \
-isort -rc -c -df && \
-check-manifest --ignore ".travis-*" && \
-sphinx-build -qnNW docs docs/_build/html && \
-python setup.py test
+# Quit on errors
+set -o errexit
+
+# Quit on unbound symbols
+set -o nounset
+
+python -m check_manifest --ignore ".*-requirements.txt"
+python -m sphinx.cmd.build -qnNW docs docs/_build/html
+python -m pytest
+python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest
diff --git a/tests/test_pynpm.py b/tests/test_pynpm.py
index 18780ae..dddd95e 100644
--- a/tests/test_pynpm.py
+++ b/tests/test_pynpm.py
@@ -61,9 +61,9 @@ def test_command_nowait(pkg):
     npmpkg = NPMPackage(pkg)
     proc = npmpkg.run_script('test', wait=False)
     # Just check output of last line
-    for l in proc.stdout:
+    for line in proc.stdout:
         pass
-    assert l.decode() == u'test\n'
+    assert line.decode() == u'test\n'
 
 
 def test_command_install(pkg, deppkg):