From a20521fe3225bcaccd0d9bdbcc1f0f7c94f6cea6 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Tue, 10 Dec 2024 14:46:09 +0000 Subject: [PATCH 01/10] Adding github actions --- .github/workflows/test.yml | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 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 0000000..3254835 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,59 @@ +# This is a basic workflow to help you get started with Actions + +name: Run-tests + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13'] + name: Python ${{ matrix.python-version }} sample + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + + - uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }} + + - name: Install + run: python setup.py install + + - name: Test + run: python setup.py test + + - name: install coveralls + run: pip install coveralls + + + - name: Generate coverage + run: coverage run --include=iiif-presentation-validator.py setup.py test + + - name: Upload coverage data to coveralls.io + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.python-version }} + COVERALLS_PARALLEL: true + + Coveralls: + needs: build + runs-on: ubuntu-latest + container: python:3-slim + steps: + - name: Coveralls Finished + run: | + pip3 install --upgrade coveralls + coveralls --service=github --finish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 60c1ee26a1376176ad6a9f36ed95f568ac866557 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Tue, 10 Dec 2024 14:51:43 +0000 Subject: [PATCH 02/10] Installing dependencies --- .github/workflows/test.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3254835..b033b88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,18 +14,24 @@ jobs: python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13'] name: Python ${{ matrix.python-version }} sample steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} architecture: x64 - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-travis coveralls + pip install setuptools -U + - name: Install run: python setup.py install From 4813129be62996d320378ef00cc2e78561036935 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Tue, 10 Dec 2024 14:58:59 +0000 Subject: [PATCH 03/10] Using module for tests --- .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 b033b88..3c43a1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: run: python setup.py install - name: Test - run: python setup.py test + run: python -m unittest discover -s tests - name: install coveralls run: pip install coveralls From 38a02442dbe08e026a9914319ed9ccb27fb29c45 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Wed, 11 Dec 2024 21:36:54 +0000 Subject: [PATCH 04/10] Installing from requirements.txt --- .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 3c43a1a..11fab49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox tox-travis coveralls + pip install -r requirements.txt pip install setuptools -U - name: Install From 6255c2373a61cbc7a6e254b019ea72bd645724a1 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Wed, 11 Dec 2024 21:38:50 +0000 Subject: [PATCH 05/10] Dropping support for python 2 --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8a22d70..465f48f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ lxml bottle python-magic -# Versions including 7 don't support python 2.x -pillow<7 +pillow mock From 1fae77ef3a9be5dfc2d5986796a9ed8c71e0bddc Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Wed, 11 Dec 2024 21:40:45 +0000 Subject: [PATCH 06/10] Fixing coveralls --- .github/workflows/test.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11fab49..75c228c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,17 +41,6 @@ jobs: - name: install coveralls run: pip install coveralls - - - name: Generate coverage - run: coverage run --include=iiif-presentation-validator.py setup.py test - - - name: Upload coverage data to coveralls.io - run: coveralls --service=github - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: ${{ matrix.python-version }} - COVERALLS_PARALLEL: true - Coveralls: needs: build runs-on: ubuntu-latest From 9fc4b1dc6345b05cd759ff92616b3f7324bae3e1 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Wed, 11 Dec 2024 21:42:03 +0000 Subject: [PATCH 07/10] Moving dev dependencies to requirements.txt --- requirements-devel.txt | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 requirements-devel.txt diff --git a/requirements-devel.txt b/requirements-devel.txt deleted file mode 100644 index 21fef21..0000000 --- a/requirements-devel.txt +++ /dev/null @@ -1,7 +0,0 @@ --e git+https://github.com/python-pillow/Pillow@3.4.x#egg=Pillow --e git+https://github.com/bottlepy/bottle#egg=bottle --e git+https://github.com/ahupp/python-magic#egg=python-magic --e git+https://github.com/lxml/lxml#egg=lxml -# LXML requires Cython>=0.20 -Cython>=0.20 -mock From dc2cd929fe90c116c9f5a2cc05ee28b4b5b30531 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Wed, 11 Dec 2024 21:50:43 +0000 Subject: [PATCH 08/10] Fixing coveralls --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 75c228c..b340c47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,16 @@ jobs: - name: install coveralls run: pip install coveralls + - name: Generate coverage + run: coverage run -m unittest discover -s tests + + - name: Upload coverage data to coveralls.io + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.python-version }} + COVERALLS_PARALLEL: true + Coveralls: needs: build runs-on: ubuntu-latest From 321c770c44c279175e1b63917406ce4ada56cbd1 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Wed, 11 Dec 2024 22:07:52 +0000 Subject: [PATCH 09/10] Moving to updating pypi via github actions --- .github/workflows/PyPi.yml | 30 +++++++++++++++++ .github/workflows/TestPyPi.yml | 32 ++++++++++++++++++ iiif_validator/_version.py | 1 - requirements.txt | 1 + setup.py | 59 ++++++++++++++++------------------ 5 files changed, 91 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/PyPi.yml create mode 100644 .github/workflows/TestPyPi.yml delete mode 100644 iiif_validator/_version.py diff --git a/.github/workflows/PyPi.yml b/.github/workflows/PyPi.yml new file mode 100644 index 0000000..20ce635 --- /dev/null +++ b/.github/workflows/PyPi.yml @@ -0,0 +1,30 @@ +name: Publish Python 🐍 distributions 📦 to PyPI on Release + +on: + release: + types: [released] + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: 3.9 + + - name: Setup version + run: echo "${{ github.event.release.tag_name }}" > version.txt + + - name: Install pypa/build + run: python -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python -m build --sdist --wheel --outdir dist/ + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@v1.12.2 + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/TestPyPi.yml b/.github/workflows/TestPyPi.yml new file mode 100644 index 0000000..6431923 --- /dev/null +++ b/.github/workflows/TestPyPi.yml @@ -0,0 +1,32 @@ +name: Publish Python 🐍 distributions 📦 to TestPyPI on Tag creation + +on: + release: + types: [prereleased] + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: 3.9 + + - name: Setup version + run: echo "${{ github.event.release.tag_name }}" > version.txt + + - name: Install pypa/build + run: python -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python -m build --sdist --wheel --outdir dist/ + + + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@v1.12.2 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ diff --git a/iiif_validator/_version.py b/iiif_validator/_version.py deleted file mode 100644 index da2182f..0000000 --- a/iiif_validator/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '1.0.6' diff --git a/requirements.txt b/requirements.txt index 465f48f..2685be0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ bottle python-magic pillow mock +setuptools \ No newline at end of file diff --git a/setup.py b/setup.py index 32f945b..07b8102 100644 --- a/setup.py +++ b/setup.py @@ -1,24 +1,27 @@ from setuptools import setup -# setuptools used instead of distutils.core so that -# dependencies can be handled automatically +import os +from pathlib import Path -# Extract version number from resync/_version.py. Here we -# are very strict about the format of the version string -# as an extra sanity check. (Thanks for comments in -# http://stackoverflow.com/questions/458550/standard-way-to-embed-version-into-python-package ) -import re -VERSIONFILE = "iiif_validator/_version.py" -verfilestr = open(VERSIONFILE, "rt").read() -match = re.search(r"^__version__ = '(\d\.\d.\d+(\.\d+)?)'", verfilestr, - re.MULTILINE) -if match: - version = match.group(1) +this_directory = Path(__file__).parent +if os.path.exists("version.txt"): + VERSION = (this_directory / "version.txt").read_text().strip() else: - raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE)) + VERSION = "0.0.0.dev0" + +REQUIREMENTS = [ + "bottle>=0.12.1", + "python-magic>=0.4.12", + "lxml>=3.7.0", + "Pillow>=6.2.2" +] + +# Read dev requirements from requirements.txt +with open("requirements.txt") as f: + DEV_REQUIREMENTS = f.read().splitlines() setup( name='iiif-validator', - version=version, + version=VERSION, packages=['iiif_validator', 'iiif_validator.tests'], scripts=['iiif-validator.py', 'iiif-validate.py'], classifiers=[ @@ -27,29 +30,23 @@ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules", "Environment :: Web Environment" ], + python_requires='>=3', author='IIIF Contributors', author_email='simeon.warner@cornell.edu', description='IIIF Image API Validator', long_description=open('README').read(), - url='http://github.com/IIIF/image-api', - install_requires=[ - "bottle>=0.12.1", - "python-magic>=0.4.12", - "lxml>=3.7.0" - ], + long_description_content_type='text/markdown', + url='https://github.com/IIIF/image-validator', + install_requires=REQUIREMENTS, extras_require={ - ':python_version>="3.0"': ["Pillow>=3.2.0"], - ':python_version<"3.0"': ["Pillow==6.2.2"], - }, - test_suite="tests", - tests_require=["mock"]) + "dev": DEV_REQUIREMENTS + }) From 18b1b602b301ddc3f2d04d469bcab972bc612f3c Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Wed, 11 Dec 2024 22:18:15 +0000 Subject: [PATCH 10/10] Updating links --- README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 67daceb..7df3b56 100644 --- a/README +++ b/README @@ -2,11 +2,11 @@ IIIF Validator ============== -.. image:: https://travis-ci.org/IIIF/image-validator.svg?branch=master - :target: https://travis-ci.org/IIIF/image-validator +.. image:: https://github.com/github/docs/actions/workflows/test.yml/badge.svg + :target: https://github.com/IIIF/image-validator/actions -.. image:: https://coveralls.io/repos/github/IIIF/image-validator/badge.svg?branch=master - :target: https://coveralls.io/github/IIIF/image-validator?branch=master +.. image:: https://coveralls.io/repos/github/IIIF/image-validator/badge.svg?branch=main + :target: https://coveralls.io/github/IIIF/image-validator?branch=main This validator supports the same validations that are available on the