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: remove peer relation and improve integration tests #2

Merged
merged 3 commits into from
Dec 20, 2024
Merged
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: 11 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
inclusive-naming-check:
name: Inclusive naming check
Expand All @@ -45,6 +49,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 +68,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,8 +87,10 @@ 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 type
run: just typecheck

integration-test:
name: Integration tests (LXD)
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/
58 changes: 30 additions & 28 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,48 @@ parts:
build-snaps:
- astral-uv
charm-requirements: ["requirements.txt"]
charm-binary-python-packages:
- rpds_py ~= 0.22.3
override-build: |
just requirements
craftctl default

subordinate: true
charm-libs:
- lib: operator-libs-linux.apt
version: "0.15"
- lib: operator-libs-linux.systemd
version: "1.4"

peers:
storage-peers:
interface: storage_peers
subordinate: true

requires:
fs-share:
interface: fs_share
filesystem:
interface: filesystem_info
jedel1043 marked this conversation as resolved.
Show resolved Hide resolved
limit: 1
juju-info:
interface: juju-info
scope: container

config:
options:
mountinfo:
default: "{}"
mountpoint:
description: Location to mount the filesystem on the machine.
type: string
noexec:
default: false
description: |
Block execution of binaries on the filesystem.
type: boolean
nosuid:
default: false
description: |
Do not honor suid and sgid bits on the filesystem.
type: boolean
nodev:
default: false
description: |
Information to mount the filesystem on the machine. This is specified as a JSON object string.
Example usage:
```bash
$ juju config slurmd mountpoints=<<EOF
{
"cephfs": {
"mountpoint": "/scratch",
"noexec": true
},
"nfs": {
"mountpoint": "/data",
"nosuid": true,
"nodev": true,
"read-only": true,
}
}
EOF
```
Blocking interpretation of character and/or block
devices on the filesystem.
type: boolean
read-only:
default: false
description: Mount filesystem as read-only.
type: boolean
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
type *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