Skip to content

Commit 13f73fe

Browse files
Merge pull request #10 from AlessandroMiola/add_justfile
feat: add justfile, update pre-commit and github actions configs accordingly
2 parents 6874112 + e4bf404 commit 13f73fe

File tree

4 files changed

+59
-7
lines changed

4 files changed

+59
-7
lines changed

β€Ž.github/workflows/actions.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,20 @@ jobs:
5151
- name: Install project
5252
run: poetry install --no-interaction
5353

54+
- name: Setup just
55+
uses: taiki-e/install-action@just
56+
5457
- name: Enforce code style (Ruff)
55-
run: poetry run ruff check --show-source --show-fixes .
58+
run: just ruff-show-violations
5659

5760
- name: Verify code formatting (Black)
58-
run: poetry run black --check --diff .
61+
run: just black-check
5962

6063
- name: Run tests
61-
run: poetry run pytest --verbose
64+
run: just test
6265

6366
- name: Generate test coverage report
64-
run: poetry run pytest --cov=./ --cov-report=xml
67+
run: just test-and-report-cov
6568

6669
- name: Upload coverage reports to Codecov
6770
uses: codecov/codecov-action@v3

β€Ž.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ repos:
1313
hooks:
1414
- id: ruff
1515
name: ruff (linter)
16-
entry: poetry run ruff check .
16+
entry: just ruff
1717
language: system
1818
types: [python]
1919
args: [--fix]
2020
- id: black
2121
name: black
22-
entry: poetry run black .
22+
entry: just black
2323
language: system
2424
types: [python]

β€ŽREADME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Personal attempt to solve the `advent-of-code`[^aoc] puzzles in a `TDD` fashion
1616
### ⚠️ TODO:
1717
- Repo setup:
1818
- 🚧 ~~try out `ruff` as a linter, thus replacing `flake8`~~
19+
- 🚧 ~~`makefile` | `justfile`~~
1920
- 🚧 rely on a unique configuration file (possibly `pyproject.toml`)
2021
- 🚧 add `mypy` (`--strict`?) in the pipeline
21-
- 🚧 `makefile` | `justfile`
2222
- 🚧 try out `ruff` as a formatter, thus replacing `black`?
2323
- 🚧 Dockerization?
2424
- 🚧 else?

β€Žjustfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Use PowerShell instead of sh
2+
# set shell := ["powershell.exe", "-c"]
3+
4+
help:
5+
@just --list
6+
7+
install:
8+
@echo "πŸš€ Installing dependencies"
9+
@poetry install --with dev
10+
11+
install-pre-commit:
12+
@echo "πŸš€ Setting up the hooks"
13+
@poetry run pre-commit install
14+
15+
check-project:
16+
@echo "πŸš€ Checking consistency between poetry.lock and pyproject.toml"
17+
@poetry check --lock
18+
@echo "πŸš€ Running the hooks against all files"
19+
@poetry run pre-commit run --all-files
20+
21+
ruff:
22+
@echo "πŸš€ Linting the project with Ruff"
23+
@poetry run ruff check src tests
24+
25+
ruff-show-violations:
26+
@echo "πŸš€ Linting the project with Ruff and show violations"
27+
@poetry run ruff check --show-source --show-fixes src tests
28+
29+
ruff-fix:
30+
@echo "πŸš€ Linting the project with Ruff and autofix violations (where possible)"
31+
@poetry run ruff check --fix src tests
32+
33+
black:
34+
@echo "πŸš€ Formatting the code with Black"
35+
@poetry run black src tests
36+
37+
black-check:
38+
@echo "πŸš€ Checking formatting advices from Black"
39+
@poetry run black --check --diff src tests
40+
41+
lint-and-format: ruff black
42+
43+
test:
44+
@echo "πŸš€ Testing code with pytest"
45+
@poetry run pytest --verbose tests
46+
47+
test-and-report-cov:
48+
@echo "πŸš€ Testing code with pytest and generating coverage report"
49+
@poetry run pytest --cov=./ --cov-report=xml

0 commit comments

Comments
Β (0)