diff --git a/charmcraft.yaml b/charmcraft.yaml index 75f1fb50f9..87a3f72d53 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -86,6 +86,7 @@ parts: source: . stage: - LICENSE + - scripts - templates libpq: build-packages: diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000000..e1b55ab3b2 --- /dev/null +++ b/scripts/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2025 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Charm script utilities.""" diff --git a/src/rotate_logs.py b/scripts/rotate_logs.py similarity index 93% rename from src/rotate_logs.py rename to scripts/rotate_logs.py index b19e935573..cb6a3f441b 100644 --- a/src/rotate_logs.py +++ b/scripts/rotate_logs.py @@ -1,4 +1,4 @@ -# Copyright 2024 Canonical Ltd. +# Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Service for rotating logs.""" diff --git a/src/backups.py b/src/backups.py index 1324b50791..c798e930be 100644 --- a/src/backups.py +++ b/src/backups.py @@ -1205,7 +1205,7 @@ def _render_pgbackrest_conf_file(self) -> bool: with open("templates/pgbackrest.logrotate.j2") as file: template = Template(file.read()) self.container.push(PGBACKREST_LOGROTATE_FILE, template.render()) - with open("src/rotate_logs.py") as f: + with open("scripts/rotate_logs.py") as f: self.container.push( "/home/postgres/rotate_logs.py", f.read(), diff --git a/tests/unit/test_rotate_logs.py b/tests/unit/test_rotate_logs.py index c5f66f1fce..8b579e8e21 100644 --- a/tests/unit/test_rotate_logs.py +++ b/tests/unit/test_rotate_logs.py @@ -3,7 +3,7 @@ import contextlib from unittest.mock import call, patch -from rotate_logs import main +from scripts.rotate_logs import main def test_main(): diff --git a/tox.ini b/tox.ini index f61bf9cf28..f842fe1afe 100644 --- a/tox.ini +++ b/tox.ini @@ -7,9 +7,10 @@ env_list = lint, unit [vars] src_path = "{tox_root}/src" +scripts_path = "{tox_root}/scripts" tests_path = "{tox_root}/tests" lib_path = "{tox_root}/lib/charms/postgresql_k8s" -all_path = {[vars]src_path} {[vars]tests_path} {[vars]lib_path} +all_path = {[vars]src_path} {[vars]scripts_path} {[vars]tests_path} {[vars]lib_path} [testenv] set_env = @@ -48,7 +49,7 @@ set_env = commands_pre = poetry install --only main,charm-libs,unit --no-root commands = - poetry run coverage run --source={[vars]src_path} \ + poetry run coverage run --source={[vars]src_path},{[vars]scripts_path} \ -m pytest -v --tb native -s {posargs} {[vars]tests_path}/unit poetry run coverage report poetry run coverage xml