Skip to content

Commit

Permalink
Add typing, JSON schema and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed May 26, 2021
1 parent 8cbc375 commit d6f8ad5
Show file tree
Hide file tree
Showing 27 changed files with 1,397 additions and 184 deletions.
2 changes: 2 additions & 0 deletions .bandit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skips:
- B101 # Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
7 changes: 5 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
*
!process
!.pylintrc
!scan_to_paperless
!.prospector.yaml
!.bandit.yaml
!mypy.ini
!README.md
!setup.py
!setup.cfg
!requirements-install.txt
!Pipfile
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ jobs:
- name: Checks
run: c2cciutils-checks

# the if the generated files are up to date
- run: ./run-jsonschema-gentypes
- run: jsonschema2md scan_to_paperless/config-schema.json config.md
- run: jsonschema2md scan_to_paperless/process.json process.md
- run: git diff --quiet
- run: git diff
if: failure()

- run: docker build --target=base --tag=sbrunner/scan-to-paperless .
- run: docker build --target=tests --tag=tests .
- run: docker run --rm tests prospector
- run: docker run --rm tests prospector --output=pylint
- name: Init Docker volumes
run: |
docker run --rm --detach --name volumes --volume=tests:/tests --volume=results:/results alpine tail -f /dev/null
Expand All @@ -41,9 +49,8 @@ jobs:
docker run --rm --env=PYTHONPATH=/opt/
--volume=results:/results --volume=tests:/tests
tests bash -c '
mv /opt/process /opt/process.py &&
cd /tests &&
coverage run --source=process --module pytest --durations=0 --verbose --color=yes
coverage run --source=scan_to_paperless --module pytest --durations=0 --verbose --color=yes
--profile --profile-svg --junitxml=/results/test-reports/junit.xml . &&
coverage report &&
coverage html --directory=/results/coverage'
Expand Down
35 changes: 35 additions & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
strictness: veryhigh

ignore-paths:
- scan_to_paperless/process_schema.py
- scan_to_paperless/config.py

pylint:
disable:
- wrong-import-order
- line-too-long
- no-value-for-parameter
- too-few-public-methods
- too-many-lines
- too-many-branches
- too-many-statements
- too-many-locals
- too-many-nested-blocks
- broad-except
options:
good-names: x,y

bandit:
run: true
options:
config: .bandit.yaml

mypy:
run: true

mccabe:
run: false

pyroma:
run: true
9 changes: 0 additions & 9 deletions .pylintrc

This file was deleted.

31 changes: 15 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,38 @@ VOLUME /source \

ENV LANG=C.UTF-8

WORKDIR /opt

FROM base-dist as tests-dist

RUN apt update
RUN DEBIAN_FRONTEND=noninteractive apt install --assume-yes --no-install-recommends \
poppler-utils ghostscript graphviz

RUN cd /tmp && pipenv sync --system --clear --dev

WORKDIR /opt
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt install --assume-yes --no-install-recommends \
poppler-utils ghostscript graphviz && \
apt-get clean && \
rm --recursive --force /var/lib/apt/lists/* /root/.cache /var/cache/* && \
cd /tmp && pipenv sync --system --clear --dev


FROM base-dist as base

COPY process /opt/
COPY scan_to_paperless scan_to_paperless/
COPY setup.py README.md ./
RUN python3 -m pip install --no-cache-dir --editable .

CMD ["/opt/process"]
CMD ["scan-process"]


FROM tests-dist as tests

COPY process /opt/
COPY .pylintrc mypy.ini setup.cfg /opt/
RUN touch __init__.py

CMD ["/opt/process"]
COPY . ./
RUN python3 -m pip install --no-cache-dir --editable .


FROM base as all

RUN \
apt update && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt install --assume-yes --no-install-recommends \
tesseract-ocr-all && \
apt clean && \
apt-get clean && \
rm --recursive --force /var/lib/apt/lists/* /var/cache/*
5 changes: 4 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ scipy = "==1.6.3"
scikit-image = "==0.18.1"
opencv-python-headless = "==4.5.2.52"
deskew = "==0.10.29"
jsonschema-gentypes = "==0.9.0"
"ruamel.yaml" = "==0.17.4"

[dev-packages]
prospector = {extras = ["bandit", "mypy"], version = "==1.3.1"}
prospector = {extras = ["with_bandit", "with_mypy", "with_pyroma"], version = "==1.3.1"}
flake8 = "==3.8.4"
pytest = "==6.2.4"
coverage = "==5.5"
pytest-profiling = "==1.7.0"
argcomplete = "==1.12.3"

[requires]
python_version = "3.8"
Loading

0 comments on commit d6f8ad5

Please sign in to comment.