Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e9217ae
deps: replace black, flake8 and isort with ruff in pre-commit
voneiden Sep 24, 2025
40451f4
deps(benefit): replace black, flake8 and isort with ruff
voneiden Sep 24, 2025
c4c4270
ci(benefit): use pre-commit to check code style
voneiden Sep 25, 2025
5b55793
style(benefit): apply ruff format
voneiden Sep 24, 2025
d40780e
refactor(benefit): apply ruff automatic fixes
voneiden Sep 24, 2025
57d5aa1
style(benefit): break long strings with black and reformat with ruff
voneiden Sep 24, 2025
152aa1f
style(benefit): reflow comments
voneiden Sep 24, 2025
039f8f6
style(benefit): add noqa to all E501
voneiden Sep 24, 2025
1a9141d
style(benefit): add noqa to all T201
voneiden Sep 24, 2025
29d6a30
refactor(benefit): manual ruff check fixes
voneiden Sep 24, 2025
f4acbbf
refactor(benefit): docker entrypoint shellcheck fixes
voneiden Sep 25, 2025
c46420b
deps(kesaseteli): replace black, flake8 and isort with ruff
voneiden Sep 25, 2025
06461fb
ci(kesaseteli): use pre-commit to check code style
voneiden Sep 25, 2025
83fbeec
style(kesaseteli): apply ruff format
voneiden Sep 25, 2025
da93ec5
refactor(kesaseteli): docker entrypoint shellcheck fixes
voneiden Sep 25, 2025
b10bebd
refactor(kesaseteli): apply ruff automatic fixes
voneiden Sep 25, 2025
87a9956
style(kesaseteli): split long strings with black
voneiden Sep 26, 2025
e873081
style(kesaseteli): split long comments
voneiden Sep 26, 2025
d1710d6
style(kesaseteli): apply docformatter
voneiden Sep 26, 2025
b0ce2fa
refactor(kesaseteli): ruff manual fixes
voneiden Sep 26, 2025
1ce9fda
chore(shared): configure ruff
voneiden Sep 25, 2025
c850e2d
style(shared): apply ruff format
voneiden Sep 25, 2025
fc66616
refactor(shared): apply ruff automatic fixes
voneiden Sep 25, 2025
6f84683
style(shared): split long strings with black
voneiden Sep 26, 2025
b16a732
style(shared): split long comments
voneiden Sep 26, 2025
9315469
style(shared): apply docformatter
voneiden Sep 26, 2025
839f1ef
refactor(shared): ruff manual fixes
voneiden Sep 26, 2025
45673f5
docs: document and add .git-blame-ignore-revs
voneiden Sep 25, 2025
c41220b
docs(benefit): update documentation on code format
voneiden Sep 26, 2025
58e9b18
deps(benefit): drop ruff and pre-commit from requirements-dev
voneiden Sep 26, 2025
f44f7b5
docs(kesaseteli): update documentation on code format
voneiden Sep 26, 2025
950b225
ci: use ruff-check instead of ruff in .pre-commit-config.yaml
voneiden Sep 30, 2025
36a743c
ci: restore frontend husky pre-commit
voneiden Sep 30, 2025
8713e06
ci: fix wrong name benefit -> kesaseteli
voneiden Sep 30, 2025
b484aca
docs(shared): fix docstring that got mangled by docformatter
voneiden Sep 30, 2025
f291b14
ci(kesaseteli): set order-by-type to false
voneiden Sep 30, 2025
7255990
style(kesaseteli): apply order-by-type = false
voneiden Sep 30, 2025
8bca3b1
chore: update git blame ignore revs
voneiden Sep 30, 2025
d4c97fc
ci: remove prepare husky and commitlint from package.json
voneiden Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 28 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# style(benefit): apply ruff format
5b557933b1a275d60f9ad8a449a93fa7ca37e9fe
# style(benefit): break long strings with black and reformat with ruff
57d5aa102229bdefd4ca845f08afc40f5b57e1c6
# style(benefit): reflow comments
152aa1f10be35e93314edf2ed200f384d400e291
# style(benefit): add noqa to all E501
039f8f60d9e1ada9c0e6fd525ba33abde42565b7
# style(benefit): add noqa to all T201
1a9141dff51f0fd3e35a4477bfa3510b69672c31

# style(kesaseteli): apply ruff format
83fbeeccd762ad1db105d82f030617c70504e740
# style(kesaseteli): split long strings with black
87a9956457afce87acb910ff07cf6313efbd3735
# style(kesaseteli): split long comments
e8730817bd9aa5f97cbf7b2823f9563526520118
# style(kesaseteli): apply docformatter
d1710d68062def0a1c43be362d5948e7ea088249

