Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .gitlint

This file was deleted.

40 changes: 23 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
# Pre-commit hook documentation:
# - https://pre-commit.com/
# - https://pre-commit.com/hooks.html
#
# Ruff pre-commit hook documentation:
# - https://github.com/astral-sh/ruff-pre-commit
default_language_version:
python: python3
python: python3
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit, manual]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
exclude: ^.*\.ambr$
- id: end-of-file-fixer
exclude: notification_importers/templates/sms/
- id: check-yaml
- id: check-toml
- id: check-added-large-files
exclude: ^.*\.ambr$
- repo: https://github.com/astral-sh/ruff-pre-commit
# NOTE: Don't move the trailing "ruff-pre-commit version" comment from
# the ruff's version line, it is used by test_pre_commit_ruff_version.py
# test case in order not to have to add a YAML library dependency just
# to test this version:
rev: v0.10.0 # ruff-pre-commit version
rev: v0.12.12 # ruff-pre-commit version
hooks:
# Run the linter
- id: ruff
args: [ --fix ]
# Run the formatter
- id: ruff-format
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.0.0
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.22.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
- id: commitlint
stages: [ commit-msg, manual ]
additional_dependencies: [ "@commitlint/config-conventional" ]
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.11.0
hooks:
- id: gitlint
stages: [commit-msg]
- id: shellcheck
- repo: https://github.com/frnmst/md-toc
rev: 9.0.0
hooks:
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ RUN mkdir /entrypoint
# see .dockerignore for info on what is not copied here:
COPY --chown=root:root --chmod=755 . /app/

RUN yum update -y && yum install -y \
nc \
&& pip install -U pip \
RUN dnf update -y \
&& dnf install -y nmap-ncat \
&& pip install --upgrade pip setuptools wheel \
&& pip install --no-cache-dir -r /app/requirements.txt \
&& pip install --no-cache-dir -r /app/requirements-prod.txt \
&& uwsgi --build-plugin https://github.com/City-of-Helsinki/uwsgi-sentry \
&& yum clean all
&& dnf clean all

COPY --chown=root:root --chmod=755 docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
Expand Down
46 changes: 17 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
- [API Documentation](#api-documentation)
- [Audit logging](#audit-logging)
- [Keeping Python requirements up to date](#keeping-python-requirements-up-to-date)
- [Code linting & formatting](#code-linting--formatting)
- [Pre-commit hooks](#pre-commit-hooks)
- [Contact infomation](#contact-infomation)
- [Code format](#code-format)
- [Commit message format](#commit-message-format)
- [Issues board](#issues-board)
- [Maintaining](#maintaining)
- [Enrolment reports](#enrolment-reports)
Expand Down Expand Up @@ -451,40 +450,29 @@ The GraphQL query/mutation and admin site views can be logged by using the mixin

- `pip-sync requirements.txt`

## Code linting & formatting
## Code format

This project uses [ruff](https://github.com/astral-sh/ruff) for Python code linting and formatting.
Ruff is configured through [pyproject.toml](./pyproject.toml).
Basic `ruff` commands:

- Check linting: `ruff check`
- Check & auto-fix linting: `ruff check --fix`
- Format: `ruff format`

Basically:
- Ruff linter (i.e. `ruff check --fix`) does what `flake8` and `isort` did before.
- Ruff formatter (i.e. `ruff format`) does what `black` did before.
This project uses [Ruff](https://docs.astral.sh/ruff/) for code formatting and quality checking.

Integrations for `ruff` are available for many editors:
- https://docs.astral.sh/ruff/integrations/

## Pre-commit hooks
Basic `ruff` commands:

You can use [`pre-commit`](https://pre-commit.com/) to lint and format your code before committing:
* lint: `ruff check`
* apply safe lint fixes: `ruff check --fix`
* check formatting: `ruff format --check`
* format: `ruff format`

1. Install `pre-commit` (there are many ways to do that, but let's use pip as an example):
- `pip install pre-commit`
2. Set up git hooks from `.pre-commit-config.yaml` by running these commands from project root:
- `pre-commit install` to enable pre-commit code formatting & linting
- `pre-commit install --hook-type commit-msg` to enable pre-commit commit message linting
[`pre-commit`](https://pre-commit.com/) can be used to install and
run all the formatting tools as git hooks automatically before a
commit.

After that, linting and formatting hooks will run against all changed files before committing.
## Commit message format

Git commit message linting is configured in [.gitlint](./.gitlint)
New commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/)
specification, and line length is limited to 72 characters.

## Contact infomation
When [`pre-commit`](https://pre-commit.com/) is in use, [`commitlint`](https://github.com/conventional-changelog/commitlint)
checks new commit messages for the correct format.

@quyenlq @nikomakela

## Issues board

Expand Down
4 changes: 2 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

if [ -z "$SKIP_DATABASE_CHECK" -o "$SKIP_DATABASE_CHECK" = "0" ]; then
if [ -z "$SKIP_DATABASE_CHECK" ] || [ "$SKIP_DATABASE_CHECK" = "0" ]; then
until nc -z -v -w30 "$DATABASE_HOST" 5432
do
echo "Waiting for postgres database connection..."
Expand All @@ -18,7 +18,7 @@ if [[ "$APPLY_MIGRATIONS" = "1" ]]; then
fi

# Start server
if [[ ! -z "$@" ]]; then
if [[ -n "$*" ]]; then
"$@"
elif [[ "$DEV_SERVER" = "1" ]]; then
python ./manage.py runserver 0.0.0.0:8081
Expand Down
Loading