From 92551dfe37534dfd3c2b9f99f2ce1028c9af3226 Mon Sep 17 00:00:00 2001 From: "Douglas Cerna (Soy Douglas)" Date: Fri, 27 Oct 2023 17:16:32 +0200 Subject: [PATCH 1/4] Update package setup --- .pre-commit-config.yaml | 17 +++++++++-------- requirements-dev.txt | 4 ++++ requirements.txt | 3 ++- requirements/base.txt | 2 -- requirements/local.txt | 4 ---- requirements/production.txt | 1 - setup.py | 9 +++++---- 7 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 requirements-dev.txt delete mode 100644 requirements/base.txt delete mode 100644 requirements/local.txt delete mode 100644 requirements/production.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index db6b571..1bfd3ea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,23 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v3.10.1 hooks: - id: pyupgrade - args: [--py3-plus, --py36-plus] + args: [--py38-plus] - repo: https://github.com/asottile/reorder_python_imports - rev: v2.6.0 + rev: v3.10.0 hooks: - id: reorder-python-imports - args: [--py3-plus, --py36-plus] + args: [--py38-plus] - repo: https://github.com/ambv/black - rev: 22.8.0 + rev: "23.7.0" hooks: - id: black args: [--safe, --quiet] - language_version: python3 - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: "6.1.0" hooks: - id: flake8 - language_version: python3 + additional_dependencies: + - flake8-bugbear==23.9.16 + - flake8-comprehensions==3.14.0 diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..cf1fde8 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +-r requirements.txt +pytest==7.4.3 +pytest-cov==4.1.0 +vcrpy==5.1.0 diff --git a/requirements.txt b/requirements.txt index ea77c2d..e8218b6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ --r requirements/production.txt +requests==2.31.0 +SQLAlchemy==1.4.49 diff --git a/requirements/base.txt b/requirements/base.txt deleted file mode 100644 index 4b37ad8..0000000 --- a/requirements/base.txt +++ /dev/null @@ -1,2 +0,0 @@ -requests==2.27.1 -SQLAlchemy==1.4.48 diff --git a/requirements/local.txt b/requirements/local.txt deleted file mode 100644 index cae2dce..0000000 --- a/requirements/local.txt +++ /dev/null @@ -1,4 +0,0 @@ --r base.txt -pytest==7.0.1 -pytest-cov==4.0.0 -vcrpy==4.1.1 diff --git a/requirements/production.txt b/requirements/production.txt deleted file mode 100644 index a3e81b8..0000000 --- a/requirements/production.txt +++ /dev/null @@ -1 +0,0 @@ --r base.txt diff --git a/setup.py b/setup.py index 1300f4d..d4f904e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="fixity", - version="0.5.0", + version="0.6.0", packages=["fixity"], url="https://github.com/artefactual/fixity", author="Artefactual Systems", @@ -11,10 +11,11 @@ classifiers=[ "License :: OSI Approved :: GNU Affero General Public License v3", "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", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], - python_requires=">=3.6", + python_requires=">=3.8", ) From b59a14a71851752fe4b94f3f4bbeec947a6e5099 Mon Sep 17 00:00:00 2001 From: "Douglas Cerna (Soy Douglas)" Date: Fri, 27 Oct 2023 17:17:00 +0200 Subject: [PATCH 2/4] Update CI configuration --- .github/workflows/test.yml | 46 +++++++++++++------------------------- tox.ini | 29 +++++++++++++++++++----- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55eba4e..3fcb694 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,44 +7,32 @@ on: - "master" jobs: tox: - name: "Test ${{ matrix.toxenv }}" - runs-on: "ubuntu-20.04" + name: "Test Python ${{ matrix.python-version }}" + runs-on: "ubuntu-22.04" strategy: matrix: - include: - - python-version: "3.6" - toxenv: "py36" - - python-version: "3.7" - toxenv: "py37" - - python-version: "3.8" - toxenv: "py38" - - python-version: "3.9" - toxenv: "py39" + python-version: [ + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", + ] steps: - name: "Check out repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Set up Python ${{ matrix.python-version }}" uses: "actions/setup-python@v4" with: python-version: "${{ matrix.python-version }}" - - name: "Get pip cache dir" - id: "pip-cache" - run: | - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - - name: "Cache pip packages" - uses: "actions/cache@v3" - with: - path: "${{ steps.pip-cache.outputs.dir }}" - key: "${{ runner.os }}-pip-${{ hashFiles('**/base.txt', '**/local.txt', '**/production.txt') }}" - restore-keys: | - ${{ runner.os }}-pip- + cache: "pip" + cache-dependency-path: | + requirements-dev.txt - name: "Install tox" run: | python -m pip install --upgrade pip - pip install tox + pip install tox tox-gh-actions - name: "Run tox" - env: - TOXENV: ${{ matrix.toxenv }} run: | tox -- --cov fixity --cov-config .coveragerc --cov-report xml:coverage.xml - name: "Upload coverage report" @@ -52,10 +40,8 @@ jobs: uses: "codecov/codecov-action@v3" with: files: ./coverage.xml - fail_ci_if_error: true + fail_ci_if_error: false verbose: true - name: ${{ matrix.toxenv }} - flags: ${{ matrix.toxenv }} lint: name: "Lint" runs-on: "ubuntu-22.04" @@ -65,7 +51,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v4" with: - python-version: "3.8" + python-version: "3.12" - name: "Install tox" run: | python -m pip install --upgrade pip diff --git a/tox.ini b/tox.ini index 9d8a475..b370cc0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,18 @@ [tox] skipsdist = True -envlist = py{36,37,38,39},linting +envlist = py{38,39,310,311,312},linting + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 [testenv] skip_install = True -deps = -rrequirements/local.txt +deps = -rrequirements-dev.txt whitelist_externals = pytest commands = pytest {posargs} @@ -15,6 +23,17 @@ commands = pre-commit run --all-files --show-diff-on-failure [flake8] exclude = .tox, .git, __pycache__, .cache, build, dist, *.pyc, *.egg-info, .eggs -application-import-names = flake8 -select = C, E, F, W, B, B950 -ignore = E501, W503 +# Error codes: +# - https://flake8.pycqa.org/en/latest/user/error-codes.html +# - https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes +# - https://github.com/PyCQA/flake8-bugbear#list-of-warnings +# +# E203: whitespace before ‘,’, ‘;’, or ‘:’ +# E402: module level import not at top of file +# E501: line too long +# W503: line break before binary operator +ignore = + E203, + E402, + E501, + W503 From fee3b6bb89173ebd58abee29cc1806cc4f2b2eb2 Mon Sep 17 00:00:00 2001 From: "Douglas Cerna (Soy Douglas)" Date: Fri, 27 Oct 2023 17:17:30 +0200 Subject: [PATCH 3/4] Address test issues --- fixity/models.py | 2 +- fixity/utils.py | 9 +-------- tests/test_storage_service.py | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/fixity/models.py b/fixity/models.py index edf873c..65942ee 100644 --- a/fixity/models.py +++ b/fixity/models.py @@ -7,8 +7,8 @@ from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy import String -from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import backref +from sqlalchemy.orm import declarative_base from sqlalchemy.orm import relationship from sqlalchemy.orm import sessionmaker diff --git a/fixity/utils.py b/fixity/utils.py index c7d8124..83e830f 100644 --- a/fixity/utils.py +++ b/fixity/utils.py @@ -1,12 +1,5 @@ from uuid import UUID -try: - # Python2 - STRING_TYPES = basestring -except NameError: - # Python3 - STRING_TYPES = str - class InvalidUUID(Exception): def __init__(self, uuid): @@ -25,7 +18,7 @@ def check_valid_uuid(uuid): This uses the UUID() class constructor from the uuid module, which raises a ValueError if the passed string is not a valid UUID. """ - if not isinstance(uuid, STRING_TYPES): + if not isinstance(uuid, str): raise TypeError("UUID must be a string") try: diff --git a/tests/test_storage_service.py b/tests/test_storage_service.py index e959bee..16cc4a7 100644 --- a/tests/test_storage_service.py +++ b/tests/test_storage_service.py @@ -23,7 +23,7 @@ def test_get_single_aip(): aip = storage_service.get_single_aip( aip_uuid, STORAGE_SERVICE_URL, STORAGE_SERVICE_USER, STORAGE_SERVICE_KEY ) - assert type(aip) == dict + assert isinstance(aip, dict) assert aip["uuid"] == aip_uuid @@ -117,7 +117,7 @@ def test_get_all_aips(): ) assert len(aips) == 2 for aip in aips: - assert type(aip) == dict + assert isinstance(aip, dict) assert aip["uuid"] in aip_uuids From 8d8caab762ab20b20818e1bc8129999de2656e4c Mon Sep 17 00:00:00 2001 From: "Douglas Cerna (Soy Douglas)" Date: Fri, 27 Oct 2023 17:17:55 +0200 Subject: [PATCH 4/4] Remove debian package source --- debian/changelog | 5 ----- debian/compat | 1 - debian/control | 18 ------------------ debian/copyright | 8 -------- debian/dirs | 1 - debian/fixity.install | 1 - debian/fixity.links | 1 - debian/fixity.postinst | 14 -------------- debian/rules | 7 ------- 9 files changed, 56 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/dirs delete mode 100644 debian/fixity.install delete mode 100644 debian/fixity.links delete mode 100644 debian/fixity.postinst delete mode 100755 debian/rules diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 1282d81..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -fixity (0.1) UNRELEASED; urgency=low - - * Initial release. - - -- Misty De Meo Tue, 20 May 2014 12:07:12 -0700 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control deleted file mode 100644 index f94ef24..0000000 --- a/debian/control +++ /dev/null @@ -1,18 +0,0 @@ -Source: fixity -Section: utils -Priority: extra -Maintainer: Artefactual Systems Inc. -Build-Depends: - debhelper (>= 9), - python3.6-dev, - ruby-ronn, - dh-virtualenv -Standards-Version: 3.9.3 -X-Python-Version: 3.6 - -Package: fixity -Architecture: i386 amd64 -Depends: python3, ${python3:Depends}, ${misc:Depends}, sqlite3 -Description: Commandline tool to check fixity of AIPs stored in - an Archivematica Storage Service installation. -Homepage: http://archivematica.org diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 74c8792..0000000 --- a/debian/copyright +++ /dev/null @@ -1,8 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: fixity -Upstream-Contact: Justin Simpson - -Files: * -Copyright: Artefactual Systems Inc. -License: AGPL-3+ - Full license available at http://www.gnu.org/licenses/agpl-3.0.txt diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index b69bb77..0000000 --- a/debian/dirs +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/fixity diff --git a/debian/fixity.install b/debian/fixity.install deleted file mode 100644 index f22de19..0000000 --- a/debian/fixity.install +++ /dev/null @@ -1 +0,0 @@ -docs/*.1 usr/share/man/man1 diff --git a/debian/fixity.links b/debian/fixity.links deleted file mode 100644 index ce902d2..0000000 --- a/debian/fixity.links +++ /dev/null @@ -1 +0,0 @@ -usr/share/python/fixity/bin/fixity usr/bin/fixity diff --git a/debian/fixity.postinst b/debian/fixity.postinst deleted file mode 100644 index 37ebba0..0000000 --- a/debian/fixity.postinst +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Archivematica user creation borrowed from Storage Service postinst -echo "creating archivematica user" -userID=`id -u archivematica` - -if [ "${userID}" = 333 ]; then - echo "User archivematica exists" -else - adduser --uid 333 --group --system --home /var/lib/archivematica/ archivematica -fi - -chgrp archivematica /usr/share/python/fixity/lib/python2.7/site-packages/fixity -chmod g+ws /usr/share/python/fixity/lib/python2.7/site-packages/fixity diff --git a/debian/rules b/debian/rules deleted file mode 100755 index d144b1e..0000000 --- a/debian/rules +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/make -f - -%: - dh $@ --with python-virtualenv - -override_dh_virtualenv: - dh_virtualenv --local-wheel-dir lib