Skip to content

Add quality checks and pre-commit & editor configs #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 18, 2025
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
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Check http://editorconfig.org for more information
# This is the main config file for this project:
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.py]
indent_style = space
indent_size = 4

[*.py.jinja]
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false
24 changes: 23 additions & 1 deletion .github/workflows/check-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@ on:
types: trigger-run-check-dependencies

jobs:
quality-checks:

Choose a reason for hiding this comment

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

I think it's better to merge editor config and lint rules first. Then clean up the code and finally enable quality check as merge gate.

Enabling it first would cause huge PR with all lint fixes.

Copy link
Member Author

@dalito dalito Jul 18, 2025

Choose a reason for hiding this comment

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

The current linkml config which I copied here is not yet very strict. The checks of this PR already ran with the action code from this PR (inspect the Workflow file for quality-checks in https://github.com/linkml/linkml-runtime/actions/runs/16326610375/workflow?pr=406). There should be no surprises after merge (I hope 😉).

runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install Poetry
run: |
pipx install poetry
pipx inject poetry poetry-dynamic-versioning
- uses: actions/[email protected]
with:
python-version: 3.13
- name: Check pyproject.toml and poetry.lock
run: poetry check
- name: Install tox
run: python -m pip install tox
- name: Run codespell
run: tox -e codespell
- name: Run code quality checks
run: tox -e lint

test:
needs:
- quality-checks
strategy:
fail-fast: false
matrix:
Expand All @@ -35,7 +57,7 @@ jobs:
with:
# Fetch all history for all branches and all tags.
# The tags are required for dynamic versioning.
fetch-depth: 0
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
Expand Down
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
default_language_version:
python: python3
# Specify files to exclude - pre-commit hook doesn't parse pyproject.toml
exclude: tests/data/hp.ttl|tests/data/hp_f.ttl|.*\.svg|jsonschema_value_constraints.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
exclude: __snapshots__
- id: check-yaml
exclude: (__snapshots__|test_utils/input)
- id: check-toml
- id: trailing-whitespace
# TODO: This is temporary while bioliank is being fixed upstream.
# TODO: Should look at snapshot exclusion to find upstream problems
exclude: (__snapshots__|biolink-model.yaml)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ensure this version stays in sync with tox.ini
rev: v0.11.13
hooks:
# Run the linter.
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli
Loading