Skip to content

Commit

Permalink
Merge pull request #10 from AlessandroMiola/add_justfile
Browse files Browse the repository at this point in the history
feat: add justfile, update pre-commit and github actions configs accordingly
  • Loading branch information
AlessandroMiola authored Jan 24, 2024
2 parents 6874112 + e4bf404 commit 13f73fe
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
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

0 comments on commit 13f73fe

Please sign in to comment.