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: migrate from make to just #314

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install dependencies
run: sudo snap install --classic astral-uv
run: |
sudo snap install --classic astral-uv
sudo snap install --classic just
- name: Run linters
run: make lint
run: just lint

unit-test:
name: Unit tests
Expand All @@ -25,9 +27,11 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install dependencies
run: sudo snap install --classic astral-uv
run: |
sudo snap install --classic astral-uv
sudo snap install --classic just
- name: Run tests
run: make unit
run: just unit

lib-check:
name: Check libraries
Expand Down
16 changes: 12 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ This project uses [`uv`](https://github.com/astral-sh/uv) for managing dependenc
environments.

You can create a virtual environment manually should you wish, though most of that is taken
care of automatically if you use the `Makefile` provided:
care of automatically if you use the `justfile` provided. Simply run
[`just`](https://github.com/casey/just) (you can `snap install just`) to show the available
commands:

```shell
make fmt # update your code according to linting rules
make lint # code style
make unit # unit tests
∮ just
Available recipes:
clean # Cleanup transient files
fmt # Format the code
generate-requirements # Generate requirements.txt from pyproject.toml
integration *args='' # Run integration tests
lint # Lint the code
lock # Update uv.lock with the latest deps
unit *args='' # Run unit tests
```

To create the environment manually:
Expand Down
56 changes: 0 additions & 56 deletions Makefile

This file was deleted.

3 changes: 2 additions & 1 deletion charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ parts:
build-snaps:
- rustup
- astral-uv
- just
override-build: |
rustup toolchain install stable
make generate-requirements
just generate-requirements
craftctl default
prime:
- -*.charm
Expand Down
73 changes: 73 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
set quiet # Recipes are silent by default
set export # Just variables are exported to the environment
set positional-arguments # Send positional arguments to Just recipes

PROJECT := invocation_directory()

SRC := PROJECT + "/src"
TESTS := PROJECT + "/tests"
ALL := SRC + " " + TESTS

PYTHONPATH := PROJECT + ":" + \
SRC + ":" + \
PROJECT + "/lib"

# List the available recipes
[private]
default:
just --list

# Update uv.lock with the latest deps
lock:
uv lock --upgrade --no-cache

# Generate requirements.txt from pyproject.toml
generate-requirements:
uv export --frozen --no-hashes --format=requirements-txt -o requirements.txt

# Lint the code
lint:
uv tool run ruff check $ALL
uv tool run ruff format --check --diff $ALL

# Format the code
fmt:
uv tool run ruff check --fix-only $ALL
uv tool run ruff format $ALL

# Run unit tests
unit *args='':
uv run --frozen --isolated --all-extras \
coverage run \
--source=$SRC \
-m pytest \
--ignore=$TESTS/integration \
--tb native \
-v \
-s \
"$@"
uv run --all-extras coverage report

# Run integration tests
integration *args='':
uv run --frozen --isolated --all-extras \
pytest \
-v \
-x \
-s \
--tb native \
--ignore=$TESTS/unit \
--log-cli-level=INFO \
"$@"

# Cleanup transient files
clean:
rm -rf .coverage
rm -rf .pytest_cache
rm -rf .ruff_cache
rm -rf .venv
rm -rf *.charm
rm -rf *.rock
rm -rf **/__pycache__
rm -rf **/*.egg-info
rm -rf requirements*.txt
2 changes: 1 addition & 1 deletion spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ prepare: |
fi

snap install --classic concierge
concierge prepare --trace -p microk8s --extra-snaps astral-uv --extra-debs make
concierge prepare --trace -p microk8s --extra-snaps astral-uv,just

pushd "$SPREAD_PATH"

Expand Down
2 changes: 1 addition & 1 deletion tests/spread/deploy-python/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ execute: |
args="--charm-path=$PWD/zinc-k8s_amd64.charm $args"
fi

make integration ARGS="$args"
just integration "$args"

restore: |
if [[ -z "${CI:-}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion tests/spread/ingress-path/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ execute: |
args="--charm-path=$PWD/zinc-k8s_amd64.charm $args"
fi

make integration ARGS="$args"
just integration "$args"

restore: |
if [[ -z "${CI:-}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion tests/spread/ingress/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ execute: |
args="--charm-path=$PWD/zinc-k8s_amd64.charm $args"
fi

make integration ARGS="$args"
just integration "$args"

restore: |
if [[ -z "${CI:-}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion tests/spread/observability-relations/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ execute: |
args="--charm-path=$PWD/zinc-k8s_amd64.charm $args"
fi

make integration ARGS="$args"
just integration "$args"

restore: |
if [[ -z "${CI:-}" ]]; then
Expand Down