Skip to content

Commit

Permalink
Merge pull request #167 from biglocalnews/tests
Browse files Browse the repository at this point in the history
Build out tests
  • Loading branch information
palewire authored Apr 15, 2022
2 parents 627c4ca + a688b34 commit 00b7af4
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 56 deletions.
152 changes: 152 additions & 0 deletions .github/workflows/continuous-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Testing and deployment
on:
push:
workflow_dispatch:

jobs:
lint-python:
name: Lint Python code
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install pipenv
run: pipx install pipenv

- uses: actions/setup-python@v2
with:
python-version: "3.7"
cache: "pipenv"

- id: pipenv-install
name: Install Python dependencies
run: pipenv install --dev --python `which python`

- id: lint
name: Lint
run: make lint

test-docs:
name: Test Sphinx build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install pipenv
run: pipx install pipenv

- uses: actions/setup-python@v2
with:
python-version: "3.9"
cache: "pipenv"

- id: pipenv-install
name: Install Python dependencies
run: pipenv install --dev --python `which python`

- id: build
name: Build
run: make test-docs

- id: save
name: Save artifact
uses: actions/upload-artifact@v2
with:
name: docs
path: ./docs
if-no-files-found: error

test-python:
name: "Test Python code"
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10"]
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v2

- name: Install pipenv
run: pipx install pipenv

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: "pipenv"

- id: pipenv-install
name: Install Python dependencies
run: pipenv install --dev --python `which python`

- id: tests
name: Tests
run: pipenv run coverage run --source court_scraper -m pytest

- id: coverage
name: Coverage
run: pipenv run coverage report -m

test-build:
name: Build Python package
runs-on: ubuntu-latest
needs: [test-python]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install pipenv
run: pipx install pipenv

- uses: actions/setup-python@v2
with:
python-version: '3.9'
cache: 'pipenv'

- id: pipenv-install
name: Install Python dependencies
run: pipenv install --dev --python `which python`

- id: build
name: Build release
run: make build-release

- id: check
name: Check release
run: make check-release

- id: save
name: Save artifact
uses: actions/upload-artifact@v2
with:
name: release
path: ./dist
if-no-files-found: error

tag-release:
name: Tagged PyPI release
runs-on: ubuntu-latest
needs: [test-build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.9'

- id: fetch
name: Fetch artifact
uses: actions/download-artifact@v2
with:
name: release
path: ./dist

- id: publish
name: Publish release
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
verify_metadata: false
44 changes: 0 additions & 44 deletions .github/workflows/tests.yaml

This file was deleted.

1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ check-release: ## check release for potential errors
build-release: ## builds source and wheel package
$(call banner, 📦 Building release 📦)
@$(PYTHON) setup.py sdist
@$(PYTHON) setup.py bdist_wheel
@ls -l dist


Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ wheel = "*"
black = "*"
myst-parser = "*"
sphinxcontrib-napoleon = "*"
setuptools-scm = "*"
sphinx-autobuild = "*"

[packages]
Expand Down
26 changes: 17 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 31 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@
"""
from setuptools import find_packages, setup


def version_scheme(version):
"""
Version scheme hack for setuptools_scm.
Appears to be necessary to due to the bug documented here: https://github.com/pypa/setuptools_scm/issues/342
If that issue is resolved, this method can be removed.
"""
import time

from setuptools_scm.version import guess_next_version

if version.exact:
return version.format_with("{tag}")
else:
_super_value = version.format_next_version(guess_next_version)
now = int(time.time())
return _super_value + str(now)


def local_version(version):
"""
Local version scheme hack for setuptools_scm.
Appears to be necessary to due to the bug documented here: https://github.com/pypa/setuptools_scm/issues/342
If that issue is resolved, this method can be removed.
"""
return ""


requirements = [
"anticaptchaofficial",
"bs4",
Expand All @@ -61,7 +89,6 @@

setup(
name="court-scraper",
version="0.1.1",
description="Command-line tool for scraping data from U.S. county courts",
long_description=__doc__,
long_description_content_type="text/x-rst",
Expand All @@ -84,10 +111,10 @@
"License :: OSI Approved :: ISC License (ISCL)",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
test_suite="tests",
tests_require=test_requirements,
Expand All @@ -96,4 +123,6 @@
"Source": "https://github.com/biglocalnews/court-scraper",
"Tracker": "https://github.com/biglocalnews/court-scraper/issues",
},
setup_requires=["setuptools_scm"],
use_scm_version={"version_scheme": version_scheme, "local_scheme": local_version},
)

0 comments on commit 00b7af4

Please sign in to comment.