diff --git a/.github/workflows/continuous-deployment.yaml b/.github/workflows/continuous-deployment.yaml new file mode 100644 index 0000000..5e395cb --- /dev/null +++ b/.github/workflows/continuous-deployment.yaml @@ -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 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml deleted file mode 100644 index 0bce96c..0000000 --- a/.github/workflows/tests.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: Tests -on: - push: - workflow_dispatch: - -jobs: - lint: - name: "Linter" - runs-on: ubuntu-latest - steps: - - name: Checkout the repo - uses: actions/checkout@v2 - - - name: Install Python, pipenv and Pipfile packages - uses: palewire/install-python-pipenv-pipfile@v1 - with: - python-version: 3.7 - - - id: flake8 - name: Flake8 - run: make lint - - tests: - name: "Tests" - runs-on: ubuntu-latest - strategy: - matrix: - python: [3.6, 3.7, 3.8, 3.9] - steps: - - name: Checkout the repo - uses: actions/checkout@v2 - - - name: Install Python, pipenv and Pipfile packages - uses: palewire/install-python-pipenv-pipfile@v1 - with: - python-version: ${{ matrix.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 diff --git a/Makefile b/Makefile index 2ba666b..1cfb8d4 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/Pipfile b/Pipfile index 748d3fe..7cca127 100644 --- a/Pipfile +++ b/Pipfile @@ -21,6 +21,7 @@ wheel = "*" black = "*" myst-parser = "*" sphinxcontrib-napoleon = "*" +setuptools-scm = "*" sphinx-autobuild = "*" [packages] diff --git a/Pipfile.lock b/Pipfile.lock index 0cac781..8debaf0 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "041e37d177e4425aa89d3c9540c87e656431464c11ff86e292fb6b2c5e0878c3" + "sha256": "3e29bd8c90b4ad23a728903a6edb9ec9a52899d03c8964433629c6e038fad655" }, "pipfile-spec": 6, "requires": {}, @@ -252,7 +252,7 @@ "sha256:fa877ca7f6b48054f847b61d6fa7bed5cebb663ebc55e018fda12db09dcc664c", "sha256:fdcec0b8399108577ec290f55551d926d9a1fa6cad45882093a7a07ac5ec147b" ], - "markers": "python_version >= '3' and platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32')))))", + "markers": "python_version >= '3' and (platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32'))))))", "version": "==1.1.2" }, "h11": { @@ -481,7 +481,7 @@ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==1.16.0" }, "sniffio": { @@ -554,7 +554,7 @@ "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.10.2" }, "trio": { @@ -928,7 +928,7 @@ "sha256:1208431ca90a8cca1a6b8af391bb53c1a2db74e5d1cef6ddced95d4b2062edc6", "sha256:ea4c597ebf37142f827b8f39299579e31685c31d3a438b59f469406afd0f2539" ], - "markers": "python_version >= '3.7'", + "markers": "python_version < '3.10'", "version": "==4.11.3" }, "iniconfig": { @@ -943,7 +943,7 @@ "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7", "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951" ], - "markers": "python_version < '4' and python_full_version >= '3.6.1'", + "markers": "python_full_version >= '3.6.1' and python_version < '4.0'", "version": "==5.10.1" }, "jeepney": { @@ -1374,7 +1374,7 @@ "sha256:c50f3d253bc6a9bb9c79d61a26d510d74abdf1b16881260fab5edfc3edfb082f", "sha256:ea74bc9dad9589d8eea3e3fd0b136d8bf6e428888955f215824c2894f0da8b47" ], - "markers": "python_version < '4' and python_full_version >= '3.6.3'", + "markers": "python_full_version >= '3.6.3' and python_version < '4.0'", "version": "==12.2.0" }, "secretstorage": { @@ -1393,12 +1393,20 @@ "markers": "python_version >= '3.7'", "version": "==62.1.0" }, + "setuptools-scm": { + "hashes": [ + "sha256:6833ac65c6ed9711a4d5d2266f8024cfa07c533a0e55f4c12f6eff280a5a9e30", + "sha256:acea13255093849de7ccb11af9e1fb8bde7067783450cee9ef7a93139bddf6d4" + ], + "index": "pypi", + "version": "==6.4.2" + }, "six": { "hashes": [ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==1.16.0" }, "snowballstemmer": { @@ -1493,7 +1501,7 @@ "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.10.2" }, "tomli": { diff --git a/setup.py b/setup.py index a742475..725dde0 100644 --- a/setup.py +++ b/setup.py @@ -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", @@ -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", @@ -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, @@ -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}, )