Skip to content

Commit

Permalink
release: v1.0.0
Browse files Browse the repository at this point in the history
Co-Authored-by: Johnny Mariéthoz <[email protected]>
  • Loading branch information
jma committed May 16, 2024
1 parent a155fef commit 40c998e
Show file tree
Hide file tree
Showing 11 changed files with 1,201 additions and 738 deletions.
43 changes: 16 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ name: CI

on:
push:
branches: main
branches:
- main
- staging
pull_request:
branches:
- main
- "maint-**"
- "staging"
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 3 * * 6"
Expand All @@ -36,29 +38,21 @@ on:

jobs:
Tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
# TODO: You can add/remove combinations e.g. `dev` requirements or
# `postgresql13` by adding a new item to the following lists.
# You can see the complete list of services and versions that are available at:
# https://docker-services-cli.readthedocs.io/en/latest/configuration.html
python-version: ["3.9"]
requirements-level: [pypi]
db-service: [postgresql13]
search-service: [elasticsearch]
include:
- search-service: elasticsearch
SEARCH_EXTRAS: "elasticsearch"

# - search-service: opensearch2
# SEARCH_EXTRAS: "opensearch2"
dependencies: ['dev', 'deploy']

env:
DB: ${{ matrix.db-service }}
SEARCH: ${{ matrix.search-service }}
# TODO: Adapt EXTRAS accordingly
EXTRAS: tests,${{ matrix.search-service }}

steps:
- name: Checkout
Expand All @@ -69,25 +63,20 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Generate dependencies
run: |
python -m pip install --upgrade pip setuptools py wheel requirements-builder
requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
- name: Install Poetry
uses: snok/install-poetry@v1

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}
- name: Update depencencies
if: ${{ matrix.dependencies == 'dev' }}
run: poetry update

- name: Install dependencies
run: |
pip install -r .${{matrix.requirements-level}}-${{ matrix.python-version }}-requirements.txt
pip install ".[$EXTRAS]"
pip freeze
docker --version
docker-compose --version
poetry install
- name: Run tests
run: |
./run-tests.sh
poetry run ./run-tests.sh
- name: Run build
run: poetry build
5 changes: 0 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@
:target: https://github.com/rero/rero-invenio-files/blob/master/LICENSE

Files support for the RERO invenio instances.

TODO: Please provide feature overview of module

Further documentation is available on
https://rero-invenio-files.readthedocs.io/
1,690 changes: 1,140 additions & 550 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[tool.poetry]
name = "rero-invenio-files"
version = "0.1.0"
version = "1.0.0"
description = "Files support for the RERO invenio instances."
authors = ["RERO <[email protected]>"]
license = "GNU Affero General Public License v3.0"
readme = "README.rst"

[tool.poetry.dependencies]
python = "^3.9"
invenio-records-resources = "^4.18.3"
invenio-records-resources = "<5.7.0"
invenio-search = {version = ">=2.1.0,<3.0.0", extras = ["elasticsearch7"]}
invenio-db = {version = ">=1.1.0,<1.2.0", extras = ["postgresql"]}
fpdf2 = "^2.7.7"
pymupdf = "^1.23.21"
invenio-previewer = "^2.2.0"
invenio-theme = ">=2.5.7,<3.0.0"
invenio-theme = "<4.0.0"


[tool.poetry.group.dev.dependencies]
Expand All @@ -23,6 +23,8 @@ pytest-invenio = ">=2.1.6,<3.0.0"
pytest-black = ">=0.3.0"
sphinx = ">=4.5.0"
mock = "^5.1.0"
safety = "^3.2.0"
autoflake = "^2.3.1"

[build-system]
requires = ["poetry-core"]
Expand Down Expand Up @@ -50,3 +52,16 @@ records = "rero_invenio_files.records.jsonschemas"

[tool.poetry.plugins."invenio_search.mappings"]
records = "rero_invenio_files.records.mappings"

[tool.distutils.bdist_wheel]
universal = true

[tool.pydocstyle]
add_ignore = "D401"

[tool.isort]
profile="black"