# style(shared): apply ruff format
c850e2d19f40cabbe43f8cf331e7bf642e3099f6
# style(shared): split long strings with black
6f84683833b9fab8d4e586f88a15a40012aa7fee
# style(shared): split long comments
b16a7329fc75c71353e0cfa5701a39047bd85ddd
# style(shared): apply docformatter
931546951c1adb4c5d3a262c190bd332ae58604f
61 changes: 18 additions & 43 deletions .github/workflows/bf-py-coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,29 @@ on:
pull_request:
paths:
- '.github/workflows/bf-py-coding-style.yml'
- 'backend/benefit/**'
- 'backend/shared/**'
workflow_dispatch:

env:
DEBUG: 1

jobs:
py-coding-style:
name: Python coding style
pre-commit:
name: Run pre-commit hooks
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Cache pip packages
uses: actions/cache@v3
env:
cache-name: cache-pip-modules
with:
path: ~/.pip-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install dependencies
run: cd backend/benefit && pip install -r requirements.txt -r requirements-dev.txt

- name: (BF) Formatting
run: cd backend/benefit && black --check .

- name: (BF) Linting
run: cd backend/benefit && flake8

- name: (BF) Import sorting
run: cd backend/benefit && isort -c .

- name: (Shared) Formatting
run: cd backend/shared && black --check .

- name: (Shared) Linting
run: cd backend/shared && flake8

