Skip to content

Commit

Permalink
chore: Use uv for dependency management (#455)
Browse files Browse the repository at this point in the history
* chore: Use uv for dependency management

* chore: Update workflows and switch to Renovate to support uv

* chore: Remove unnecessary requirements field in charmcraft.yaml

* chore: Use latest v2.1.0 release of workflows
  • Loading branch information
ghislainbourgeois authored Nov 18, 2024
1 parent 9189dee commit a438932
Show file tree
Hide file tree
Showing 17 changed files with 1,850 additions and 426 deletions.
34 changes: 0 additions & 34 deletions .github/dependabot.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
":disableRateLimiting",
":noUnscheduledUpdates",
// Avoid conflicts with custom `commitMessagePrefix`
":semanticCommitsDisabled"
],
"automerge": true,
"automergeStrategy": "squash",
"automergeType": "pr",
"platformAutomerge": true,
"schedule": ["after 1am and before 3am every monday"],
"lockFileMaintenance": {
"enabled": true,
"schedule": ["after 1am and before 3am every wednesday"]
},
"timezone": "Etc/UTC",
"enabledManagers": ["pep621", "github-actions", "terraform"],
"packageRules": [
// Later rules override earlier rules
{
"matchManagers": ["pep621"],
"rangeStrategy": "bump",
"groupName": "Python dependencies"
},
{
"matchManagers": ["github-actions"],
"groupName": "GitHub actions"
},
{
"matchManagers": ["terraform"],
"groupName": "Terraform"
},
],
}
14 changes: 0 additions & 14 deletions .github/workflows/dependabot_pr.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ on:
jobs:
update:
name: Update Issue
uses: canonical/sdcore-github-workflows/.github/workflows/issues.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/issues.yaml@v2.1.0
secrets:
JIRA_URL: ${{ secrets.JIRA_URL }}
22 changes: 11 additions & 11 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,37 @@ on:
jobs:
codeql:
name: CodeQL Analysis
uses: canonical/sdcore-github-workflows/.github/workflows/codeql-analysis.yml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/codeql-analysis.yml@v2.1.0

check-libraries:
uses: canonical/sdcore-github-workflows/.github/workflows/check-libraries.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/check-libraries.yaml@v2.1.0
secrets:
CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_AUTH }}

lint-report:
uses: canonical/sdcore-github-workflows/.github/workflows/lint-report.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/lint-report.yaml@v2.1.0

terraform-check:
uses: canonical/sdcore-github-workflows/.github/workflows/terraform.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/terraform.yaml@v2.1.0

static-analysis:
uses: canonical/sdcore-github-workflows/.github/workflows/static-analysis.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/static-analysis.yaml@v2.1.0

unit-tests-with-coverage:
uses: canonical/sdcore-github-workflows/.github/workflows/unit-test.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/unit-test.yaml@v2.1.0

build:
needs:
- lint-report
- static-analysis
- unit-tests-with-coverage
uses: canonical/sdcore-github-workflows/.github/workflows/build.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/build.yaml@v2.1.0
secrets: inherit

integration-test:
needs:
- build
uses: canonical/sdcore-github-workflows/.github/workflows/integration-test.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/integration-test.yaml@v2.1.0
with:
enable-metallb: true

Expand All @@ -53,7 +53,7 @@ jobs:
- unit-tests-with-coverage
- integration-test
if: ${{ github.ref_name == 'main' }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-charm.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/publish-charm.yaml@v2.1.0
with:
track-name: 1.5
secrets:
Expand All @@ -67,7 +67,7 @@ jobs:
- unit-tests-with-coverage
- integration-test
if: ${{ (github.ref_name != 'main') && (github.event_name == 'push') }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-charm.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/publish-charm.yaml@v2.1.0
with:
branch-name: ${{ github.ref_name }}
track-name: 1.5
Expand All @@ -93,7 +93,7 @@ jobs:
- publish-charm
- lib-needs-publishing
if: ${{ github.ref_name == 'main' }} && ${{ needs.changes.outputs.needs-publishing == 'true' }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@v2.1.0
with:
lib-name: "charms.sdcore_amf_k8s.v0.fiveg_n2"
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/promote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
jobs:
promote:
name: Promote Charm
uses: canonical/sdcore-github-workflows/.github/workflows/promote.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/promote.yaml@v2.1.0
with:
promotion: ${{ github.event.inputs.promotion }}
track-name: ${{ github.event.inputs.track-name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-libs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ permissions:
jobs:
update-lib:
name: Check libraries
uses: canonical/sdcore-github-workflows/.github/workflows/update-libs.yaml@v1.0.0
uses: canonical/sdcore-github-workflows/.github/workflows/update-libs.yaml@v2.1.0
secrets: inherit
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
*.idea
.vscode/
.coverage
.charm_tracing_buffer.raw
build/
src/sdcore_amf_k8s_operator.egg-info/

# Python
**/venv/**
**/.venv/**
*.pyc

# Charmcraft
Expand Down Expand Up @@ -43,4 +47,4 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc
.terraform.lock.hcl
.terraform.lock.hcl
21 changes: 13 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,26 @@ sudo snap install juju --channel=3.1/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: 9 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ bases:

parts:
charm:
source: .
plugin: charm
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
35 changes: 34 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
[project]
name = "sdcore-amf-k8s-operator"
version = "0.1.0"
requires-python = ">=3.10"

dependencies = [
"cosl",
"cryptography",
"jinja2",
"jsonschema",
"lightkube",
"lightkube-models",
"ops",
"opentelemetry-exporter-otlp-proto-http",
"pydantic<3.0",
"pytest-interface-tester",
"rpds-py==0.18.1",
]

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

# Testing tools configuration
[tool.coverage.run]
branch = true
Expand Down Expand Up @@ -34,4 +67,4 @@ per-file-ignores = {"tests/*" = ["D100","D101","D102","D103","D104"]}
max-complexity = 10

[tool.codespell]
skip = "build,lib,venv,icon.svg,.tox,.git,.ruff_cache,.coverage"
skip = "build,lib,venv,icon.svg,.tox,.git,.ruff_cache,.coverage"
11 changes: 0 additions & 11 deletions requirements.in

This file was deleted.

Loading

0 comments on commit a438932

Please sign in to comment.