Repository: stummjr/scrapy-fieldstats (language: python)

Issue:
Setup Github actions for tests and linting



Discussion / hints:

Fix patch:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 5cd1572..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-# Config file for automatic testing at travis-ci.org
-# This file will be regenerated if you run travis_pypi_setup.py
-
-language: python
-python:
-  - 3.5
-  - 3.4
-  - 3.3
-  - 2.7
-  - 2.6
-
-# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
-install: pip install -U tox-travis
-
-# command to run tests, e.g. python setup.py test
-script: tox
-
-# After you create the Github repo and add it to Travis, run the
-# travis_pypi_setup.py script to finish PyPI deployment setup
-deploy:
-  provider: pypi
-  distributions: sdist bdist_wheel
-  user: stummjr
-  password:
-    secure: PLEASE_REPLACE_ME
-  on:
-    tags: true
-    repo: stummjr/scrapy_fieldstats
-    python: 2.7
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 965b2dd..0000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,11 +0,0 @@
-include AUTHORS.rst
-include CONTRIBUTING.rst
-include HISTORY.rst
-include LICENSE
-include README.rst
-
-recursive-include tests *
-recursive-exclude * __pycache__
-recursive-exclude * *.py[co]
-
-recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
diff --git a/Makefile b/Makefile
deleted file mode 100644
index b59d42c..0000000
--- a/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-.PHONY: clean clean-test clean-pyc clean-build docs help
-.DEFAULT_GOAL := help
-define BROWSER_PYSCRIPT
-import os, webbrowser, sys
-try:
-	from urllib import pathname2url
-except:
-	from urllib.request import pathname2url
-
-webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
-endef
-export BROWSER_PYSCRIPT
-
-define PRINT_HELP_PYSCRIPT
-import re, sys
-
-for line in sys.stdin:
-	match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
-	if match:
-		target, help = match.groups()
-		print("%-20s %s" % (target, help))
-endef
-export PRINT_HELP_PYSCRIPT
-BROWSER := python -c "$$BROWSER_PYSCRIPT"
-
-help:
-	@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
-
-clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
-
-
-clean-build: ## remove build artifacts
-	rm -fr build/
-	rm -fr dist/
-	rm -fr .eggs/
-	find . -name '*.egg-info' -exec rm -fr {} +
-	find . -name '*.egg' -exec rm -f {} +
-
-clean-pyc: ## remove Python file artifacts
-	find . -name '*.pyc' -exec rm -f {} +
-	find . -name '*.pyo' -exec rm -f {} +
-	find . -name '*~' -exec rm -f {} +
-	find . -name '__pycache__' -exec rm -fr {} +
-
-clean-test: ## remove test and coverage artifacts
-	rm -fr .tox/
-	rm -f .coverage
-	rm -fr htmlcov/
-
-lint: ## check style with flake8
-	flake8 scrapy_fieldstats tests
-
-test: ## run tests quickly with the default Python
-	py.test
-	
-
-test-all: ## run tests on every Python version with tox
-	tox
-
-coverage: ## check code coverage quickly with the default Python
-	coverage run --source scrapy_fieldstats -m pytest
-	coverage report -m
-	coverage html
-	$(BROWSER) htmlcov/index.html
-
-docs: ## generate Sphinx HTML documentation, including API docs
-	rm -f docs/scrapy_fieldstats.rst
-	rm -f docs/modules.rst
-	sphinx-apidoc -o docs/ scrapy_fieldstats
-	$(MAKE) -C docs clean
-	$(MAKE) -C docs html
-	$(BROWSER) docs/_build/html/index.html
-
-servedocs: docs ## compile the docs watching for changes
-	watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
-
-release: clean ## package and upload a release
-	python setup.py sdist upload
-	python setup.py bdist_wheel upload
-
-dist: clean ## builds source and wheel package
-	python setup.py sdist
-	python setup.py bdist_wheel
-	ls -l dist
-
-install: clean ## install the package to the active Python's site-packages
-	python setup.py install
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..ecb781a
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,1 @@
+scrapy==2.0.1
diff --git a/requirements_dev.txt b/requirements_dev.txt
deleted file mode 100644
index 7fc2ffa..0000000
--- a/requirements_dev.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-pip==8.1.2
-bumpversion==0.5.3
-wheel==0.29.0
-watchdog==0.8.3
-flake8==2.6.0
-tox==2.3.1
-coverage==4.1
-Sphinx==1.4.8
-cryptography==1.7
-PyYAML==3.11
-pytest==2.9.2
-pytest-runner==2.11.1
-scrapy==1.4.0
-
diff --git a/setup.py b/setup.py
index 61d77d1..2c1f0a5 100644
--- a/setup.py
+++ b/setup.py
@@ -30,8 +30,10 @@
         'Intended Audience :: Developers',
         'License :: OSI Approved :: MIT License',
         'Natural Language :: English',
-        'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
+        'Programming Language :: Python :: 3.8',
     ],
     test_suite='tests',
     tests_require=test_requirements,
diff --git a/tox.ini b/tox.ini
index e025e2a..78c9a1d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,30 +1,12 @@
 [tox]
-envlist = py26, py27, py33, py34, py35, flake8
-
-[travis]
-python =
-    3.5: py35
-    3.4: py34
-    3.3: py33
-    2.7: py27
-    2.6: py26
-
-[testenv:flake8]
-basepython=python
-deps=flake8
-commands=flake8 scrapy_fieldstats
+envlist = py38
 
 [testenv]
