From 150c5f00ea2ba602d1809bc0503a8084d126ddd2 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Tue, 16 Jan 2024 00:02:25 +0100 Subject: [PATCH 1/8] feat: add justfile --- .github/workflows/actions.yaml | 8 +++--- .pre-commit-config.yaml | 4 +-- justfile | 49 ++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 justfile diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 51cd7f1..48fd00c 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -52,16 +52,16 @@ jobs: run: poetry install --no-interaction - 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a18690..78675cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/justfile b/justfile new file mode 100644 index 0000000..c9c9b7b --- /dev/null +++ b/justfile @@ -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 From 00b17547f91cf375343ec08dd1286401b8687d11 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Tue, 16 Jan 2024 00:04:05 +0100 Subject: [PATCH 2/8] chore: update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a67036a..a8719a7 100644 --- a/README.md +++ b/README.md @@ -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? From c28d678353457def41bcda2ecc1e861e7b488d13 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Tue, 16 Jan 2024 00:23:06 +0100 Subject: [PATCH 3/8] feat: setup just action to use just in gh actions --- .github/workflows/actions.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 48fd00c..3660493 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -51,6 +51,9 @@ jobs: - name: Install project run: poetry install --no-interaction + - name: Setup just + uses: taiki-e/install-action@just + - name: Enforce code style (Ruff) run: just ruff-show-violations From 1fbcfd21c93850ee2e30ab05f3400c52f7d1c4e8 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Wed, 17 Jan 2024 19:02:39 +0100 Subject: [PATCH 4/8] feat: run actions on pwsh to be able to invoke just there --- .github/workflows/actions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 3660493..28ed735 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: bash + shell: pwsh steps: - name: Check out repository From d57c86b78b765701c13ff2eb783803c86c5b2d12 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Wed, 17 Jan 2024 19:32:51 +0100 Subject: [PATCH 5/8] feat: run actions on powershell to be able to invoke just there --- .github/workflows/actions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 28ed735..2649a00 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: pwsh + shell: powershell steps: - name: Check out repository From 8af1f04ff1918eb1c706a677401b45ad8ffa2712 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Wed, 24 Jan 2024 11:28:44 +0100 Subject: [PATCH 6/8] feat: explicitly set the shell for just setup action and related --- .github/workflows/actions.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 2649a00..e3144a9 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: powershell + shell: pwsh steps: - name: Check out repository @@ -53,18 +53,28 @@ jobs: - name: Setup just uses: taiki-e/install-action@just + with: + shell: pwsh - name: Enforce code style (Ruff) run: just ruff-show-violations + with: + shell: pwsh - name: Verify code formatting (Black) run: just black-check + with: + shell: pwsh - name: Run tests run: just test + with: + shell: pwsh - name: Generate test coverage report run: just test-and-report-cov + with: + shell: pwsh - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 From 6c1bcf1693f83aef16fbbd47691411e9aa2fae85 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Wed, 24 Jan 2024 11:36:24 +0100 Subject: [PATCH 7/8] fix: shell: specification in lieu of invalid with: shell --- .github/workflows/actions.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index e3144a9..57f29f4 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -57,24 +57,20 @@ jobs: shell: pwsh - name: Enforce code style (Ruff) + shell: pwsh run: just ruff-show-violations - with: - shell: pwsh - name: Verify code formatting (Black) + shell: pwsh run: just black-check - with: - shell: pwsh - name: Run tests + shell: pwsh run: just test - with: - shell: pwsh - name: Generate test coverage report + shell: pwsh run: just test-and-report-cov - with: - shell: pwsh - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 From e4bf404999d4aedad1d870395ef2cbe9eaf16a99 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Wed, 24 Jan 2024 15:24:01 +0100 Subject: [PATCH 8/8] feat: setup just to work on bash rather than on pwsh --- .github/workflows/actions.yaml | 8 +------- justfile | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 57f29f4..3660493 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: pwsh + shell: bash steps: - name: Check out repository @@ -53,23 +53,17 @@ jobs: - name: Setup just uses: taiki-e/install-action@just - with: - shell: pwsh - name: Enforce code style (Ruff) - shell: pwsh run: just ruff-show-violations - name: Verify code formatting (Black) - shell: pwsh run: just black-check - name: Run tests - shell: pwsh run: just test - name: Generate test coverage report - shell: pwsh run: just test-and-report-cov - name: Upload coverage reports to Codecov diff --git a/justfile b/justfile index c9c9b7b..363c13d 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ # Use PowerShell instead of sh -set shell := ["powershell.exe", "-c"] +# set shell := ["powershell.exe", "-c"] help: @just --list