mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
Merge pull request #552 from stumpylog/bugfix-black
Bump version of black in CI/pre-commit
This commit is contained in:

committed by
Michael Shamoon

parent
f3d1bd25ad
commit
9e8ac05f72
162
.github/workflows/ci.yml
vendored
162
.github/workflows/ci.yml
vendored
@@ -13,37 +13,31 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
documentation:
|
documentation:
|
||||||
|
name: "Build Documentation"
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Install pipenv
|
||||||
|
run: pipx install pipenv
|
||||||
-
|
-
|
||||||
name: Set up Python
|
name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: 3.9
|
||||||
-
|
cache: "pipenv"
|
||||||
name: Get pip cache dir
|
cache-dependency-path: 'Pipfile.lock'
|
||||||
id: pip-cache
|
|
||||||
run: |
|
|
||||||
echo "::set-output name=dir::$(pip cache dir)"
|
|
||||||
-
|
|
||||||
name: Persistent Github pip cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ${{ steps.pip-cache.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-pip3.8}
|
|
||||||
-
|
-
|
||||||
name: Install dependencies
|
name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install --upgrade pipenv
|
pipenv sync --dev
|
||||||
pipenv install --system --dev --ignore-pipfile
|
|
||||||
-
|
-
|
||||||
name: Make documentation
|
name: Make documentation
|
||||||
run: |
|
run: |
|
||||||
cd docs/
|
cd docs/
|
||||||
make html
|
pipenv run make html
|
||||||
-
|
-
|
||||||
name: Upload artifact
|
name: Upload artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
@@ -51,52 +45,68 @@ jobs:
|
|||||||
name: documentation
|
name: documentation
|
||||||
path: docs/_build/html/
|
path: docs/_build/html/
|
||||||
|
|
||||||
codestyle:
|
code-checks-backend:
|
||||||
|
name: "Backend Code Checks"
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Set up Python
|
name: Install checkers
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.9
|
|
||||||
-
|
|
||||||
name: Get pip cache dir
|
|
||||||
id: pip-cache
|
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=dir::$(pip cache dir)"
|
pipx install reorder-python-imports
|
||||||
|
pipx install yesqa
|
||||||
|
pipx install add-trailing-comma
|
||||||
|
pipx install flake8
|
||||||
-
|
-
|
||||||
name: Persistent Github pip cache
|
name: Run reorder-python-imports
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ${{ steps.pip-cache.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-pip${{ matrix.python-version }}
|
|
||||||
-
|
|
||||||
name: Install dependencies
|
|
||||||
run: |
|
run: |
|
||||||
pip install --upgrade pipenv
|
find src/ -type f -name '*.py' ! -path "*/migrations/*" | xargs reorder-python-imports
|
||||||
pipenv install --system --dev --ignore-pipfile
|
|
||||||
-
|
-
|
||||||
name: Codestyle
|
name: Run yesqa
|
||||||
run: |
|
run: |
|
||||||
cd src/
|
find src/ -type f -name '*.py' ! -path "*/migrations/*" | xargs yesqa
|
||||||
pycodestyle --max-line-length=88 --ignore=E121,E123,E126,E226,E24,E704,W503,W504,E203
|
|
||||||
codeformatting:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Run add-trailing-comma
|
||||||
uses: actions/checkout@v2
|
run: |
|
||||||
|
find src/ -type f -name '*.py' ! -path "*/migrations/*" | xargs add-trailing-comma
|
||||||
|
# black is placed after add-trailing-comma because it may format differently
|
||||||
|
# if a trailing comma is added
|
||||||
-
|
-
|
||||||
name: Run black
|
name: Run black
|
||||||
uses: psf/black@stable
|
uses: psf/black@stable
|
||||||
with:
|
with:
|
||||||
options: "--check --diff"
|
options: "--check --diff"
|
||||||
version: "22.1.0"
|
version: "22.3.0"
|
||||||
|
-
|
||||||
|
name: Run flake8 checks
|
||||||
|
run: |
|
||||||
|
cd src/
|
||||||
|
flake8 --max-line-length=88 --ignore=E203,W503
|
||||||
|
|
||||||
tests:
|
code-checks-frontend:
|
||||||
|
name: "Frontend Code Checks"
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
-
|
||||||
|
name: Install prettier
|
||||||
|
run: |
|
||||||
|
npm install prettier
|
||||||
|
-
|
||||||
|
name: Run prettier
|
||||||
|
run:
|
||||||
|
npx prettier --check --ignore-path Pipfile.lock **/*.js **/*.ts *.md **/*.md
|
||||||
|
|
||||||
|
tests-backend:
|
||||||
|
needs: [code-checks-backend]
|
||||||
|
name: "Backend Tests (${{ matrix.python-version }})"
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -106,49 +116,77 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
-
|
||||||
|
name: Install pipenv
|
||||||
|
run: pipx install pipenv
|
||||||
-
|
-
|
||||||
name: Set up Python
|
name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: "${{ matrix.python-version }}"
|
python-version: "${{ matrix.python-version }}"
|
||||||
|
cache: "pipenv"
|
||||||
|
cache-dependency-path: 'Pipfile.lock'
|
||||||
-
|
-
|
||||||
name: Get pip cache dir
|
name: Install system dependencies
|
||||||
id: pip-cache
|
|
||||||
run: |
|
|
||||||
echo "::set-output name=dir::$(pip cache dir)"
|
|
||||||
-
|
|
||||||
name: Persistent Github pip cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ${{ steps.pip-cache.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-pip${{ matrix.python-version }}
|
|
||||||
-
|
|
||||||
name: Install dependencies
|
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update -qq
|
sudo apt-get update -qq
|
||||||
sudo apt-get install -qq --no-install-recommends unpaper tesseract-ocr imagemagick ghostscript optipng
|
sudo apt-get install -qq --no-install-recommends unpaper tesseract-ocr imagemagick ghostscript optipng
|
||||||
pip install --upgrade pipenv
|
-
|
||||||
pipenv install --system --dev --ignore-pipfile
|
name: Install Python dependencies
|
||||||
|
run: |
|
||||||
|
pipenv sync --dev
|
||||||
-
|
-
|
||||||
name: Tests
|
name: Tests
|
||||||
run: |
|
run: |
|
||||||
cd src/
|
cd src/
|
||||||
pytest
|
pipenv run pytest
|
||||||
|
-
|
||||||
|
name: Get changed files
|
||||||
|
id: changed-files-specific
|
||||||
|
uses: tj-actions/changed-files@v18.1
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
src/**
|
||||||
|
-
|
||||||
|
name: List all changed files
|
||||||
|
run: |
|
||||||
|
for file in ${{ steps.changed-files-specific.outputs.all_changed_files }}; do
|
||||||
|
echo "${file} was changed"
|
||||||
|
done
|
||||||
-
|
-
|
||||||
name: Publish coverage results
|
name: Publish coverage results
|
||||||
if: matrix.python-version == '3.9'
|
if: matrix.python-version == '3.9' && steps.changed-files-specific.outputs.any_changed == 'true'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# https://github.com/coveralls-clients/coveralls-python/issues/251
|
# https://github.com/coveralls-clients/coveralls-python/issues/251
|
||||||
run: |
|
run: |
|
||||||
cd src/
|
cd src/
|
||||||
coveralls --service=github
|
pipenv run coveralls --service=github
|
||||||
|
|
||||||
|
tests-frontend:
|
||||||
|
needs: [code-checks-frontend]
|
||||||
|
name: "Frontend Tests"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [16.x]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- run: cd src-ui && npm ci
|
||||||
|
- run: cd src-ui && npm run test
|
||||||
|
- run: cd src-ui && npm run e2e:ci
|
||||||
|
|
||||||
# build and push image to docker hub.
|
# build and push image to docker hub.
|
||||||
build-docker-image:
|
build-docker-image:
|
||||||
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/feature-') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/beta' || startsWith(github.ref, 'refs/tags/ngx-') || startsWith(github.ref, 'refs/tags/beta-'))
|
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/feature-') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/beta' || startsWith(github.ref, 'refs/tags/ngx-') || startsWith(github.ref, 'refs/tags/beta-'))
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [tests, codeformatting, codestyle]
|
needs: [tests-backend, tests-frontend]
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Prepare
|
name: Prepare
|
||||||
@@ -213,7 +251,7 @@ jobs:
|
|||||||
path: src/documents/static/frontend/
|
path: src/documents/static/frontend/
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
needs: [build-docker-image, documentation, tests, codeformatting, codestyle]
|
needs: [build-docker-image, documentation]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@@ -325,4 +363,4 @@ jobs:
|
|||||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||||
asset_path: ./paperless-ngx.tar.xz
|
asset_path: ./paperless-ngx.tar.xz
|
||||||
asset_name: paperless-ngx-${{ steps.get_version.outputs.version }}.tar.xz
|
asset_name: paperless-ngx-${{ steps.get_version.outputs.version }}.tar.xz
|
||||||
asset_content_type: application/x-xz
|
asset_content_type: application/x-xz
|
||||||
|
80
.pre-commit-config.yaml
Normal file
80
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# This file configures pre-commit hooks.
|
||||||
|
# See https://pre-commit.com/ for general information
|
||||||
|
# See https://pre-commit.com/hooks.html for a listing of possible hooks
|
||||||
|
|
||||||
|
repos:
|
||||||
|
# General hooks
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.1.0
|
||||||
|
hooks:
|
||||||
|
- id: check-docstring-first
|
||||||
|
- id: check-json
|
||||||
|
exclude: "tsconfig.*json"
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-toml
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
exclude_types:
|
||||||
|
- svg
|
||||||
|
- pofile
|
||||||
|
exclude: "(^LICENSE$)"
|
||||||
|
- id: mixed-line-ending
|
||||||
|
args:
|
||||||
|
- "--fix=lf"
|
||||||
|
- id: trailing-whitespace
|
||||||
|
exclude_types:
|
||||||
|
- svg
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: detect-private-key
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
|
rev: "v2.6.1"
|
||||||
|
hooks:
|
||||||
|
- id: prettier
|
||||||
|
types_or:
|
||||||
|
- javascript
|
||||||
|
- ts
|
||||||
|
- markdown
|
||||||
|
exclude: "(^Pipfile\\.lock$)"
|
||||||
|
# Python hooks
|
||||||
|
- repo: https://github.com/asottile/reorder_python_imports
|
||||||
|
rev: v3.0.1
|
||||||
|
hooks:
|
||||||
|
- id: reorder-python-imports
|
||||||
|
exclude: "(migrations)"
|
||||||
|
- repo: https://github.com/asottile/yesqa
|
||||||
|
rev: "v1.3.0"
|
||||||
|
hooks:
|
||||||
|
- id: yesqa
|
||||||
|
exclude: "(migrations)"
|
||||||
|
- repo: https://github.com/asottile/add-trailing-comma
|
||||||
|
rev: "v2.2.1"
|
||||||
|
hooks:
|
||||||
|
- id: add-trailing-comma
|
||||||
|
exclude: "(migrations)"
|
||||||
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
|
rev: 3.9.2
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
files: ^src/
|
||||||
|
args:
|
||||||
|
- "--config=./src/setup.cfg"
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 22.3.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
# Dockerfile hooks
|
||||||
|
- repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
|
||||||
|
rev: "v0.1.0"
|
||||||
|
hooks:
|
||||||
|
- id: dockerfilelint
|
||||||
|
# Shell script hooks
|
||||||
|
- repo: https://github.com/lovesegfault/beautysh
|
||||||
|
rev: v6.2.1
|
||||||
|
hooks:
|
||||||
|
- id: beautysh
|
||||||
|
args:
|
||||||
|
- "--tab"
|
||||||
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||||
|
rev: "v0.8.0.4"
|
||||||
|
hooks:
|
||||||
|
- id: shellcheck
|
Reference in New Issue
Block a user