Skip to content

Commit

Permalink
Merge pull request #30 from unicef/feature/ruff
Browse files Browse the repository at this point in the history
Feature/ruff
  • Loading branch information
saxix authored Dec 23, 2024
2 parents 1054d5d + 79d3026 commit b3f63b3
Show file tree
Hide file tree
Showing 289 changed files with 583 additions and 1,142 deletions.
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Legal Boilerplate

Look, I get it.
Contributing to HOPE Workspace, I retain all rights, title and interest in and to my contributions, and by keeping
this boilerplate intact I confirm that HOPE Workspace can use, modify, copy, and redistribute my contributions,
Look, I get it.
Contributing to HOPE Workspace, I retain all rights, title and interest in and to my contributions, and by keeping
this boilerplate intact I confirm that HOPE Workspace can use, modify, copy, and redistribute my contributions,
under HOPE's choice of terms.
8 changes: 4 additions & 4 deletions .github/actions/docker_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ runs:
run: |
build_date=$(date +"%Y-%m-%d %H:%M")
echo "BUILD_DATE=$build_date" >> $GITHUB_ENV
if [[ "${{inputs.target}}" == "dist" ]]; then
echo "TAG_PREFIX=" >> $GITHUB_ENV
else
Expand Down Expand Up @@ -114,7 +114,7 @@ runs:
- name: "Check Image"
id: image_status
shell: bash
run: |
run: |
set +e
echo "::notice::ℹ Checking checksum for ${{ steps.image_name.outputs.name }}"
image_checksum=$(regctl image inspect \
Expand All @@ -134,7 +134,7 @@ runs:
echo "::warning::🤬 Checksum: found '${image_checksum}' expected '${code_checksum}'"
echo "updated=false" >> $GITHUB_OUTPUT
fi
if [[ "${{inputs.rebuild}}" == "true" ]]; then
if [[ "${{inputs.rebuild}}" == "true" ]]; then
echo "::warning::⚠ Forced build due input parameter"
fi
- name: Set up Docker BuildX
Expand Down Expand Up @@ -188,7 +188,7 @@ runs:
if: (steps.image_status.outputs.updated != 'true' || inputs.rebuild == 'true') && inputs.dryrun != 'true'
shell: bash
run: |
echo "${{ toJSON(steps.build_push.outputs) }}"
echo "${{ toJSON(steps.build_push.outputs) }}"
regctl image inspect -p linux/amd64 ${{ steps.image_name.outputs.name }}
echo "::notice:: Image ${{ steps.meta.outputs.tags }} successfully built and pushed"
echo "created=true" >> $GITHUB_OUTPUT
16 changes: 8 additions & 8 deletions .github/actions/last_commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ outputs:
runs:
using: "composite"
steps:
- name: Setup Environment (PR)
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
- name: Setup Environment (PR)
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo "LAST_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Setup Environment (Push)
if: ${{ github.event_name == 'push' }}
- name: Setup Environment (Push)
if: ${{ github.event_name == 'push' }}
shell: bash
run: |
run: |
echo "LAST_COMMIT_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
- id: result
shell: bash
run: |
raw=${{env.LAST_COMMIT_SHA}}
raw=${{env.LAST_COMMIT_SHA}}
echo "last_commit_sha=$raw" >> $GITHUB_OUTPUT
echo "last_commit_short_sha=${raw::8}" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
version: 2
updates:
- package-ecosystem: "pip"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
Expand Down
35 changes: 4 additions & 31 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
base: ${{ github.ref }}
token: ${{ github.token }}
filters: .github/file-filters.yml

flake8:
ruff:
needs: changes
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false && needs.changes.outputs.lint
Expand All @@ -56,36 +55,10 @@ jobs:
with:
python-version: '3.12'
- name: Install requirements
run: pip install flake8 pycodestyle
run: pip install ruff
- name: Check syntax
# Stop the build if there are Python syntax errors or undefined names
run: flake8 src/ --count --statistics --max-line-length=127
run: ruff check src/

- name: Warnings
run: flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --extend-exclude=""
isort:
needs: changes
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false && needs.changes.outputs.lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install requirements
run: pip install isort
- name: iSort
run: isort src/ --check-only
black:
needs: changes
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false && needs.changes.outputs.lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install requirements
run: pip install black
- name: Black
run: black src/ --check
run: ruff format --check
77 changes: 0 additions & 77 deletions .github/workflows/security.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
# django-admin upgrade

- name: Publish images
run: |
run: |
docker push ${{needs.test.outputs.image}}
docker inspect ${{needs.test.outputs.image}} | jq -r '.[0].Config.Labels'
echo "::notice::✅ Image ${{needs.test.outputs.image}} built and pushed"
39 changes: 12 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/adamchainz/djade-pre-commit
rev: "1.3.2"
hooks:
Expand All @@ -10,28 +15,17 @@ repos:
hooks:
- id: isort
stages: [pre-commit]
- repo: https://github.com/ambv/black
rev: 24.10.0
hooks:
- id: black
args: [--config=pyproject.toml]
exclude: "migrations|snapshots"
stages: [pre-commit]
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
args: [--config=.flake8]
stages: [ pre-commit ]
- repo: https://github.com/PyCQA/bandit
rev: '1.7.10' # Update me!
hooks:
- id: bandit
args: ["-c", "bandit.yaml"]
- repo: https://github.com/twisted/towncrier
rev: 24.8.0
hooks:
- id: towncrier-check
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
- id: ruff-format
args:
- --check

- repo: https://github.com/saxix/pch
rev: '0.1'
Expand All @@ -47,12 +41,3 @@ repos:
- src
- tests
stages: [ pre-push ]

- id: check-forbidden
args:
- -p
- /\.showbrowser\(/
- -p
- /print\(111/
stages: [ pre-commit ]
additional_dependencies: [ setuptools ]
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ RUN --mount=type=cache,target=/root/.uv-cache \

# ------- production only deps-------
FROM builder AS production
ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \
ENV PATH=/venv/bin:/usr/local/bin/:/usr/bin:/bin \
DJANGO_SETTINGS_MODULE=country_workspace.config.settings \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
Expand Down Expand Up @@ -147,7 +147,7 @@ COPY . /app/
COPY --chown=hope:unicef --from=production /venv /venv
COPY --from=builder /usr/local/bin/uwsgi /usr/local/bin/uv /usr/local/bin/
RUN --mount=type=cache,target=/root/.uv-cache \
uv --cache-dir=/root/.uv-cache pip install --link-mode=copy --no-deps . \
uv --cache-dir=/root/.uv-cache pip install --no-deps . \
&& rm -fr /app


Expand Down
2 changes: 1 addition & 1 deletion docs/_theme/css/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Install [uv](https://docs.astral.sh/uv/)
wget https://github.com/sqreen/PyMiniRacer/files/7575004/libmini_racer.dylib.zip

1. Unzip The Dylib file

unzip libmini_racer.dylib.zip

1. MV Dylib file to your site-packages

mv libmini_racer.dylib /opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/py_mini_racer/.

1. Import Success.

>>> from py_mini_racer import MiniRacer


Expand All @@ -42,11 +42,11 @@ CSS. CSS sources are located in the `country_workspace/workspaces/theme/static_s
If you need to edit the CSS follow the below steps:

1. Install node dependencies

./manage.py tailwind install

1. Configure the enviroment

export EXTRA_APPS="country_workspace.contrib.hope,django_browser_reload"
export EXTRA_MIDDLEWARES="django_browser_reload.middleware.BrowserReloadMiddleware,"

Expand Down
2 changes: 1 addition & 1 deletion docs/src/dev_helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
show_bases: false
show_bases: false
show_root_heading: true
show_source: true
show_source: true
2 changes: 1 addition & 1 deletion docs/src/flows/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Spreadsheet import


```mermaid
```mermaid
graph TD
A[Upload file] --> B{All records are valid?}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/flows/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ erDiagram
Spreadsheet {
string title
}
Error {
string sheet
int row
string column
}
Program ||--o{ Spreadsheet: has
Program ||--o{ Individual: has
Program ||--o{ Household: has
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ docs = [
[tool.uv]
package = true
dev-dependencies = [
"black>=24.4.2",
"bump2version>=1.0.1",
"djade>=1.3.2",
"django-browser-reload>=1.17.0",
"django-webtest>=1.9.11",
"factory-boy>=3.3.0",
"flake8>=7.1.0",
"freezegun>=1.5.1",
"ipython>=8.29.0",
"isort>=5.13.2",
"mypy>=1.11.2",
"pdbpp>=0.10.3",
"pip>=24.3.1",
Expand Down
Loading

0 comments on commit b3f63b3

Please sign in to comment.