Skip to content

Commit

Permalink
chore: avoid vendoring charm libs
Browse files Browse the repository at this point in the history
This avoids having big diffs when bumping the version of charm libs.
  • Loading branch information
jedel1043 committed Dec 18, 2024
1 parent 4b30161 commit aac1ee2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1,656 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
uses: astral-sh/setup-uv@v4
with:
version: "0.5.8"
- name: Install Charmcraft
run: sudo snap install charmcraft --classic --channel latest/stable
- name: Run linters
run: just lint

Expand All @@ -62,6 +64,8 @@ jobs:
uses: astral-sh/setup-uv@v4
with:
version: 0.5.8
- name: Install Charmcraft
run: sudo snap install charmcraft --classic --channel latest/stable
- name: Run unit tests
run: just unit

Expand All @@ -79,6 +83,8 @@ jobs:
uses: astral-sh/setup-uv@v4
with:
version: 0.5.8
- name: Install Charmcraft
run: sudo snap install charmcraft --classic --channel latest/stable
- name: Run tests
run: just typecheck

Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ __pycache__/
*.py[cod]
.idea
.vscode/
requirements.txt
requirements.txt

# Ignore libs except the filesystem_client

lib/charms/*
!lib/charms/filesystem_client/
6 changes: 6 additions & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ parts:
just requirements
craftctl default
charm-libs:
- lib: operator-libs-linux.apt
version: "0.15"
- lib: operator-libs-linux.systemd
version: "1.4"

subordinate: true

requires:
Expand Down
20 changes: 14 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
uv := `which uv`
charmcraft := `which charmcraft`

project_dir := justfile_directory()

Expand All @@ -13,10 +14,18 @@ export PYTHONBREAKPOINT := "pdb.set_trace"

uv_run := "uv run --frozen --extra dev"

# Regenerate uv.lock
# Regenerate uv.lock.
lock:
uv lock --no-cache

# Fetch the required charm libraries.
fetch-libs:
charmcraft fetch-libs

# Create a development environment.
env: lock fetch-libs
uv sync --extra dev

# Upgrade uv.lock with the latest deps
upgrade:
uv lock --upgrade --no-cache
Expand All @@ -27,23 +36,22 @@ requirements: lock

# Apply coding style standards to code
fmt: lock
echo {{PYTHONPATH}}
{{uv_run}} ruff format {{all}}
{{uv_run}} ruff check --fix {{all}}

# Check code against coding style standards
lint: lock
lint: lock fetch-libs
{{uv_run}} codespell {{lib}}
{{uv_run}} codespell {{project_dir}}
{{uv_run}} ruff check {{all}}
{{uv_run}} ruff format --check --diff {{all}}

# Run static type checks
typecheck *args: lock
typecheck *args: lock fetch-libs
{{uv_run}} pyright {{args}}

# Run unit tests
unit *args: lock
unit *args: lock fetch-libs
{{uv_run}} coverage run \
--source={{src}} \
--source={{lib}} \
Expand All @@ -56,7 +64,7 @@ unit *args: lock
{{uv_run}} coverage report

# Run integration tests
integration *args: lock
integration *args: lock fetch-libs
{{uv_run}} pytest \
-v \
-s \
Expand Down
Loading

0 comments on commit aac1ee2

Please sign in to comment.