Skip to content
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

feat: add justfile, update pre-commit and github actions configs accordingly #10

Merged
merged 8 commits into from
Jan 24, 2024
11 changes: 7 additions & 4 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@ jobs:
- name: Install project
run: poetry install --no-interaction

- name: Setup just
uses: taiki-e/install-action@just

- name: Enforce code style (Ruff)
run: poetry run ruff check --show-source --show-fixes .
run: just ruff-show-violations

- name: Verify code formatting (Black)
run: poetry run black --check --diff .
run: just black-check

- name: Run tests
run: poetry run pytest --verbose
run: just test

- name: Generate test coverage report
run: poetry run pytest --cov=./ --cov-report=xml
run: just test-and-report-cov

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ repos:
hooks:
- id: ruff
name: ruff (linter)
entry: poetry run ruff check .
entry: just ruff
language: system
types: [python]
args: [--fix]
- id: black
name: black
entry: poetry run black .
entry: just black
language: system
types: [python]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Personal attempt to solve the `advent-of-code`[^aoc] puzzles in a `TDD` fashion
### ⚠️ TODO:
- Repo setup:
- 🚧 ~~try out `ruff` as a linter, thus replacing `flake8`~~
- 🚧 ~~`makefile` | `justfile`~~
- 🚧 rely on a unique configuration file (possibly `pyproject.toml`)
- 🚧 add `mypy` (`--strict`?) in the pipeline
- 🚧 `makefile` | `justfile`
- 🚧 try out `ruff` as a formatter, thus replacing `black`?
- 🚧 Dockerization?
- 🚧 else?
Expand Down
49 changes: 49 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Use PowerShell instead of sh
# set shell := ["powershell.exe", "-c"]

help:
@just --list

install:
@echo "🚀 Installing dependencies"
@poetry install --with dev

install-pre-commit:
@echo "🚀 Setting up the hooks"
@poetry run pre-commit install

check-project:
@echo "🚀 Checking consistency between poetry.lock and pyproject.toml"
@poetry check --lock
@echo "🚀 Running the hooks against all files"
@poetry run pre-commit run --all-files

ruff:
@echo "🚀 Linting the project with Ruff"
@poetry run ruff check src tests

ruff-show-violations:
@echo "🚀 Linting the project with Ruff and show violations"
@poetry run ruff check --show-source --show-fixes src tests

ruff-fix:
@echo "🚀 Linting the project with Ruff and autofix violations (where possible)"
@poetry run ruff check --fix src tests

black:
@echo "🚀 Formatting the code with Black"
@poetry run black src tests

black-check:
@echo "🚀 Checking formatting advices from Black"
@poetry run black --check --diff src tests

lint-and-format: ruff black

test:
@echo "🚀 Testing code with pytest"
@poetry run pytest --verbose tests

test-and-report-cov:
@echo "🚀 Testing code with pytest and generating coverage report"
@poetry run pytest --cov=./ --cov-report=xml
Loading