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
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
repos:
# Black - Python code formatter
- repo: https://github.com/psf/black
rev: &black-version 25.1.0
hooks:
- id: black
language_version: python3.12
files: '\.py$'
exclude: '^(data/|obsolete/|src/ssvc/utils/namespace_patterns\.py)'

# Markdownlint - Markdown linting with auto-fix
- repo: local
hooks:
- id: markdownlint-fix
name: markdownlint
entry: markdownlint --config .markdownlint.yml --fix
language: system
files: '\.md$'
exclude: '^(data/|obsolete/)'

# Custom hook: doctools.py - Regenerate JSON from Python decision tables
- repo: local
hooks:
- id: doctools-regenerate
name: doctools regenerate
entry: bash -c 'PYTHONPATH=src:$PYTHONPATH uv run python src/ssvc/doctools.py --datadir=./data --overwrite'
language: system
files: '^src/ssvc/.*\.py$'
exclude: '^(src/ssvc/api/|src/ssvc/test/)'
pass_filenames: false

# Custom hook: pytest - Run tests (non-blocking)
- repo: local
hooks:
- id: pytest-check
name: pytest
entry: uv run pytest --tb=short -q
language: system
files: '\.py$'
pass_filenames: false
fail_fast: false
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,51 @@ To account for different stakeholder perspectives, we benefit from a diverse gro
Please see our project documentation in the [wiki](https://github.com/CERTCC/SSVC/wiki) that accompanies this repository
for more information on how you can contribute to the project.

## Development Setup

### Prerequisites

- Python 3.12+
- [uv](https://docs.astral.sh/uv/) - Fast Python package installer and resolver
- [pre-commit](https://pre-commit.com/) - Git hooks framework

### Installing Dependencies and Git Hooks

1. **Set up the development environment:**

```bash
make dev
```

2. **Install pre-commit hooks:**

```bash
uv run pre-commit install
```

### Pre-Commit Hooks

This repository uses [pre-commit](https://pre-commit.com/) to enforce code quality standards before commits. The following hooks are configured:

| Hook | Scope | Behavior |
|------|-------|----------|
| **Black** | Python files | Auto-formats code; blocks commit if changes made |
| **Markdownlint** | Markdown files | Auto-fixes linting issues; blocks commit if changes made |
| **Doctools** | Decision point/table Python files | Regenerates JSON files; blocks commit if changes made (review before staging) |
| **Pytest** | All tests | Runs full test suite; non-blocking (warning only) |

**Running hooks manually:**

```bash
uv run pre-commit run --all-files
```

**Skipping hooks (use sparingly):**

```bash
git commit --no-verify
```

## Licenses

See [LICENSE](https://github.com/CERTCC/SSVC/blob/main/LICENSE)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies = [
"pydantic>=2.11.7",
"semver>=3.0.4",
"fastapi[all,standard]>=0.116.1",
"pre-commit>=4.6.0",
]
dynamic = ["version",]

Expand Down
91 changes: 91 additions & 0 deletions uv.lock

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

Loading