Skip to content

Commit 765fea7

Browse files
authored
Merge pull request #1362 from paperless-ngx/ci-file-health
Chore: use pre-commit in the Ci workflow
2 parents ca75fb5 + 32861ad commit 765fea7

File tree

6 files changed

+107
-183
lines changed

6 files changed

+107
-183
lines changed

.github/workflows/ci.yml

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,29 @@ on:
1414
- 'translations**'
1515

1616
jobs:
17+
pre-commit:
18+
name: Linting Checks
19+
runs-on: ubuntu-latest
20+
steps:
21+
-
22+
name: Checkout repository
23+
uses: actions/checkout@v3
24+
25+
-
26+
name: Install tools
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: "3.9"
30+
31+
-
32+
name: Check files
33+
uses: pre-commit/[email protected]
34+
1735
documentation:
1836
name: "Build Documentation"
1937
runs-on: ubuntu-20.04
38+
needs:
39+
- pre-commit
2040
steps:
2141
-
2242
name: Checkout
@@ -47,11 +67,86 @@ jobs:
4767
name: documentation
4868
path: docs/_build/html/
4969

50-
ci-backend:
51-
uses: ./.github/workflows/reusable-ci-backend.yml
70+
tests-backend:
71+
name: "Tests (${{ matrix.python-version }})"
72+
runs-on: ubuntu-20.04
73+
needs:
74+
- pre-commit
75+
strategy:
76+
matrix:
77+
python-version: ['3.8', '3.9', '3.10']
78+
fail-fast: false
79+
steps:
80+
-
81+
name: Checkout
82+
uses: actions/checkout@v3
83+
with:
84+
fetch-depth: 2
85+
-
86+
name: Install pipenv
87+
run: pipx install pipenv
88+
-
89+
name: Set up Python
90+
uses: actions/setup-python@v4
91+
with:
92+
python-version: "${{ matrix.python-version }}"
93+
cache: "pipenv"
94+
cache-dependency-path: 'Pipfile.lock'
95+
-
96+
name: Install system dependencies
97+
run: |
98+
sudo apt-get update -qq
99+
sudo apt-get install -qq --no-install-recommends unpaper tesseract-ocr imagemagick ghostscript libzbar0 poppler-utils
100+
-
101+
name: Install Python dependencies
102+
run: |
103+
pipenv sync --dev
104+
-
105+
name: Tests
106+
run: |
107+
cd src/
108+
pipenv run pytest
109+
-
110+
name: Get changed files
111+
id: changed-files-specific
112+
uses: tj-actions/changed-files@v24
113+
with:
114+
files: |
115+
src/**
116+
-
117+
name: List all changed files
118+
run: |
119+
for file in ${{ steps.changed-files-specific.outputs.all_changed_files }}; do
120+
echo "${file} was changed"
121+
done
122+
-
123+
name: Publish coverage results
124+
if: matrix.python-version == '3.9' && steps.changed-files-specific.outputs.any_changed == 'true'
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
# https://github.com/coveralls-clients/coveralls-python/issues/251
128+
run: |
129+
cd src/
130+
pipenv run coveralls --service=github
52131
53-
ci-frontend:
54-
uses: ./.github/workflows/reusable-ci-frontend.yml
132+
tests-frontend:
133+
name: "Tests Frontend"
134+
runs-on: ubuntu-20.04
135+
needs:
136+
- pre-commit
137+
strategy:
138+
matrix:
139+
node-version: [16.x]
140+
steps:
141+
- uses: actions/checkout@v3
142+
-
143+
name: Use Node.js ${{ matrix.node-version }}
144+
uses: actions/setup-node@v3
145+
with:
146+
node-version: ${{ matrix.node-version }}
147+
- run: cd src-ui && npm ci
148+
- run: cd src-ui && npm run test
149+
- run: cd src-ui && npm run e2e:ci
55150

56151
prepare-docker-build:
57152
name: Prepare Docker Pipeline Data
@@ -65,8 +160,8 @@ jobs:
65160
cancel-in-progress: false
66161
needs:
67162
- documentation
68-
- ci-backend
69-
- ci-frontend
163+
- tests-backend
164+
- tests-frontend
70165
steps:
71166
-
72167
name: Set ghcr repository name

.github/workflows/reusable-ci-backend.yml

Lines changed: 0 additions & 129 deletions
This file was deleted.

.github/workflows/reusable-ci-frontend.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

docker/docker-entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ initialize() {
9595
done
9696
set -e
9797

98-
${gosu_cmd[@]} /sbin/docker-prepare.sh
98+
"${gosu_cmd[@]}" /sbin/docker-prepare.sh
9999
}
100100

101101
install_languages() {
@@ -138,7 +138,7 @@ install_languages() {
138138
echo "Paperless-ngx docker container starting..."
139139

140140
gosu_cmd=(gosu paperless)
141-
if [ $(id -u) == $(id -u paperless) ]; then
141+
if [ "$(id -u)" == "$(id -u paperless)" ]; then
142142
gosu_cmd=()
143143
fi
144144

@@ -151,7 +151,7 @@ initialize
151151

152152
if [[ "$1" != "/"* ]]; then
153153
echo Executing management command "$@"
154-
exec ${gosu_cmd[@]} python3 manage.py "$@"
154+
exec "${gosu_cmd[@]}" python3 manage.py "$@"
155155
else
156156
echo Executing "$@"
157157
exec "$@"

docker/paperless_cmd.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
rootless_args=()
4-
if [ $(id -u) == $(id -u paperless) ]; then
4+
if [ "$(id -u)" == "$(id -u paperless)" ]; then
55
rootless_args=(
66
--user
77
paperless
@@ -12,4 +12,4 @@ if [ $(id -u) == $(id -u paperless) ]; then
1212
)
1313
fi
1414

15-
/usr/local/bin/supervisord -c /etc/supervisord.conf ${rootless_args[@]}
15+
/usr/local/bin/supervisord -c /etc/supervisord.conf "${rootless_args[@]}"

src-ui/src/manifest.webmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
"name": "Paperless-ngx",
1616
"short_name": "Paperless-ngx",
1717
"start_url": "/"
18-
}
18+
}

0 commit comments

Comments
 (0)