Skip to content

Commit

Permalink
chore: Uses UV for dependency management (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gmerold authored Nov 27, 2024
1 parent d825019 commit dd2d6ea
Show file tree
Hide file tree
Showing 10 changed files with 1,628 additions and 442 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,45 @@
# Python
**/venv/**
*.pyc
*.venv
build/
*.egg-info/

# Charmcraft
*.charm

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
.terraform.lock.hcl
25 changes: 15 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lxd init --auto

Install MicroK8s:
```shell
sudo snap install microk8s --channel=1.27-strict/stable
sudo snap install microk8s --channel=1.31-strict/stable
sudo usermod -a -G snap_microk8s $USER
newgrp snap_microk8s
sudo microk8s enable hostpath-storage
Expand All @@ -27,25 +27,30 @@ sudo microk8s enable multus

Install Juju and bootstrap a controller on the MicroK8S instance:
```shell
sudo snap install juju --channel=3.4/stable
sudo snap install juju --channel=3.5/stable
juju bootstrap microk8s
```

Install `pip` and `tox`:
This project uses `uv`. You can install it on Ubuntu with:

```shell
sudo apt install python3-pip
python3 -m pip install "tox>=4.0.0"
sudo snap install --classic astral-uv
```

## Development
Activate the virtual environment created by `tox` for development:
You can create an environment for development with `uv`:

```shell
tox --notest -e unit
source .tox/unit/bin/activate
uv sync
source .venv/bin/activate
```

## Testing
This project uses `tox` for managing test environments.
This project uses `tox` for managing test environments. It can be installed
with:

```shell
uv tool install tox --with tox-uv
```

There are some pre-configured environments
that can be used for linting and formatting code when you're preparing contributions to the charm:
Expand Down
11 changes: 11 additions & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,23 @@ platforms:

parts:
charm:
source: .
plugin: charm
charm-requirements:
- requirements.txt
build-packages:
- cargo
- libffi-dev
- libssl-dev
- pkg-config
- rustc
build-snaps:
- astral-uv
- rustup
override-build: |
rustup default stable
uv export --frozen --no-dev -o requirements.txt
craftctl default
config:
options:
Expand Down
39 changes: 38 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
[project]
name = "sdcore-upf-k8s-operator"
version = "0.1.0"
requires-python = ">=3.10"

dependencies = [
"cosl",
"httpx",
"ipaddress",
"jinja2",
"juju",
"lightkube",
"lightkube-models",
"macaddress",
"ops",
"pydantic-extra-types",
"pydantic<3.0",
"pytest-interface-tester",
"pyyaml",
]

[dependency-groups]
test = [
"coverage[toml]",
"juju>=3.5.2.1",
"pytest",
"pytest-asyncio<0.23",
"pytest-operator",
"parameterized",
"ops-scenario",
]
dev = [
"codespell",
"pyright",
"ruff",
]

# Testing tools configuration
[tool.coverage.run]
branch = true
Expand All @@ -15,11 +52,11 @@ line-length = 99
[tool.ruff.lint]
select = ["E", "W", "F", "C", "N", "D", "I001"]
extend-ignore = [
"D107",
"D203",
"D204",
"D213",
"D215",
"D107",
"D400",
"D404",
"D406",
Expand Down
13 changes: 0 additions & 13 deletions requirements.in

This file was deleted.

190 changes: 0 additions & 190 deletions requirements.txt

This file was deleted.

12 changes: 0 additions & 12 deletions test-requirements.in

This file was deleted.

Loading

0 comments on commit dd2d6ea

Please sign in to comment.