-setenv =
-    PYTHONPATH = {toxinidir}
 deps =
-    -r{toxinidir}/requirements_dev.txt
+    pytest
+    scrapy
 commands =
-    pip install -U pip
-    py.test --basetemp={envtmpdir}
-
+    pytest
 
-; If you want to make tox run the tests with the same versions, create a
-; requirements.txt with the pinned versions and uncomment the following lines:
-; deps =
-;     -r{toxinidir}/requirements.txt
+[flake8]
+max-line-length = 120
diff --git a/travis_pypi_setup.py b/travis_pypi_setup.py
deleted file mode 100644
index 5b65572..0000000
--- a/travis_pypi_setup.py
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-"""Update encrypted deploy password in Travis config file."""
-
-
-from __future__ import print_function
-import base64
-import json
-import os
-from getpass import getpass
-import yaml
-from cryptography.hazmat.primitives.serialization import load_pem_public_key
-from cryptography.hazmat.backends import default_backend
-from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15
-
-
-try:
-    from urllib import urlopen
-except ImportError:
-    from urllib.request import urlopen
-
-
-GITHUB_REPO = 'stummjr/scrapy_fieldstats'
-TRAVIS_CONFIG_FILE = os.path.join(
-    os.path.dirname(os.path.abspath(__file__)), '.travis.yml')
-
-
-def load_key(pubkey):
-    """Load public RSA key.
-
-    Work around keys with incorrect header/footer format.
-
-    Read more about RSA encryption with cryptography:
-    https://cryptography.io/latest/hazmat/primitives/asymmetric/rsa/
-    """
-    try:
-        return load_pem_public_key(pubkey.encode(), default_backend())
-    except ValueError:
-        # workaround for https://github.com/travis-ci/travis-api/issues/196
-        pubkey = pubkey.replace('BEGIN RSA', 'BEGIN').replace('END RSA', 'END')
-        return load_pem_public_key(pubkey.encode(), default_backend())
-
-
-def encrypt(pubkey, password):
-    """Encrypt password using given RSA public key and encode it with base64.
-
-    The encrypted password can only be decrypted by someone with the
-    private key (in this case, only Travis).
-    """
-    key = load_key(pubkey)
-    encrypted_password = key.encrypt(password, PKCS1v15())
-    return base64.b64encode(encrypted_password)
-
-
-def fetch_public_key(repo):
-    """Download RSA public key Travis will use for this repo.
-
-    Travis API docs: http://docs.travis-ci.com/api/#repository-keys
-    """
-    keyurl = 'https://api.travis-ci.org/repos/{0}/key'.format(repo)
-    data = json.loads(urlopen(keyurl).read().decode())
-    if 'key' not in data:
-        errmsg = "Could not find public key for repo: {}.\n".format(repo)
-        errmsg += "Have you already added your GitHub repo to Travis?"
-        raise ValueError(errmsg)
-    return data['key']
-
-
-def prepend_line(filepath, line):
-    """Rewrite a file adding a line to its beginning."""
-    with open(filepath) as f:
-        lines = f.readlines()
-
-    lines.insert(0, line)
-
-    with open(filepath, 'w') as f:
-        f.writelines(lines)
-
-
-def load_yaml_config(filepath):
-    """Load yaml config file at the given path."""
-    with open(filepath) as f:
-        return yaml.load(f)
-
-
-def save_yaml_config(filepath, config):
-    """Save yaml config file at the given path."""
-    with open(filepath, 'w') as f:
-        yaml.dump(config, f, default_flow_style=False)
-
-
-def update_travis_deploy_password(encrypted_password):
-    """Put `encrypted_password` into the deploy section of .travis.yml."""
-    config = load_yaml_config(TRAVIS_CONFIG_FILE)
-
-    config['deploy']['password'] = dict(secure=encrypted_password)
-
-    save_yaml_config(TRAVIS_CONFIG_FILE, config)
-
-    line = ('# This file was autogenerated and will overwrite'
-            ' each time you run travis_pypi_setup.py\n')
-    prepend_line(TRAVIS_CONFIG_FILE, line)
-
-
-def main(args):
-    """Add a PyPI password to .travis.yml so that Travis can deploy to PyPI.
-
-    Fetch the Travis public key for the repo, and encrypt the PyPI password
-    with it before adding, so that only Travis can decrypt and use the PyPI
-    password.
-    """
-    public_key = fetch_public_key(args.repo)
-    password = args.password or getpass('PyPI password: ')
-    update_travis_deploy_password(encrypt(public_key, password.encode()))
-    print("Wrote encrypted password to .travis.yml -- you're ready to deploy")
-
-
-if '__main__' == __name__:
-    import argparse
-    parser = argparse.ArgumentParser(description=__doc__)
-    parser.add_argument('--repo', default=GITHUB_REPO,
-                        help='GitHub repo (default: %s)' % GITHUB_REPO)
-    parser.add_argument('--password',
-                        help='PyPI password (will prompt if not provided)')
-
-    args = parser.parse_args()
-    main(args)


Test patch:
diff --git a/.github/workflows/lintandtest.yml b/.github/workflows/lintandtest.yml
index 5a06dc5..0918149 100644
--- a/.github/workflows/lintandtest.yml
+++ b/.github/workflows/lintandtest.yml
@@ -20,6 +20,9 @@ jobs:
       uses: actions/setup-python@v1
       with:
         python-version: ${{ matrix.python-version }}
+    - name: Install dependencies
+      run: |
+        pip install -r requirements.txt
     - name: Lint with flake8
       run: |
         pip install flake8