Skip to content

Commit

Permalink
Merge pull request #53 from callegarimattia/main
Browse files Browse the repository at this point in the history
Make the release badge run after release
  • Loading branch information
krishnasism authored Jan 17, 2024
2 parents b601545 + 4137839 commit 8ca4d48
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 81 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-badge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: build
on:
schedule:
- cron: '5 0 * * *'
workflow_dispatch:
push:
branches:
- main

jobs:
build:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,29 @@ jobs:
run: |
python -m build
twine upload dist/*
badge:
needs: deploy
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.10", "3.9"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install ghostscript
run: |
sudo apt-get update
sudo apt-get install ghostscript
- name : Install from PyPI and run tests
run: |
mkdir $HOME/test_external_dir
cd $HOME/test_external_dir
cp $GITHUB_WORKSPACE/tests/ . -r
python -m venv venv
source venv/bin/activate
pip install hotpdf pytest pytest-xdist
python -m pytest tests -n=auto
32 changes: 0 additions & 32 deletions .github/workflows/release-badge.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
run: python -m mypy

tests:
needs: linter
strategy:
matrix:
python-version: ["3.11", "3.10", "3.9"]
Expand Down
55 changes: 23 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: ruff-format
name: ruff format
entry: ruff format .
language: system
always_run: true
pass_filenames: false
- id: ruff-format-imports
name: ruff format imports
entry: ruff check --select I --fix .
language: system
always_run: true
pass_filenames: false
- id: ruff-lint
name: ruff lint
entry: ruff check .
language: system
always_run: true
pass_filenames: false
- id: mypy
name: mypy
entry: mypy
language: system
always_run: true
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: ruff-format
name: ruff format
entry: ruff format
language: system
pass_filenames: false
- id: ruff-lint
name: ruff lint
entry: ruff check
language: system
pass_filenames: false
- id: mypy
name: mypy
entry: mypy
language: system
pass_filenames: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# hotpdf

[![Documentation Status](https://readthedocs.org/projects/hotpdf/badge/?version=latest)](https://hotpdf.readthedocs.io/en/latest/?badge=latest)
[![latest](https://github.com/weareprestatech/hotpdf/actions/workflows/release-badge.yml/badge.svg)](https://github.com/weareprestatech/hotpdf/actions/workflows/release-badge.yml)
[![latest](https://github.com/weareprestatech/hotpdf/actions/workflows/python-publish.yml/badge.svg)](https://github.com/weareprestatech/hotpdf/actions/workflows/python-publish.yml)
[![build](https://github.com/weareprestatech/hotpdf/actions/workflows/build-badge.yml/badge.svg)](https://github.com/weareprestatech/hotpdf/actions/workflows/build-badge.yml)
[![Coverage Status](https://coveralls.io/repos/github/weareprestatech/hotpdf/badge.svg?branch=main)](https://coveralls.io/github/weareprestatech/hotpdf?branch=main)

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ requires-python = ">=3.9"
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.9",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down Expand Up @@ -72,6 +74,7 @@ fixable = ["ALL"]
exclude = ["docs"]
preview = true
line-length = 150
extend-select = ["I"]

[tool.mypy]
warn_unused_configs = true
Expand Down
31 changes: 16 additions & 15 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,20 @@ def test_get_spans(valid_file_name):
occurences_by_page = occurences[page_num]
for occurence_by_page in occurences_by_page:
element_dimension = get_element_dimension(occurence_by_page)
full_spans_in_bbox = hot_pdf_object.extract_spans(
x0=element_dimension.x0,
y0=element_dimension.y0,
x1=element_dimension.x1,
y1=element_dimension.y1,
)
__full_spans_in_bbox_unsorted = hot_pdf_object.extract_spans(
x0=element_dimension.x0,
y0=element_dimension.y0,
x1=element_dimension.x1,
y1=element_dimension.y1 + 100, # to simulate multi line extraction
sort=False,
)
with pytest.warns(UserWarning, match="This function will be deprecated in the next release"):
full_spans_in_bbox = hot_pdf_object.extract_spans(
x0=element_dimension.x0,
y0=element_dimension.y0,
x1=element_dimension.x1,
y1=element_dimension.y1,
)
__full_spans_in_bbox_unsorted = hot_pdf_object.extract_spans(
x0=element_dimension.x0,
y0=element_dimension.y0,
x1=element_dimension.x1,
y1=element_dimension.y1 + 100, # to simulate multi line extraction
sort=False,
)
assert len(full_spans_in_bbox) == 1
assert len(__full_spans_in_bbox_unsorted) > 1
assert full_spans_in_bbox[0] in __full_spans_in_bbox_unsorted
Expand Down Expand Up @@ -254,7 +255,7 @@ def test_extract_page_range_exception(multiple_pages_file_name, first_page, last

def test_no_spans_in_xml_file_extraction(valid_file_name):
hot_pdf_object = HotPdf()
with patch.object(MemoryMap, "_MemoryMap__get_page_spans") as get_page_spans:
with patch.object(MemoryMap, "_MemoryMap__get_page_spans") as get_page_spans, pytest.warns(UserWarning, match="No spans exist on this page"):
get_page_spans.return_value = None
hot_pdf_object.load(valid_file_name)
get_page_spans.assert_called_once()
Expand Down Expand Up @@ -283,7 +284,7 @@ def test_no_spans_in_xml_file_extraction(valid_file_name):

def test_no_spans_in_xml_file_extract_spans(valid_file_name):
hot_pdf_object = HotPdf()
with patch.object(MemoryMap, "_MemoryMap__get_page_spans") as get_page_spans:
with patch.object(MemoryMap, "_MemoryMap__get_page_spans") as get_page_spans, pytest.warns(UserWarning, match="No spans exist on this page"):
hot_pdf_object.load(valid_file_name)
get_page_spans.return_value = None
# Test No spans
Expand Down

0 comments on commit 8ca4d48

Please sign in to comment.