[tool.pytest.ini_options]
addopts = "--black --isort --pydocstyle --doctest-glob=\"*.rst\" --doctest-modules --cov=rero_invenio_files --cov-report=term-missing"
testpaths = "docs tests rero_invenio_files"
2 changes: 1 addition & 1 deletion rero_invenio_files/records/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""Files support for the RERO invenio instances."""

from invenio_records_resources.services.records.schema import BaseRecordSchema
from marshmallow import INCLUDE, Schema, fields
from marshmallow import Schema, fields
from marshmallow_utils.fields import SanitizedUnicode


Expand Down
4 changes: 1 addition & 3 deletions rero_invenio_files/records/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def should_render(self, obj, ctx):
# pdf is supported
if not hasattr(obj.file, "mimetype"):
return False
if obj.file.mimetype in ["application/pdf", "image/jpeg", "image/png"]:
return True
return False
return obj.file.mimetype in ["application/pdf", "image/jpeg", "image/png"]


class ThumbFileLink(PreviewFileLink):
Expand Down
12 changes: 12 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ trap cleanup EXIT
# python -m check_manifest
python -m sphinx.cmd.build -qnNW docs docs/_build/html

safety_exceptions="-i 51668 -i 42194 -i 62019 -i 67599 -i 51457"
msg=$(safety check -o text ${safety_exceptions}) || {
echo "Safety vulnerabilites found for packages:" $(safety check -o bare ${safety_exceptions})
echo "Run: \"safety check -o screen ${safety_exceptions} | grep -i vulnerability\" for more details"
exit 1
}

autoflake -c -r --remove-all-unused-imports --ignore-init-module-imports . &> /dev/null || {
autoflake --remove-all-unused-imports -r --ignore-init-module-imports .
exit 1
}

# TODO: Remove services below that are not neeed (fix also the usage note).
eval "$(docker-services-cli up --db ${DB:-postgresql} --search ${SEARCH:-elasticsearch} --cache ${CACHE:-redis} --mq ${MQ:-rabbitmq} --env)"
python -m pytest
Expand Down
111 changes: 0 additions & 111 deletions setup.cfg

This file was deleted.

22 changes: 0 additions & 22 deletions setup.py

This file was deleted.

16 changes: 10 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@
from invenio_app.factory import create_app as _create_app
from mock_module.services import MockFileServiceConfig, MockRecordServiceConfig

from rero_invenio_files.pdf import PDFGenerator

@pytest.fixture(scope="module")
def pdf_file():
"""."""
from rero_invenio_files.pdf import PDFGenerator

data = dict(
@pytest.fixture(scope="module")
def simple_data():
"""Simple document data for pdf generation."""
yield dict(
header="Document pid: 1234",
title="Simple Title",
authors=["Author1, Author2"],
summary="""The year 1866 was marked by a bizarre development, an unexplained and downright inexplicable phenomenon that surely no one has forgotten. Without getting into those rumors that upset civilians in the seaports and deranged the public mind even far inland, it must be said that professional seamen were especially alarmed. Traders, shipowners, captains of vessels, skippers, and master mariners from Europe and America, naval officers from every country, and at their heels the various national governments on these two continents, were all extremely disturbed by the business.""",
)

pdf = PDFGenerator(data)

@pytest.fixture(scope="module")
def pdf_file(simple_data):
"""Simple pdf file."""
pdf = PDFGenerator(simple_data)
pdf.render()
return pdf.output()

Expand Down
13 changes: 3 additions & 10 deletions tests/test_pdf_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@
from rero_invenio_files.pdf import PDFGenerator


def test_pdf_generation():
# Instantiation of inherited class
data = dict(
header="Document pid: 1234",
title="Simple Title",
authors=["Author1, Author2"],
summary="""The year 1866 was marked by a bizarre development, an unexplained and downright inexplicable phenomenon that surely no one has forgotten. Without getting into those rumors that upset civilians in the seaports and deranged the public mind even far inland, it must be said that professional seamen were especially alarmed. Traders, shipowners, captains of vessels, skippers, and master mariners from Europe and America, naval officers from every country, and at their heels the various national governments on these two continents, were all extremely disturbed by the business.""",
)

pdf = PDFGenerator(data)
def test_pdf_generation(simple_data):
"""Test the pdf generation."""
pdf = PDFGenerator(simple_data)
pdf.render()
assert pdf.output()

0 comments on commit 40c998e

Please sign in to comment.