mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Merge pull request #1362 from paperless-ngx/ci-file-health
Chore: use pre-commit in the Ci workflow
This commit is contained in:
commit
765fea7f7e
107
.github/workflows/ci.yml
vendored
107
.github/workflows/ci.yml
vendored
@ -14,9 +14,29 @@ on:
|
|||||||
- 'translations**'
|
- 'translations**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
pre-commit:
|
||||||
|
name: Linting Checks
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Install tools
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.9"
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Check files
|
||||||
|
uses: pre-commit/action@v3.0.0
|
||||||
|
|
||||||
documentation:
|
documentation:
|
||||||
name: "Build Documentation"
|
name: "Build Documentation"
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
needs:
|
||||||
|
- pre-commit
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@ -47,11 +67,86 @@ jobs:
|
|||||||
name: documentation
|
name: documentation
|
||||||
path: docs/_build/html/
|
path: docs/_build/html/
|
||||||
|
|
||||||
ci-backend:
|
tests-backend:
|
||||||
uses: ./.github/workflows/reusable-ci-backend.yml
|
name: "Tests (${{ matrix.python-version }})"
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
needs:
|
||||||
|
- pre-commit
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.8', '3.9', '3.10']
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
-
|
||||||
|
name: Install pipenv
|
||||||
|
run: pipx install pipenv
|
||||||
|
-
|
||||||
|
name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "${{ matrix.python-version }}"
|
||||||
|
cache: "pipenv"
|
||||||
|
cache-dependency-path: 'Pipfile.lock'
|
||||||
|
-
|
||||||
|
name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -qq
|
||||||
|
sudo apt-get install -qq --no-install-recommends unpaper tesseract-ocr imagemagick ghostscript libzbar0 poppler-utils
|
||||||
|
-
|
||||||
|
name: Install Python dependencies
|
||||||
|
run: |
|
||||||
|
pipenv sync --dev
|
||||||
|
-
|
||||||
|
name: Tests
|
||||||
|
run: |
|
||||||
|
cd src/
|
||||||
|
pipenv run pytest
|
||||||
|
-
|
||||||
|
name: Get changed files
|
||||||
|
id: changed-files-specific
|
||||||
|
uses: tj-actions/changed-files@v24
|
||||||
|
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
|
||||||
|
if: matrix.python-version == '3.9' && steps.changed-files-specific.outputs.any_changed == 'true'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# https://github.com/coveralls-clients/coveralls-python/issues/251
|
||||||
|
run: |
|
||||||
|
cd src/
|
||||||
|
pipenv run coveralls --service=github
|
||||||
|
|
||||||
ci-frontend:
|
tests-frontend:
|
||||||
uses: ./.github/workflows/reusable-ci-frontend.yml
|
name: "Tests Frontend"
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
needs:
|
||||||
|
- pre-commit
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [16.x]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
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
|
||||||
|
|
||||||
prepare-docker-build:
|
prepare-docker-build:
|
||||||
name: Prepare Docker Pipeline Data
|
name: Prepare Docker Pipeline Data
|
||||||
@ -65,8 +160,8 @@ jobs:
|
|||||||
cancel-in-progress: false
|
cancel-in-progress: false
|
||||||
needs:
|
needs:
|
||||||
- documentation
|
- documentation
|
||||||
- ci-backend
|
- tests-backend
|
||||||
- ci-frontend
|
- tests-frontend
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set ghcr repository name
|
name: Set ghcr repository name
|
||||||
|
129
.github/workflows/reusable-ci-backend.yml
vendored
129
.github/workflows/reusable-ci-backend.yml
vendored
@ -1,129 +0,0 @@
|
|||||||
name: Backend CI Jobs
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
code-checks-backend:
|
|
||||||
name: "Code Style Checks"
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
-
|
|
||||||
name: Install checkers
|
|
||||||
run: |
|
|
||||||
pipx install reorder-python-imports
|
|
||||||
pipx install yesqa
|
|
||||||
pipx install add-trailing-comma
|
|
||||||
pipx install flake8
|
|
||||||
-
|
|
||||||
name: Run reorder-python-imports
|
|
||||||
run: |
|
|
||||||
find src/ -type f -name '*.py' ! -path "*/migrations/*" | xargs reorder-python-imports
|
|
||||||
-
|
|
||||||
name: Run yesqa
|
|
||||||
run: |
|
|
||||||
find src/ -type f -name '*.py' ! -path "*/migrations/*" | xargs yesqa
|
|
||||||
-
|
|
||||||
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.3.0"
|
|
||||||
-
|
|
||||||
name: Run flake8 checks
|
|
||||||
run: |
|
|
||||||
cd src/
|
|
||||||
flake8 --max-line-length=88 --ignore=E203,W503
|
|
||||||
|
|
||||||
tests-backend:
|
|
||||||
name: "Tests (${{ matrix.python-version }})"
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
needs:
|
|
||||||
- code-checks-backend
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: ['3.8', '3.9', '3.10']
|
|
||||||
fail-fast: false
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 2
|
|
||||||
-
|
|
||||||
name: Install pipenv
|
|
||||||
run: pipx install pipenv
|
|
||||||
-
|
|
||||||
name: Set up Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: "${{ matrix.python-version }}"
|
|
||||||
cache: "pipenv"
|
|
||||||
cache-dependency-path: 'Pipfile.lock'
|
|
||||||
-
|
|
||||||
name: Install system dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -qq --no-install-recommends unpaper tesseract-ocr imagemagick ghostscript libzbar0 poppler-utils
|
|
||||||
-
|
|
||||||
name: Install Python dependencies
|
|
||||||
run: |
|
|
||||||
pipenv sync --dev
|
|
||||||
-
|
|
||||||
name: Tests
|
|
||||||
run: |
|
|
||||||
cd src/
|
|
||||||
pipenv run pytest
|
|
||||||
-
|
|
||||||
name: Get changed files
|
|
||||||
id: changed-files-specific
|
|
||||||
uses: tj-actions/changed-files@v24
|
|
||||||
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
|
|
||||||
if: matrix.python-version == '3.9' && steps.changed-files-specific.outputs.any_changed == 'true'
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# https://github.com/coveralls-clients/coveralls-python/issues/251
|
|
||||||
run: |
|
|
||||||
cd src/
|
|
||||||
pipenv run coveralls --service=github
|
|
||||||
|
|
||||||
dockerfile-lint:
|
|
||||||
name: "Lint ${{ matrix.dockerfile }}"
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
dockerfile:
|
|
||||||
- Dockerfile
|
|
||||||
- docker-builders/Dockerfile.qpdf
|
|
||||||
- docker-builders/Dockerfile.jbig2enc
|
|
||||||
- docker-builders/Dockerfile.psycopg2
|
|
||||||
- docker-builders/Dockerfile.pikepdf
|
|
||||||
fail-fast: false
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
-
|
|
||||||
uses: hadolint/hadolint-action@v2.1.0
|
|
||||||
with:
|
|
||||||
dockerfile: ${{ matrix.dockerfile }}
|
|
42
.github/workflows/reusable-ci-frontend.yml
vendored
42
.github/workflows/reusable-ci-frontend.yml
vendored
@ -1,42 +0,0 @@
|
|||||||
name: Frontend CI Jobs
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
code-checks-frontend:
|
|
||||||
name: "Code Style Checks"
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-node@v3
|
|
||||||
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-frontend:
|
|
||||||
name: "Tests"
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
needs:
|
|
||||||
- code-checks-frontend
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [16.x]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
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
|
|
@ -95,7 +95,7 @@ initialize() {
|
|||||||
done
|
done
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
${gosu_cmd[@]} /sbin/docker-prepare.sh
|
"${gosu_cmd[@]}" /sbin/docker-prepare.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
install_languages() {
|
install_languages() {
|
||||||
@ -138,7 +138,7 @@ install_languages() {
|
|||||||
echo "Paperless-ngx docker container starting..."
|
echo "Paperless-ngx docker container starting..."
|
||||||
|
|
||||||
gosu_cmd=(gosu paperless)
|
gosu_cmd=(gosu paperless)
|
||||||
if [ $(id -u) == $(id -u paperless) ]; then
|
if [ "$(id -u)" == "$(id -u paperless)" ]; then
|
||||||
gosu_cmd=()
|
gosu_cmd=()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ initialize
|
|||||||
|
|
||||||
if [[ "$1" != "/"* ]]; then
|
if [[ "$1" != "/"* ]]; then
|
||||||
echo Executing management command "$@"
|
echo Executing management command "$@"
|
||||||
exec ${gosu_cmd[@]} python3 manage.py "$@"
|
exec "${gosu_cmd[@]}" python3 manage.py "$@"
|
||||||
else
|
else
|
||||||
echo Executing "$@"
|
echo Executing "$@"
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
rootless_args=()
|
rootless_args=()
|
||||||
if [ $(id -u) == $(id -u paperless) ]; then
|
if [ "$(id -u)" == "$(id -u paperless)" ]; then
|
||||||
rootless_args=(
|
rootless_args=(
|
||||||
--user
|
--user
|
||||||
paperless
|
paperless
|
||||||
@ -12,4 +12,4 @@ if [ $(id -u) == $(id -u paperless) ]; then
|
|||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/usr/local/bin/supervisord -c /etc/supervisord.conf ${rootless_args[@]}
|
/usr/local/bin/supervisord -c /etc/supervisord.conf "${rootless_args[@]}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user