From a8b5d1f49462a71558d644bb47031e6d44ab63ec Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 6 Oct 2020 09:32:45 -0700 Subject: [PATCH 1/4] Call build_html separately from sdist --- dev-bin/release.sh | 2 +- setup.cfg | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dev-bin/release.sh b/dev-bin/release.sh index 2e6d7707..57b01441 100755 --- a/dev-bin/release.sh +++ b/dev-bin/release.sh @@ -67,5 +67,5 @@ hub release create -m "$message" "$tag" git push --tags rm -fr dist -python setup.py sdist bdist_wheel +python setup.py build_html sdist bdist_wheel twine upload dist/* diff --git a/setup.cfg b/setup.cfg index cdfe10f1..cfd298ee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [aliases] build_html = build_sphinx -b html --build-dir docs -sdist = build_html sdist [flake8] # black uses 88 : ¯\_(ツ)_/¯ From 24f709445b828905f78b5b64f0583b78cee62e34 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 6 Oct 2020 09:33:02 -0700 Subject: [PATCH 2/4] Use tox --- .gitignore | 1 + setup.cfg | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 3e8afcd5..f9d687ec 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ pylint.txt .pyre .pytype *.swp +.tox violations.pyflakes.txt diff --git a/setup.cfg b/setup.cfg index cfd298ee..0954005a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,3 +7,19 @@ max-line-length = 88 [wheel] universal = 1 + +[tox:tox] +envlist = py36, py37, py38, mypy + +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + 3.9: py39, mypy + +[testenv] +deps = + pytest + mocket +commands = pytest tests From 80c7465e0b422ad919dc04a46b4bfeb6b1014223 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 6 Oct 2020 09:36:00 -0700 Subject: [PATCH 3/4] Add GitHub Actions --- .github/workflows/lint.yml | 39 ++++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..3578c0cd --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,39 @@ +name: Python lint + +on: + push: + pull_request: + schedule: + - cron: '3 19 * * SUN' + +jobs: + build: + + name: Python linting + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade pylint black mypy voluptuous-stubs + + - name: Install + run: python setup.py install + + - name: Run mypy + run: mypy geoip2 tests + + - name: Run Pylint + run: pylint geoip2 + + - name: Run Black + run: black --check --diff . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..b2088bce --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: Python tests + +on: + push: + pull_request: + schedule: + - cron: '3 15 * * SUN' + +jobs: + build: + + strategy: + matrix: + # We don't test on Windows currently as it appears mocket may not + # work there. + platform: [ubuntu-latest, macos-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + + name: Python ${{ matrix.python-version }} on ${{ matrix.platform }} + runs-on: ${{ matrix.platform }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + + - name: Test with tox + run: tox From 77f5142f8e582ef0f63231a425a8b0a83c37a9cc Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 6 Oct 2020 09:36:12 -0700 Subject: [PATCH 4/4] Remove Travis config --- .travis-black.sh | 16 -------------- .travis-pylint.sh | 6 ------ .travis.yml | 54 ----------------------------------------------- 3 files changed, 76 deletions(-) delete mode 100755 .travis-black.sh delete mode 100755 .travis-pylint.sh delete mode 100644 .travis.yml diff --git a/.travis-black.sh b/.travis-black.sh deleted file mode 100755 index a3d2475d..00000000 --- a/.travis-black.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -eux - -diff=$(black --check .) - -if [[ $? != 0 ]]; then - echo "black failed to run." - echo "$diff" - exit $? -elif [[ $diff ]]; then - echo "$diff" - exit 1 -else - exit 0 -fi diff --git a/.travis-pylint.sh b/.travis-pylint.sh deleted file mode 100755 index 7c6d8a90..00000000 --- a/.travis-pylint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -eux - -python setup.py install -pylint geoip2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4cbacfaa..00000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- -language: python -matrix: - include: - - python: 3.6 - - python: 3.7 - - python: 3.8 - env: - - RUN_SNYK=1 - - RUN_LINTER=1 - - python: nightly - allow_failures: - - python: nightly - -before_install: - - git submodule update --init --recursive - - git clone --recursive git://github.com/maxmind/libmaxminddb - - cd libmaxminddb - - ./bootstrap - - ./configure - - make - - sudo make install - - sudo ldconfig - - cd .. - - "if [[ $RUN_SNYK && $SNYK_TOKEN ]]; then sudo apt-get install -y nodejs; npm install -g snyk; fi" -install: - - pip install -r requirements.txt - - pip install mocket coveralls - - | - if [[ $RUN_LINTER ]]; then - pip install --upgrade pylint black mypy - fi - - "if [[ $RUN_SNYK && $SNYK_TOKEN ]]; then snyk test --org=maxmind; fi" -script: - - coverage run --source=geoip2 setup.py test - - "if [[ $RUN_LINTER ]]; then mypy geoip2 tests; fi" - - "if [[ $RUN_LINTER ]]; then ./.travis-pylint.sh; fi" - - "if [[ $RUN_LINTER ]]; then ./.travis-black.sh; fi" -after_success: - - coveralls - - "if [[ $RUN_SNYK && $SNYK_TOKEN && $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then snyk monitor --org=maxmind --project-name=maxmind/GeoIP2-python; fi" -notifications: - email: - on_failure: always - on_success: change - recipients: - - dev-ci@maxmind.com - slack: - rooms: - secure: "FZLn7HZnM6GOtIU7+W6tY6zd2y0K4C1ZgIOAiGscWvJydn+Xr63GCT21EPPe9QCulQHz88CWALMD7ZrDdsh6nV0gx0IeE+wq4w7NZYjLokvxs+UMYwuwl57MMrqd7e4byZDC4BLvTQTCvpOHOd8dCHwDXmuBcuyE8zB+Wkndn0I=\n" - -env: - global: - secure: "YUqALSGB89cWyKNiBKIZDxdWPl3xjYjkWx2OP1i53W5qcaKgOWco2jv+2iXTPAk3c5x3Py3J7B1SdiNcRWmjfKqrnE47fZYkiP8rk0c/pVMRw0zURpmtRzSReDF0Sh/1ZTODi2rsU52Ei1f++BTEB5m409RMnTEvQtH7XT2sVDk="