From 6e00f125ff2761858038f0d241db8b670e744b41 Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Tue, 21 Jan 2025 15:40:54 +0200 Subject: [PATCH 1/8] Improve module generator --- .../template/{{cookiecutter.module_dir}}/manifest.json | 2 ++ .../template/{{cookiecutter.module_dir}}/pyproject.toml | 1 + 2 files changed, 3 insertions(+) diff --git a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json index c501297..e0b3e07 100644 --- a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json +++ b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json @@ -8,6 +8,8 @@ }, "description": "{{cookiecutter.module_description}}", "name": "{{cookiecutter.module_name}}", + "slug": "{{cookiecutter.module_name.replace(' ', '-')}}", + "categories": [], "uuid": "{{ uuid4() }}", "version": "0.1.0" } diff --git a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml index c282d6a..f12f06d 100644 --- a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml +++ b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml @@ -3,6 +3,7 @@ name = "Automation module for {{cookiecutter.module_name.capitalize()}}" version = "0.0" description = "" authors = [] +package-mode = false [tool.poetry.dependencies] python = ">=3.10,<3.12" From fb32901d4531699928c4252f6b7d38d4315969b6 Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Tue, 21 Jan 2025 15:44:38 +0200 Subject: [PATCH 2/8] Fix dockerfile --- .../new_module/template/{{cookiecutter.module_dir}}/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/Dockerfile b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/Dockerfile index 411dd17..16a2ddf 100644 --- a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/Dockerfile +++ b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/Dockerfile @@ -6,7 +6,7 @@ RUN pip install poetry # Install dependencies COPY poetry.lock pyproject.toml /app/ -RUN poetry config virtualenvs.create false && poetry install --no-dev +RUN poetry config virtualenvs.create false && poetry install --only main COPY . . From 0e12fe2a5cfc2937da0db3b0a63dea789b4cc50f Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Wed, 22 Jan 2025 08:56:53 +0200 Subject: [PATCH 3/8] Show coverage by default --- .../pyproject.toml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml index f12f06d..bfeb3f3 100644 --- a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml +++ b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/pyproject.toml @@ -32,4 +32,21 @@ line_length = 119 omit = [ "tests/*", "main.py", -] \ No newline at end of file +] + +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = [ + "tests", +] +addopts = ''' + --strict-markers + --tb=short + --cov={{cookiecutter.module_name.lower().replace(" ", "_")}}_modules + --cov-branch + --cache-clear + --cov-report=html + --cov-report=term-missing:skip-covered + --cov-fail-under=5 + --capture=sys +''' From a5c0327dc58306348e1224fb5af5ff748e57f2d9 Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Wed, 22 Jan 2025 09:09:49 +0200 Subject: [PATCH 4/8] Fix CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 284b9f1..73fc9ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - name: Check `poetry.lock` consistency run: | - poetry lock --check + poetry check - name: Install linting dependencies run: | From cd34430bf6068ed5f8fccd6dadc0cd73117a1ab8 Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Wed, 22 Jan 2025 09:11:43 +0200 Subject: [PATCH 5/8] Add changelog record --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b376e9..1bee278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fixed template for module generation + ## 1.18.1 - 2024-12-04 ### Added From 59f42dbde2a6039730c7b8de17e6348655436051 Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Wed, 22 Jan 2025 09:34:19 +0200 Subject: [PATCH 6/8] Fix slug --- .../template/{{cookiecutter.module_dir}}/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json index e0b3e07..79012ff 100644 --- a/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json +++ b/sekoia_automation/scripts/new_module/template/{{cookiecutter.module_dir}}/manifest.json @@ -8,7 +8,7 @@ }, "description": "{{cookiecutter.module_description}}", "name": "{{cookiecutter.module_name}}", - "slug": "{{cookiecutter.module_name.replace(' ', '-')}}", + "slug": "{{cookiecutter.module_name.lower().replace(' ', '-')}}", "categories": [], "uuid": "{{ uuid4() }}", "version": "0.1.0" From eadc9d14cfc81a136ea87ccaa6054aaf2fbef7e4 Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Wed, 22 Jan 2025 09:38:05 +0200 Subject: [PATCH 7/8] Generate folder without spaces --- sekoia_automation/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sekoia_automation/cli.py b/sekoia_automation/cli.py index 1a7c595..33171a0 100644 --- a/sekoia_automation/cli.py +++ b/sekoia_automation/cli.py @@ -95,7 +95,7 @@ def new_module( extra_context={ "module_name": module_name, "module_description": description, - "module_dir": module_name, + "module_dir": module_name.replace(" ", ""), }, accept_hooks=not skip_hooks, ) From 7f87b5895fc481bbf2efd978ed727fe2d27c7a7e Mon Sep 17 00:00:00 2001 From: lvoloshyn-sekoia Date: Wed, 22 Jan 2025 09:49:26 +0200 Subject: [PATCH 8/8] Fix test --- tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 90f0629..9d351fd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -31,7 +31,7 @@ def test_new_module(tmp_path): ) assert res.exit_code == 0 - module_path = tmp_path.joinpath(module) + module_path = tmp_path.joinpath("MyModule") # without spaces assert module_path.is_dir() manifest = json.loads(module_path.joinpath("manifest.json").read_text())