From d9099480f571b3a5a1abd7b6906785e9e1b77410 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 22 Aug 2019 09:46:52 +0200 Subject: [PATCH 01/15] Try GitHub Actions CI From https://github.com/actions/starter-workflows/blob/master/ci/python-package.yml --- .github/workflows/python-package.yml | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 00000000..bc2f6416 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,34 @@ +name: Python package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [2.7, 3.5, 3.6, 3.7] + + steps: + - uses: actions/checkout@v1 + - 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 + - name: Lint with flake8 + run: | + pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pip install pytest + pytest From 423475242b56f2f16521ee3a73a6cb93c12278d3 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 22 Aug 2019 09:50:38 +0200 Subject: [PATCH 02/15] Python >= 3.6 --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index bc2f6416..0236a523 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -7,9 +7,9 @@ jobs: runs-on: ubuntu-latest strategy: - max-parallel: 4 + max-parallel: 2 matrix: - python-version: [2.7, 3.5, 3.6, 3.7] + python-version: [3.6, 3.7] steps: - uses: actions/checkout@v1 From 6a33f0a338b65dfecbaa1b06b7f6da7888e7e9ff Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 22 Aug 2019 09:54:37 +0200 Subject: [PATCH 03/15] Try on: [push,pull] --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0236a523..0c181e7e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,6 +1,6 @@ name: Python package -on: [push] +on: [push,pull] jobs: build: From 285f7ffed2c89ea6f7cd84ce69fe6c010e106a96 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 11:03:16 +0300 Subject: [PATCH 04/15] No requirements.txt here --- .github/workflows/python-package.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0c181e7e..0b9e93d1 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -20,7 +20,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - name: Lint with flake8 run: | pip install flake8 From 31549360e9f9992f07c03abf6ca5cd9e7351509e Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 18:08:40 +0300 Subject: [PATCH 05/15] Add check-yaml (and some others) to pre-commit --- .pre-commit-config.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 815f2dc1..6cb7aa1f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,3 +13,19 @@ repos: hooks: - id: flake8 language_version: python3.7 + + - repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort + language_version: python3.7 + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.4.0 + hooks: + - id: python-check-blanket-noqa + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml From 98eccfa1c24d11a2af313c8d37c7be91e3c48ffc Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 18:10:16 +0300 Subject: [PATCH 06/15] Run tox lint on GitHub Actions, like AP's lint.yml --- .github/workflows/python-package.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0b9e93d1..807b2ca7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,6 +1,6 @@ name: Python package -on: [push,pull] +on: [push,pull_request] jobs: build: @@ -9,25 +9,21 @@ jobs: strategy: max-parallel: 2 matrix: - python-version: [3.6, 3.7] + python-version: 3.7 steps: - uses: actions/checkout@v1 + - 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 - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest + python -m pip install --upgrade tox + + - name: Lint run: | - pip install pytest - pytest + tox -e lint From a3b548ef2f8b3dc38a3cd4a6a6321457008c2564 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 18:24:14 +0300 Subject: [PATCH 07/15] Fix isort and python-check-blanket-noqa --- example/example.py | 2 +- setup.cfg | 7 +++++++ src/pypistats/__init__.py | 1 + src/pypistats/cli.py | 3 +-- tests/test_cli.py | 1 - tests/test_pypistats.py | 3 +-- tests/test_pypistats_cache.py | 3 +-- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/example/example.py b/example/example.py index dbfc56de..967197e8 100644 --- a/example/example.py +++ b/example/example.py @@ -4,7 +4,7 @@ Example use of pypistats """ import argparse -from pprint import pprint # noqa +from pprint import pprint # noqa: F401 import pypistats diff --git a/setup.cfg b/setup.cfg index dcb6336c..e61f78a5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,3 +9,10 @@ license_file = LICENSE.txt [pycodestyle] max_line_length = 88 + +[tool:isort] +force_grid_wrap = 0 +include_trailing_comma = True +line_length = 88 +multi_line_output = 3 +use_parentheses = True diff --git a/src/pypistats/__init__.py b/src/pypistats/__init__.py index f0cdfef7..36f5a492 100644 --- a/src/pypistats/__init__.py +++ b/src/pypistats/__init__.py @@ -11,6 +11,7 @@ from pathlib import Path import pkg_resources + import requests from appdirs import user_cache_dir from pytablewriter import ( diff --git a/src/pypistats/cli.py b/src/pypistats/cli.py index f2a29649..6c02e6e0 100644 --- a/src/pypistats/cli.py +++ b/src/pypistats/cli.py @@ -6,9 +6,8 @@ import argparse from datetime import date, datetime -from dateutil.relativedelta import relativedelta - import pypistats +from dateutil.relativedelta import relativedelta cli = argparse.ArgumentParser() subparsers = cli.add_subparsers(dest="subcommand") diff --git a/tests/test_cli.py b/tests/test_cli.py index 0f5e2b9f..854bb1ef 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -7,7 +7,6 @@ import pytest from freezegun import freeze_time - from pypistats import cli diff --git a/tests/test_pypistats.py b/tests/test_pypistats.py index da7e6b8f..0977f126 100644 --- a/tests/test_pypistats.py +++ b/tests/test_pypistats.py @@ -8,9 +8,8 @@ import unittest from pathlib import Path -import requests_mock - import pypistats +import requests_mock from .data.python_minor import DATA as PYTHON_MINOR_DATA diff --git a/tests/test_pypistats_cache.py b/tests/test_pypistats_cache.py index ab7ddb19..9d61c32f 100644 --- a/tests/test_pypistats_cache.py +++ b/tests/test_pypistats_cache.py @@ -7,11 +7,10 @@ import unittest from pathlib import Path +import pypistats import requests_mock from freezegun import freeze_time -import pypistats - class TestPypiStatsCache(unittest.TestCase): def setUp(self): From 6a077e65a923ef95321f3b44c670f0914990b2a5 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 18:25:10 +0300 Subject: [PATCH 08/15] Fix syntax --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 807b2ca7..4433bbd6 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 2 matrix: - python-version: 3.7 + python-version: [3.7] steps: - uses: actions/checkout@v1 From 448aee4349f76290a5dd86c3758a5ff768bff385 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 18:41:01 +0300 Subject: [PATCH 09/15] Rename as lint workflow --- .github/workflows/{python-package.yml => lint.yml} | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename .github/workflows/{python-package.yml => lint.yml} (82%) diff --git a/.github/workflows/python-package.yml b/.github/workflows/lint.yml similarity index 82% rename from .github/workflows/python-package.yml rename to .github/workflows/lint.yml index 4433bbd6..60b8e2f4 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/lint.yml @@ -1,13 +1,12 @@ -name: Python package +name: Lint -on: [push,pull_request] +on: [push, pull_request] jobs: build: runs-on: ubuntu-latest strategy: - max-parallel: 2 matrix: python-version: [3.7] @@ -25,5 +24,4 @@ jobs: python -m pip install --upgrade tox - name: Lint - run: | - tox -e lint + run: tox -e lint From 5f8a35ad0c2f1544e28eabdb0bcf5a4b38ef9c80 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 21:29:48 +0300 Subject: [PATCH 10/15] Unit tests with tox --- .github/workflows/test.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..253935cd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.6, 3.7] + os: [ubuntu-latest, macOS-latest, windows-latest] + + steps: + - uses: actions/checkout@v1 + + - 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 + python -m pip install --upgrade tox + + - name: Unit tests + # Drop the dot: py3.7 -> py37 + run: | + tox -e "${{ matrix.python-version//. }}" + + - name: Test runs + run: | + pypistats --help + pypistats recent --help + + # TODO Upload to Codecov From 2c5e4e4249008d9f280a024141a9f85eaf193af9 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 21:32:23 +0300 Subject: [PATCH 11/15] Fix dot dropping --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 253935cd..c4d559ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Unit tests # Drop the dot: py3.7 -> py37 run: | - tox -e "${{ matrix.python-version//. }}" + tox -e `echo ${{ matrix.python-version }} | tr -d .` - name: Test runs run: | From f3db708521e22bacdc8f53cbbbb59d057df6f93b Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 21:34:23 +0300 Subject: [PATCH 12/15] Remember the py prefix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4d559ca..e74e93c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Unit tests # Drop the dot: py3.7 -> py37 run: | - tox -e `echo ${{ matrix.python-version }} | tr -d .` + tox -e py`echo ${{ matrix.python-version }} | tr -d .` - name: Test runs run: | From ce016753944957415ec7cd5a4845322fc515deb1 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 22:42:30 +0300 Subject: [PATCH 13/15] Use bash on Windows (the default for non-Win) --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e74e93c1..e67ed335 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,7 @@ jobs: python -m pip install --upgrade tox - name: Unit tests + shell: bash # Drop the dot: py3.7 -> py37 run: | tox -e py`echo ${{ matrix.python-version }} | tr -d .` From 0047f0ddee82b4ac5d01c087eea712350590861e Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Aug 2019 22:47:58 +0300 Subject: [PATCH 14/15] Install pypistats editable --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e67ed335..66b10622 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade tox + python -m pip install -e . - name: Unit tests shell: bash From 0078ac8011d7d054532109d5bfda5f36923fbbae Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 23 Aug 2019 10:07:45 +0300 Subject: [PATCH 15/15] Add badge (for test workflow, not lint) [CI skip] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5eb3dadd..6417ac95 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![PyPI downloads](https://img.shields.io/pypi/dm/pypistats.svg)](https://pypistats.org/packages/pypistats) [![Build Status](https://travis-ci.org/hugovk/pypistats.svg?branch=master)](https://travis-ci.org/hugovk/pypistats) [![Build Status](https://dev.azure.com/hugovk/hugovk/_apis/build/status/hugovk.pypistats?branchName=master)](https://dev.azure.com/hugovk/hugovk/_build/latest?definitionId=1?branchName=master) +[![Actions Status](https://github.com/hugovk/pypistats/workflows/test/badge.svg)](https://github.com/hugovk/pypistats/actions) [![codecov](https://codecov.io/gh/hugovk/pypistats/branch/master/graph/badge.svg)](https://codecov.io/gh/hugovk/pypistats) [![GitHub](https://img.shields.io/github/license/hugovk/pypistats.svg)](LICENSE.txt) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)