Skip to content

Commit

Permalink
Merge pull request #155 from Harvard-ATG/feature/150-matrix-testing
Browse files Browse the repository at this point in the history
Start using a version matrix for unit tests
  • Loading branch information
ColeDCrawford committed Nov 18, 2022
2 parents 52b0cde + 15cae8f commit 3db5327
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 53 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/ci.yml → .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
name: CI
name: unit tests

on:
push:
branches:
- "**"
paths:
- 'src/IIIFingest/**'
- 'tests/**'
- .github/workflows/ci.yml
pull_request:
workflow_dispatch:

jobs:
qa:
linting:
runs-on: ubuntu-latest

defaults:
run:
working-directory: .

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.10
cache: 'pip'
cache-dependency-path: '**/requirements-dev.txt'
cache-dependency-path: '**/setup.cfg'
- name: Install deps using Pip
run: pip install -r requirements-dev.txt
run: pip install -e ".[dev]"
if: steps.python-cache.outputs.cache-hit != 'true'
- name: Run isort
run: |
Expand All @@ -35,7 +31,4 @@ jobs:
black src --check --diff
- name: Run flake8
run: |
flake8 src
- name: Run unit tests
run: |
pytest tests/unit
flake8 src
37 changes: 37 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: unit tests

on:
push:
branches:
- "**"
paths:
- 'src/IIIFingest/**'
- 'tests/**'
- .github/workflows/unit_tests.yml
pull_request:
workflow_dispatch:

jobs:
unit_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
defaults:
run:
working-directory: .

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version}}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: '**/setup.cfg'
- name: Install deps using Pip
run: pip install -e ".[dev]"
if: steps.python-cache.outputs.cache-hit != 'true'
- name: Run unit tests
run: |
pytest tests/unit
12 changes: 0 additions & 12 deletions requirements-dev.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

37 changes: 26 additions & 11 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = IIIFingest
version = 1.1.2
version = 1.2.0
author = Cole Crawford
author_email = [email protected]
description = A wrapper library for interacting with the MPS ingest system for IIIF resources
Expand All @@ -20,16 +20,31 @@ package_dir =
packages = find:
python_requires = >=3.7
install_requires =
pyjwt
cryptography
jsonschema
boto3
Pillow
requests
shortuuid
pyIIIFpres
python-magic
Deprecated
pyjwt >= 2
cryptography >= 3
jsonschema >= 4
boto3 >= 1.24.66
Pillow >= 9
requests >= 2
shortuuid >= 1
pyIIIFpres >= 0.1.1
python-magic >= 0.4.24
Deprecated >= 1
backports.zoneinfo;python_version<"3.9"

[options.extras_require]
all =
%(dev)s
dev =
pre-commit >= 2
isort >= 5
black >= 22
flake8 >= 5
python-dotenv >= 0.21.0
moto >= 4
pytest >= 7
pytest-mock >= 3.8
pytest-dotenv >= 0.5

[options.packages.find]
where = src
7 changes: 6 additions & 1 deletion src/IIIFingest/auth.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import logging
import os
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo

import jwt

# Backports supports Python 3.6-3.8
try:
from zoneinfo import ZoneInfo
except ImportError:
from backports.zoneinfo import ZoneInfo

from .settings import ROOT_DIR

logger = logging.getLogger(__name__)
Expand Down
7 changes: 6 additions & 1 deletion src/IIIFingest/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
import time
from datetime import datetime
from urllib import request
from zoneinfo import ZoneInfo

import requests

# Backports supports Python 3.6-3.8
try:
from zoneinfo import ZoneInfo
except ImportError:
from backports.zoneinfo import ZoneInfo

logger = logging.getLogger(__name__)


Expand Down
7 changes: 6 additions & 1 deletion tests/unit/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
import tempfile
from datetime import datetime, timedelta
from unittest import mock
from zoneinfo import ZoneInfo

import jwt
import pytest

# Backports supports Python 3.6-3.8
try:
from zoneinfo import ZoneInfo
except ImportError:
from backports.zoneinfo import ZoneInfo

from IIIFingest.auth import Credentials


Expand Down

0 comments on commit 3db5327

Please sign in to comment.