- name: (Shared) Import sorting
run: cd backend/shared && isort -c .
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Run pre-commit (benefit)
uses: pre-commit/action@v3.0.1
with:
extra_args: --files backend/benefit/**
- name: Run pre-commit (shared)
uses: pre-commit/action@v3.0.1
with:
extra_args: --files backend/shared/**
61 changes: 18 additions & 43 deletions .github/workflows/ks-py-coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,29 @@ on:
pull_request:
paths:
- '.github/workflows/ks-py-coding-style.yml'
- 'backend/kesaseteli/**'
- 'backend/shared/**'
workflow_dispatch:

env:
DEBUG: 1

jobs:
py-coding-style:
name: Python coding style
pre-commit:
name: Run pre-commit hooks
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Cache pip packages
uses: actions/cache@v3
env:
cache-name: cache-pip-modules
with:
path: ~/.pip-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install dependencies
run: cd backend/kesaseteli && pip install -r requirements.txt -r requirements-dev.txt

- name: (KS) Formatting
run: cd backend/kesaseteli && black --check .

- name: (KS) Linting
run: cd backend/kesaseteli && flake8

- name: (KS) Import sorting
run: cd backend/kesaseteli && isort -c .

- name: (Shared) Formatting
run: cd backend/shared && black --check .

- name: (Shared) Linting
run: cd backend/shared && flake8

- name: (Shared) Import sorting
run: cd backend/shared && isort -c .
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Run pre-commit (benefit)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Run pre-commit (benefit)
- name: Run pre-commit (kesaseteli)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 8713e06

uses: pre-commit/action@v3.0.1
with:
extra_args: --files backend/kesaseteli/**
- name: Run pre-commit (shared)
uses: pre-commit/action@v3.0.1
with:
extra_args: --files backend/shared/**
93 changes: 26 additions & 67 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +1,32 @@
fail_fast: true

# Keep tool versions in sync with the versions in requirements-dev.txt
default_language_version:
python: python3

exclude: ^.*\b(migrations)\b.*$
default_stages: [commit, manual]

python: python3
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit, manual]
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: black
name: (BF) black
files: ^backend/benefit
- id: black
name: (KS) black
files: ^backend/kesaseteli
- id: black
name: (Shared) black
files: ^backend/shared
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.1
hooks:
- id: isort
name: (BF) isort
args: [--settings-file, backend/benefit/setup.cfg]
files: ^backend/benefit
- id: isort
name: (KS) isort
args: [--settings-file, backend/kesaseteli/setup.cfg]
files: ^backend/kesaseteli
- id: isort
name: (Shared) isort
args: [--settings-file, backend/shared/setup.cfg]
files: ^backend/shared
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
# Run the linter.
- id: ruff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruff id has become legacy and is replaced with ruff-check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- id: ruff
- id: ruff-check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 950b225

args: [ "--fix" ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.22.0
hooks:
- id: flake8
name: (BF) flake8
additional_dependencies: [flake8-isort, flake8-black]
exclude: migrations|snapshots
files: ^backend/benefit
args: [--config, backend/benefit/setup.cfg]
- id: flake8
name: (KS) flake8
additional_dependencies: [flake8-isort, flake8-black]
exclude: migrations|snapshots
files: ^backend/kesaseteli
args: [--config, backend/kesaseteli/setup.cfg]
- id: flake8
name: (Shared) flake8
additional_dependencies: [flake8-isort, flake8-black]
exclude: migrations|snapshots
files: ^backend/shared
args: [--config, backend/shared/setup.cfg]
- repo: local
- id: commitlint
stages: [commit-msg, manual]
additional_dependencies: ["@commitlint/config-conventional"]
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: lint-staged
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "frontend lerna linter" is removed by accident ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 36a743c and d4c97fc

name: (Frontend) Run lint-staged with lerna
entry: "./.husky/pre-commit"
language: system
types: [file]
require_serial: true
- repo: local
hooks:
- id: commit-msg
name: Validate commit message (conventional commits)
entry: "./.husky/commit-msg"
language: system
stages:
- commit-msg
- id: shellcheck
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This monorepo contains code for three different employment services:
* Handler

* **TET Job Search** - retired and can be found in [here](https://github.com/City-of-Helsinki/yjdh/tree/ab8b87d5466badb37dccb968830ddbb2a51ec170)
* Backend
* Backend
* Youth
* Admin

Expand Down Expand Up @@ -59,7 +59,7 @@ More information in [Confluence](https://helsinkisolutionoffice.atlassian.net/wi
3. Make additional changes & commit, e.g. `git commit -m "feat: new feature frontend"`
4. Open a pull request, for example with title `HL-123: New feature`
5. After PR checks are passed and PR is approved, merge with squash merge (set commit message to e.g. `feat: new feature`) or rebase and merge
6. Release Please opens release PR with a title similar to this: `chore(main): release benefit-backend 1.1.1`
6. Release Please opens release PR with a title similar to this: `chore(main): release benefit-backend 1.1.1`
7. Merge release pull request to `main`. This creates a versioned release tag (e.g. `benefit-backend: v1.1.1`) that triggers staging and production deploy (Deploys still must be approved from Azure DevOps).

## Setting up git hooks
Expand Down Expand Up @@ -141,12 +141,24 @@ YJDH-Benefit provides two services for applying and for handling the application
1. If github action deploy fail with error like this in your pull-request:

```text
Error: rendered manifests contain a resource that already exists.
Unable to continue with install: Service "yjdh-135-send-localization-param-to-suomifi-yjdh-ks-service"
in namespace "yjdh-yjdh-135-send-localization-param-to-suomifi-227" exists and cannot be
imported into the current release: invalid ownership metadata; annotation validation error:
key "meta.helm.sh/release-name" must equal "yjdh-135-send-localization-par-review-yjdh-ks-bknd":
Error: rendered manifests contain a resource that already exists.
Unable to continue with install: Service "yjdh-135-send-localization-param-to-suomifi-yjdh-ks-service"
in namespace "yjdh-yjdh-135-send-localization-param-to-suomifi-227" exists and cannot be
imported into the current release: invalid ownership metadata; annotation validation error:
key "meta.helm.sh/release-name" must equal "yjdh-135-send-localization-par-review-yjdh-ks-bknd":
current value is "yjdh-135-send-localization-par-review-yjdh-ks-empl"
```

The reason for this is that your pr's branch name is too long. You have to rename it and create a new pr. See instructions at [StackOverflow](https://stackoverflow.com/questions/30590083/how-do-i-rename-both-a-git-local-and-remote-branch-name).


### Git blame ignore refs

Project includes a `.git-blame-ignore-revs` file for ignoring certain commits from `git blame`.
This can be useful for ignoring e.g. formatting commits, so that it is more clear from `git blame`
where the actual code change came from. Configure your git to use it for this project with the
following command:

```shell
git config blame.ignoreRevsFile .git-blame-ignore-revs
```
19 changes: 10 additions & 9 deletions backend/benefit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,18 @@ Currently configured jobs (registered in the `applications/jobs`-directory):

## Code format

This project uses
[`black`](https://github.com/psf/black),
[`flake8`](https://gitlab.com/pycqa/flake8) and
[`isort`](https://github.com/PyCQA/isort)
for code formatting and quality checking. Project follows the basic
black config, without any modifications.
This project uses [](https://docs.astral.sh/ruff/) for code formatting and quality checking.

Basic `ruff` commands:

Basic `black` commands:
* lint: `ruff check`
* apply safe lint fixes: `ruff check --fix`
* check formatting: `ruff format --check`
* format: `ruff format`

- To let `black` do its magic: `black .`
- To see which files `black` would change: `black --check .`
[`pre-commit`](https://pre-commit.com/) can be used to install and
run all the formatting tools as git hooks automatically before a
commit.

## Storages

Expand Down
Loading
Loading