Skip to content

Commit

Permalink
Merge branch 'release/0.4' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed May 26, 2021
2 parents f9c969c + 596f6dd commit c3514ac
Show file tree
Hide file tree
Showing 14 changed files with 2,269 additions and 940 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "CodeQL"

on:
push:
branches: [ main, develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main, develop ]
schedule:
- cron: '34 21 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'python' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
71 changes: 71 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: unit tests

on:
push: # run on every push or PR to any branch
pull_request:
schedule: # run automatically on main branch each Tuesday at 11am
- cron: "0 16 * * 2"

jobs:
python-unit:
name: Python unit tests
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.6, 3.7, 3.8]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

# We base the python cache on the hash of all requirements files, so that
# if any change, the cache is invalidated.
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('setup.py') }}
restore-keys: |
pip-${{ hashFiles('setup.py') }}
pip-
- name: Install package with dependencies
run: |
pip install -e .
pip install -e '.[test]'
pip install codecov
- name: Run pytest
run: py.test --cov=piffle --cov-report=xml

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v1

# Set the color of the slack message used in the next step based on the
# status of the build: "danger" for failure, "good" for success,
# "warning" for error
- name: Set Slack message color based on build status
if: ${{ always() }}
env:
JOB_STATUS: ${{ job.status }}
run: echo "SLACK_COLOR=$(if [ "$JOB_STATUS" == "success" ]; then echo "good"; elif [ "$JOB_STATUS" == "failure" ]; then echo "danger"; else echo "warning"; fi)" >> $GITHUB_ENV

# Send a message to slack to report the build status. The webhook is stored
# at the organization level and available to all repositories. Only run on
# scheduled builds & pushes, since PRs automatically report to Slack.
- name: Report status to Slack
uses: rtCamp/action-slack-notify@master
if: ${{ always() && (github.event_name == 'schedule' || github.event_name == 'push') }}
continue-on-error: true
env:
SLACK_COLOR: ${{ env.SLACK_COLOR }}
SLACK_WEBHOOK: ${{ secrets.ACTIONS_SLACK_WEBHOOK }}
SLACK_TITLE: "Workflow `${{ github.workflow }}` (python ${{ matrix.python }}): ${{ job.status }}"
SLACK_MESSAGE: "Run <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|#${{ github.run_number }}> on <https://github.com/${{ github.repository }}/|${{ github.repository }}@${{ github.ref }}>"
SLACK_FOOTER: "<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|View commit>"
MSG_MINIMAL: true # use compact slack message format
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change & Version Information

## 0.4

* Dropped support for Python versions 2.7, 3.4, 3.5
* Now tested against python 3.7 and 3.8
* Moved continues integration from Travis-CI to GitHub Actions
* Renamed `piffle.iiif` to `piffle.image`, but for backwards compatibility `piffle.iiif` will still work
* Now includes `piffle.presentation` for simple read access to IIIF Presentation content

## 0.3.2

* Dropped support for Python 3.3
Expand Down
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
Python library for generating and parsing [IIIF Image API](http://iiif.io/api/image/2.1/) URLs in an
object-oriented, pythonic fashion.

[![Build Status](https://travis-ci.org/Princeton-CDH/piffle.svg?branch=main)](https://travis-ci.org/Princeton-CDH/piffle)
[![Coverage Status](https://coveralls.io/repos/github/Princeton-CDH/piffle/badge.svg?branch=master)](https://coveralls.io/github/Princeton-CDH/piffle?branch=master)
[![Unit Test Status](https://github.com/Princeton-CDH/piffle/workflows/unit_tests/badge.svg)](https://github.com/Princeton-CDH/piffle/actions?query=workflow%3Aunit_tests)
[![codecov](https://codecov.io/gh/Princeton-CDH/piffle/branch/main/graph/badge.svg)](https://codecov.io/gh/Princeton-CDH/piffle)
[![Maintainability](https://api.codeclimate.com/v1/badges/d37850d90592f9d628df/maintainability)](https://codeclimate.com/github/Princeton-CDH/piffle/maintainability)

Piffle is tested on Python 2.7 and 3.4-3.6.

Piffle was originally developed by Emory University as a part of
[Readux](https://github.com/ecds/readux>) and forked as a separate project
under [emory-lits-labs](https://github.com/emory-lits-labs/).
Piffle is tested on Python 3.6-3.8.

Piffle was originally developed by Rebecca Sutton Koeser at Emory University as a part of [Readux](https://github.com/ecds/readux>) and forked as a separate project under [emory-lits-labs](https://github.com/emory-lits-labs/). It was later transferred to Rebecca Sutton Koeser at the Center for Digital Humanities at Princeton.

## Installation and example use:

Expand All @@ -20,7 +19,7 @@ under [emory-lits-labs](https://github.com/emory-lits-labs/).
Example use for generating an IIIF image url:

```
>>> from piffle.iiif import IIIFImageClient
>>> from piffle.image import IIIFImageClient
>>> myimg = IIIFImageClient('http://image.server/path/', 'myimgid')
>>> print myimg
http://image.server/path/myimgid/full/full/0/default.jpg
Expand All @@ -33,7 +32,7 @@ http://image.server/path/myimgid/full/120,/0/default.png
Example use for parsing an IIIF image url:

```
>>> from piffle.iiif import IIIFImageClient
>>> from piffle.image import IIIFImageClient
>>> myimg = IIIFImageClient.init_from_url('http://www.example.org/image-service/abcd1234/full/full/0/default.jpg')
>>> print myimg
http://www.example.org/image-service/abcd1234/full/full/0/default.jpg
Expand All @@ -47,6 +46,30 @@ False
0.0
```

Example use for reading a IIIF manifest:

```
>>> from piffle.image import IIIFImageClient
>>> from piffle.presentation import IIIFPresentation
>>> manifest = IIIFPresentation.from_url('https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json')
>>> manifest.label
'Bodleian Library MS. Bodl. 264'
>>> manifest.id
'https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json'
>>> manifest.type
'sc:Manifest'
>>> for canvas in manifest.sequences[0].canvases[:5]:
... image_id = canvas.images[0].resource.id
... iiif_img = IIIFImageClient(*image_id.rsplit('/', 1))
... print(str(iiif_img.size(height=250)))
...
https://iiif.bodleian.ox.ac.uk/iiif/image/90701d49-5e0c-4fb5-9c7d-45af96565468/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/e878cc78-acd3-43ca-ba6e-90a392f15891/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/0f1ed064-a972-4215-b884-d8d658acefc5/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/6fe52b9a-5bb7-4b5b-bbcd-ad0489fcad2a/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/483ff8ec-347d-4070-8442-dbc15bc7b4de/full/,250/0/default.jpg
```

## Development and Testing

This project uses [git-flow](https://github.com/nvie/gitflow) branching conventions.
Expand Down
2 changes: 1 addition & 1 deletion piffle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version_info__ = (0, 3, 2, None)
__version_info__ = (0, 4, 0, None)

# Dot-connect all but the last. Last is dash-connected if not None.
__version__ = '.'.join([str(i) for i in __version_info__[:-1]])
Expand Down
Loading

0 comments on commit c3514ac

Please sign in to comment.