Skip to content

Commit

Permalink
Configure project setup (#2)
Browse files Browse the repository at this point in the history
Configure project setup:

- Add the project's metadata
- Set dev dependencies
- Configure linters, pre-commit, tests, ci workflow
  • Loading branch information
druzhinin-kirill authored Feb 29, 2024
1 parent fbe21e1 commit cba523e
Show file tree
Hide file tree
Showing 12 changed files with 2,095 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: dbt-score

on:
pull_request:
branches:
- master
paths-ignore:
- "docs/**"

push:
branches:
- master
paths-ignore:
- "docs/**"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
pdm sync -d
- name: Run Prettier
uses: creyD/[email protected]
with:
dry: True
prettier_options: "--check **/*.{json,yaml,yml,md}"
- name: Run Tox
run: |
pdm run tox -e py,lint
97 changes: 97 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# PyCharm
.idea

# VisualStudioCode
.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# PyBuilder
.pybuilder/
target/

# pdm
.pdm.toml
.pdm-python
.pdm-build/

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# ruff
.ruff_cache/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix]
description: Run linter with fixes enabled
- id: ruff-format
description: Run formatter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
description: Run prettier
types_or: [yaml, json, markdown]
- repo: local
hooks:
- id: tox_lint
name: lint
description: Run lint
entry: pdm run tox -e lint
language: system
pass_filenames: false
- id: tox_test
name: test
description: Run test
entry: pdm run tox -e py
language: system
pass_filenames: false
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,87 @@
# dbt-score

Linter for dbt model metadata.

## Development

### Prerequisites

You'll need the following prerequisites:

- Any Python version starting from 3.10
- [pre-commit](https://pre-commit.com/)
- [PDM](https://pdm-project.org/2.12/)

Configure development environment running these commands from the project's root:

```shell
pre-commit install
pdm install --group :all
```

The pdm command will install all project's dependency groups, including all the dependencies needed for development
purposes.

### Lint

`dbt_score` uses:

- [ruff](https://docs.astral.sh/ruff/) for fast linting and formatting.
- [mypy](https://mypy.readthedocs.io/en/stable/) for type checking.
- [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks).
- [prettier-hooks](https://github.com/pre-commit/mirrors-prettier).

Cheatsheet:

```shell
pdm run ruff check .
pdm run ruff check --fix
pdm run mypy .
pdm run tox -e lint
```

### Test

`dbt_score` uses:

- [pytest](https://docs.pytest.org/) as a main test framework.
- [coverage](https://coverage.readthedocs.io/en/latest/index.html) for test coverage.
- [tox](https://tox.wiki/en/latest/) for testing against multiple Python versions.

Cheatsheet:

```shell
pdm run tox -e py
pdm run pytest
pdm run coverage run -m pytest
```

### Docs

`dbt_score` uses:

- [mkdocs](https://www.mkdocs.org/) for docs generation.
- [mkdocstrings](https://mkdocstrings.github.io/) for automatic docs from sources.

Cheatsheet:

```shell
pdm run mkdocs build
pdm run mkdocs serve
```

### Pre-commit

Cheatsheet:

Execute hooks manually:

```shell
pre-commit run --all-files
```

Create a commit bypassing hooks:

```shell
git commit --no-verify
```
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Welcome to dbt-score
8 changes: 8 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
site_name: dbt-score
theme:
name: material
plugins:
- search
- mkdocstrings
nav:
- Home: index.md
Loading

0 comments on commit cba523e

Please sign in to comment.