]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Adds additional CI checks for the backend and frontend, to complement pre-commit... 324/head
authorTrenton Holmes <holmes.trenton@gmail.com>
Sun, 13 Mar 2022 21:39:31 +0000 (14:39 -0700)
committerTrenton Holmes <holmes.trenton@gmail.com>
Mon, 14 Mar 2022 02:37:34 +0000 (19:37 -0700)
.github/workflows/ci.yml
.pre-commit-config.yaml
.prettierrc [new file with mode: 0644]
src/setup.cfg

index ab700c0dcf6ebfa11a6699c3ea7dc070c556b69a..a02f55484315d5678a6d64f96d8b1c686ffe535f 100644 (file)
@@ -44,45 +44,68 @@ jobs:
           name: documentation
           path: docs/_build/html/
 
-  codestyle:
+  backend-code-checks:
+    name: "Backend Code Checks"
     runs-on: ubuntu-20.04
     steps:
       -
         name: Checkout
         uses: actions/checkout@v2
       -
-        name: Install pipenv
-        run: pipx install pipenv
+        name: Install checkers
+        run: |
+          pipx install reorder-python-imports
+          pipx install yesqa
+          pipx install add-trailing-comma
+          pipx install flake8
       -
-        name: Set up Python
-        uses: actions/setup-python@v2
-        with:
-          python-version: 3.9
-          cache: "pipenv"
-          cache-dependency-path: 'Pipfile.lock'
+        name: Run reorder-python-imports
+        run: |
+          find src/ -type f -name '*.py' ! -path "*/migrations/*" | xargs reorder-python-imports
       -
-        name: Install dependencies
+        name: Run yesqa
         run: |
-          pipenv sync --dev
+          find src/ -type f -name '*.py' ! -path "*/migrations/*" | xargs yesqa
       -
-        name: Codestyle
+        name: Run add-trailing-comma
+        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
+        uses: psf/black@stable
+        with:
+          options: "--check --diff"
+          version: "22.1.0"
+      -
+        name: Run flake8 checks
         run: |
           cd src/
-          pipenv run pycodestyle --max-line-length=88 --ignore=E121,E123,E126,E226,E24,E704,W503,W504,E203
-  codeformatting:
+          flake8 --max-line-length=88 --ignore=E203,W503
+
+  frontend-code-checks:
+    name: "Frontend Code Checks"
     runs-on: ubuntu-20.04
     steps:
       -
         name: Checkout
         uses: actions/checkout@v2
-      -
-        name: Run black
-        uses: psf/black@stable
+      - uses: actions/setup-node@v2
         with:
-          options: "--check --diff"
-          version: "22.1.0"
+          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-tests:
+    needs: [backend-code-checks]
+    name: "Backend Tests (${{ matrix.python-version }})"
     runs-on: ubuntu-20.04
     strategy:
       matrix:
@@ -130,7 +153,7 @@ jobs:
   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-'))
     runs-on: ubuntu-latest
-    needs: [tests, codeformatting, codestyle]
+    needs: [backend-tests, frontend-code-checks]
     steps:
       -
         name: Prepare
@@ -195,7 +218,7 @@ jobs:
           path: src/documents/static/frontend/
 
   build-release:
-    needs: [build-docker-image, documentation, tests, codeformatting, codestyle]
+    needs: [build-docker-image, documentation, backend-tests, backend-code-checks, frontend-code-checks]
     runs-on: ubuntu-20.04
     steps:
       -
index 5afa36e9ffb67c77b2509b8b5e2f6d799eb2344a..3758e40ba7cabe9ac91f15198d62c6797ba73656 100644 (file)
@@ -30,9 +30,6 @@ repos:
     rev: "v2.5.1"
     hooks:
       - id: prettier
-        args:
-          - "--no-semi"
-          - "--single-quote"
         types_or:
           - javascript
           - ts
@@ -59,10 +56,8 @@ repos:
     hooks:
       - id: flake8
         files: ^src/
-        exclude: "(migrations)|(paperless/settings.py)|(.*\\.tox)|(.*/tests/.*)"
         args:
-          - "--max-line-length=88"
-          - "--ignore=E203,W503"
+          - "--config=./src/setup.cfg"
   - repo: https://github.com/psf/black
     rev: 22.1.0
     hooks:
diff --git a/.prettierrc b/.prettierrc
new file mode 100644 (file)
index 0000000..5d71058
--- /dev/null
@@ -0,0 +1,4 @@
+# https://prettier.io/docs/en/options.html#semicolons
+semi: false
+# https://prettier.io/docs/en/options.html#quotes
+singleQuote: true
index 2a1a348bd6f6da774f7bbf962d3ccfcc35cba9fa..463d30931254b5e0048d82b3b8c9a35662334a65 100644 (file)
@@ -1,5 +1,9 @@
-[pycodestyle]
-exclude = migrations, paperless/settings.py, .tox, */tests/*
+[flake8]
+extend-exclude = */migrations/*, paperless/settings.py, */tests/*
+# E203 - https://www.flake8rules.com/rules/E203.html
+# W503 - https://www.flake8rules.com/rules/W503.html
+ignore = E203,W503
+max-line-length = 88
 
 [tool:pytest]
 DJANGO_SETTINGS_MODULE=paperless.settings
@@ -7,7 +11,6 @@ addopts = --pythonwarnings=all --cov --cov-report=html -n auto
 env =
   PAPERLESS_DISABLE_DBHANDLER=true
 
-
 [coverage:run]
 source =
   ./