Skip to content

Commit b3f63b3

Browse files
authored
Merge pull request #30 from unicef/feature/ruff
Feature/ruff
2 parents 1054d5d + 79d3026 commit b3f63b3

File tree

289 files changed

+583
-1142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+583
-1142
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Legal Boilerplate
22

3-
Look, I get it.
4-
Contributing to HOPE Workspace, I retain all rights, title and interest in and to my contributions, and by keeping
5-
this boilerplate intact I confirm that HOPE Workspace can use, modify, copy, and redistribute my contributions,
3+
Look, I get it.
4+
Contributing to HOPE Workspace, I retain all rights, title and interest in and to my contributions, and by keeping
5+
this boilerplate intact I confirm that HOPE Workspace can use, modify, copy, and redistribute my contributions,
66
under HOPE's choice of terms.

.github/actions/docker_build/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ runs:
8484
run: |
8585
build_date=$(date +"%Y-%m-%d %H:%M")
8686
echo "BUILD_DATE=$build_date" >> $GITHUB_ENV
87-
87+
8888
if [[ "${{inputs.target}}" == "dist" ]]; then
8989
echo "TAG_PREFIX=" >> $GITHUB_ENV
9090
else
@@ -114,7 +114,7 @@ runs:
114114
- name: "Check Image"
115115
id: image_status
116116
shell: bash
117-
run: |
117+
run: |
118118
set +e
119119
echo "::notice::ℹ Checking checksum for ${{ steps.image_name.outputs.name }}"
120120
image_checksum=$(regctl image inspect \
@@ -134,7 +134,7 @@ runs:
134134
echo "::warning::🤬 Checksum: found '${image_checksum}' expected '${code_checksum}'"
135135
echo "updated=false" >> $GITHUB_OUTPUT
136136
fi
137-
if [[ "${{inputs.rebuild}}" == "true" ]]; then
137+
if [[ "${{inputs.rebuild}}" == "true" ]]; then
138138
echo "::warning::⚠ Forced build due input parameter"
139139
fi
140140
- name: Set up Docker BuildX
@@ -188,7 +188,7 @@ runs:
188188
if: (steps.image_status.outputs.updated != 'true' || inputs.rebuild == 'true') && inputs.dryrun != 'true'
189189
shell: bash
190190
run: |
191-
echo "${{ toJSON(steps.build_push.outputs) }}"
191+
echo "${{ toJSON(steps.build_push.outputs) }}"
192192
regctl image inspect -p linux/amd64 ${{ steps.image_name.outputs.name }}
193193
echo "::notice:: Image ${{ steps.meta.outputs.tags }} successfully built and pushed"
194194
echo "created=true" >> $GITHUB_OUTPUT

.github/actions/last_commit/action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ outputs:
1313
runs:
1414
using: "composite"
1515
steps:
16-
- name: Setup Environment (PR)
17-
if: ${{ github.event_name == 'pull_request' }}
18-
shell: bash
19-
run: |
16+
- name: Setup Environment (PR)
17+
if: ${{ github.event_name == 'pull_request' }}
18+
shell: bash
19+
run: |
2020
echo "LAST_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
21-
- name: Setup Environment (Push)
22-
if: ${{ github.event_name == 'push' }}
21+
- name: Setup Environment (Push)
22+
if: ${{ github.event_name == 'push' }}
2323
shell: bash
24-
run: |
24+
run: |
2525
echo "LAST_COMMIT_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
2626
- id: result
2727
shell: bash
2828
run: |
29-
raw=${{env.LAST_COMMIT_SHA}}
29+
raw=${{env.LAST_COMMIT_SHA}}
3030
echo "last_commit_sha=$raw" >> $GITHUB_OUTPUT
3131
echo "last_commit_short_sha=${raw::8}" >> $GITHUB_OUTPUT

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
The property '#/updates/0/package-ecosystem' value "" did not match one of the following values: npm, bundler, composer, devcontainers, maven, mix, cargo, gradle, nuget, gomod, docker, elm, gitsubmodule, github-actions, pip, terraform, pub, swift
66
version: 2
77
updates:
8-
- package-ecosystem: "pip"
8+
- package-ecosystem: "pip"
99
directory: "/"
1010
schedule:
1111
interval: "weekly"

.github/workflows/lint.yml

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ jobs:
4545
base: ${{ github.ref }}
4646
token: ${{ github.token }}
4747
filters: .github/file-filters.yml
48-
49-
flake8:
48+
ruff:
5049
needs: changes
5150
runs-on: ubuntu-latest
5251
if: github.event.pull_request.draft == false && needs.changes.outputs.lint
@@ -56,36 +55,10 @@ jobs:
5655
with:
5756
python-version: '3.12'
5857
- name: Install requirements
59-
run: pip install flake8 pycodestyle
58+
run: pip install ruff
6059
- name: Check syntax
6160
# Stop the build if there are Python syntax errors or undefined names
62-
run: flake8 src/ --count --statistics --max-line-length=127
61+
run: ruff check src/
6362

6463
- name: Warnings
65-
run: flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --extend-exclude=""
66-
isort:
67-
needs: changes
68-
runs-on: ubuntu-latest
69-
if: github.event.pull_request.draft == false && needs.changes.outputs.lint
70-
steps:
71-
- uses: actions/checkout@v4
72-
- uses: actions/setup-python@v5
73-
with:
74-
python-version: '3.12'
75-
- name: Install requirements
76-
run: pip install isort
77-
- name: iSort
78-
run: isort src/ --check-only
79-
black:
80-
needs: changes
81-
runs-on: ubuntu-latest
82-
if: github.event.pull_request.draft == false && needs.changes.outputs.lint
83-
steps:
84-
- uses: actions/checkout@v4
85-
- uses: actions/setup-python@v5
86-
with:
87-
python-version: '3.12'
88-
- name: Install requirements
89-
run: pip install black
90-
- name: Black
91-
run: black src/ --check
64+
run: ruff format --check

.github/workflows/security.yml

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

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ jobs:
229229
# django-admin upgrade
230230

231231
- name: Publish images
232-
run: |
232+
run: |
233233
docker push ${{needs.test.outputs.image}}
234234
docker inspect ${{needs.test.outputs.image}} | jq -r '.[0].Config.Labels'
235235
echo "::notice::✅ Image ${{needs.test.outputs.image}} built and pushed"

.pre-commit-config.yaml

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
27
- repo: https://github.com/adamchainz/djade-pre-commit
38
rev: "1.3.2"
49
hooks:
@@ -10,28 +15,17 @@ repos:
1015
hooks:
1116
- id: isort
1217
stages: [pre-commit]
13-
- repo: https://github.com/ambv/black
14-
rev: 24.10.0
15-
hooks:
16-
- id: black
17-
args: [--config=pyproject.toml]
18-
exclude: "migrations|snapshots"
19-
stages: [pre-commit]
20-
- repo: https://github.com/PyCQA/flake8
21-
rev: 7.1.1
22-
hooks:
23-
- id: flake8
24-
args: [--config=.flake8]
25-
stages: [ pre-commit ]
26-
- repo: https://github.com/PyCQA/bandit
27-
rev: '1.7.10' # Update me!
28-
hooks:
29-
- id: bandit
30-
args: ["-c", "bandit.yaml"]
3118
- repo: https://github.com/twisted/towncrier
3219
rev: 24.8.0
3320
hooks:
3421
- id: towncrier-check
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: v0.8.4
24+
hooks:
25+
- id: ruff
26+
- id: ruff-format
27+
args:
28+
- --check
3529

3630
- repo: https://github.com/saxix/pch
3731
rev: '0.1'
@@ -47,12 +41,3 @@ repos:
4741
- src
4842
- tests
4943
stages: [ pre-push ]
50-
51-
- id: check-forbidden
52-
args:
53-
- -p
54-
- /\.showbrowser\(/
55-
- -p
56-
- /print\(111/
57-
stages: [ pre-commit ]
58-
additional_dependencies: [ setuptools ]

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ RUN --mount=type=cache,target=/root/.uv-cache \
9292

9393
# ------- production only deps-------
9494
FROM builder AS production
95-
ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \
95+
ENV PATH=/venv/bin:/usr/local/bin/:/usr/bin:/bin \
9696
DJANGO_SETTINGS_MODULE=country_workspace.config.settings \
9797
PYTHONUNBUFFERED=1 \
9898
PYTHONDONTWRITEBYTECODE=1 \
@@ -147,7 +147,7 @@ COPY . /app/
147147
COPY --chown=hope:unicef --from=production /venv /venv
148148
COPY --from=builder /usr/local/bin/uwsgi /usr/local/bin/uv /usr/local/bin/
149149
RUN --mount=type=cache,target=/root/.uv-cache \
150-
uv --cache-dir=/root/.uv-cache pip install --link-mode=copy --no-deps . \
150+
uv --cache-dir=/root/.uv-cache pip install --no-deps . \
151151
&& rm -fr /app
152152

153153

docs/_theme/css/style.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)