Skip to content

Commit 80c9fd7

Browse files
authored
Merge pull request #8 from eccenca/feature/useCmemClient-CMEM-7987
update template and replace cmempy with cmem-client
2 parents 1f4a42f + 47dc6f3 commit 80c9fd7

13 files changed

Lines changed: 1954 additions & 1512 deletions

‎.copier-answers.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: v7.3.0-24-g169e035
2+
_commit: v8.5.0-3-g60fcc85
33
_src_path: gh:eccenca/cmem-plugin-template
44
author_mail: cmempy-developer@eccenca.com
55
author_name: eccenca GmbH

‎.github/workflows/check.yml‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ jobs:
2222
- name: Check out repository
2323
uses: actions/checkout@v5
2424

25+
- name: Cache Trivy DB
26+
id: cache-trivydb
27+
uses: actions/cache@v4
28+
with:
29+
path: .trivycache
30+
key: ${{ runner.os }}-trivydb
31+
2532
- name: Install Task
2633
uses: arduino/setup-task@v2
2734

@@ -38,10 +45,6 @@ jobs:
3845
virtualenvs-in-project: true
3946
installer-parallel: true
4047

41-
- name: Install dynamic versioning plugin
42-
run: |
43-
poetry self add "poetry-dynamic-versioning[plugin]"
44-
4548
- name: mypy
4649
run: |
4750
task check:mypy
@@ -61,9 +64,13 @@ jobs:
6164
run: |
6265
task check:deptry
6366
64-
- name: safety
67+
- name: trivy
68+
env:
69+
TRIVY_NO_PROGRESS: "true"
70+
TRIVY_CACHE_DIR: ".trivycache/"
71+
TRIVY_DISABLE_VEX_NOTICE: "true"
6572
run: |
66-
task check:safety
73+
task check:trivy
6774
6875
- name: Publish Test Report in Action
6976
uses: mikepenz/action-junit-report@v4

‎.github/workflows/publish.yml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ jobs:
3535
virtualenvs-in-project: true
3636
installer-parallel: true
3737

38-
- name: Install dynamic versioning plugin
39-
run: |
40-
poetry self add "poetry-dynamic-versioning[plugin]"
41-
4238
- name: Publish Package
4339
env:
4440
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ dmypy.json
138138
# Cython debug symbols
139139
cython_debug/
140140

141+
# Claude code specifics
142+
.claude/settings.local.json
143+
141144
# project build plan specific ignores
142145
version.py
143146
co

‎.gitlab-ci.yml‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
default:
3-
image: docker-registry.eccenca.com/eccenca-python:v3.13.8
3+
image: docker-registry.eccenca.com/eccenca-python:v3.13.13
44
# all jobs can be interrupted in case a new commit is pushed
55
interruptible: true
66
before_script:
@@ -60,17 +60,24 @@ deptry:
6060
script:
6161
- task check:deptry
6262

63-
safety:
63+
trivy:
6464
stage: test
65+
variables:
66+
TRIVY_NO_PROGRESS: "true"
67+
TRIVY_CACHE_DIR: ".trivycache/"
68+
TRIVY_DISABLE_VEX_NOTICE: "true"
6569
script:
66-
- task check:safety
70+
- task check:trivy
71+
cache:
72+
paths:
73+
- .trivycache/
6774

6875
build:
6976
stage: build
7077
needs:
7178
- mypy
7279
- pytest
73-
- safety
80+
- trivy
7481
- deptry
7582
script:
7683
- task build

‎.pre-commit-config.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
default_language_version:
3+
python: python3.13
4+
25
repos:
36
- repo: local
47
hooks:
@@ -36,3 +39,9 @@ repos:
3639
stages: [post-checkout, post-merge]
3740
always_run: true
3841

42+
- id: trivy
43+
name: check:trivy
44+
description: run trivy to scan for vulnerabilities
45+
entry: task check:trivy
46+
language: python
47+
pass_filenames: false

‎.trivyignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# .trivyignore
2+
3+
# ignore 51358 safety - dev dependency only
4+
CVE-2022-39280

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55

66
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/)
77

8+
## [5.1.0] 2026-08-05
9+
10+
### Changed
11+
12+
- Update dependencies and template
13+
- Replace `cmem-cmempy` with `cmem-client`
14+
15+
816
## [5.0.0] 2024-10-16
917

1018
### Changed

‎CLAUDE.md‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
`cmem-plugin-graphql` is a [Corporate Memory (CMEM)](https://documentation.eccenca.com) plugin that executes GraphQL queries/mutations against an endpoint and saves results to a JSON dataset. It is generated from the [`eccenca/cmem-plugin-template`](https://github.com/eccenca/cmem-plugin-template).
8+
9+
## Quick Commands
10+
11+
```bash
12+
# Install dependencies
13+
poetry install
14+
15+
# Run all checks (linters + tests)
16+
task check
17+
18+
# Run only unit tests (no CMEM server required)
19+
task check:pytest
20+
21+
# Lint / format
22+
task check:ruff # lint only (non-fatal --exit-zero)
23+
task check:mypy # type checking
24+
task check:deptry # unused/missing deps
25+
task check:trivy # vulnerability scan
26+
task format:fix # auto-format + safe fixes
27+
task format:fix-unsafe # auto-format + unsafe fixes
28+
29+
# Build distribution
30+
task build # poetry build + export requirements.txt
31+
32+
# Install/uninstall plugin in a CMEM workspace
33+
task install # build + cmemc admin workspace python install
34+
task uninstall # cmemc admin workspace python uninstall
35+
```
36+
37+
Tests that require a live CMEM server are guarded with `@needs_cmem` (skips unless `CMEM_BASE_URI` is set). The lone non-CMEM test is `test_is_string_jinja_template` and `test_dummy`.
38+
39+
## Architecture
40+
41+
```
42+
cmem_plugin_graphql/
43+
__init__.py # package marker (empty)
44+
workflow/
45+
graphql.py # GraphQLPlugin — the single WorkflowPlugin entry point
46+
utils.py # jinja template detection, entity/dict conversion helpers
47+
tests/
48+
test_graphql.py # integration tests against a public test GraphQL endpoint
49+
```
50+
51+
### Key module: `workflow/graphql.py`
52+
53+
- **`GraphQLPlugin`** — decorated with `@Plugin(...)` to register as a CMEM workflow task. Parameters: `graphql_url`, `graphql_query`, `graphql_variable_values`, `graphql_dataset` (optional), `oauth_access_token` (optional).
54+
- Query validation: detects Jinja templates via `is_jinja_template()` (renders and checks for substitution); otherwise validates as pure GraphQL syntax with `gql()`.
55+
- Variable values validation: detects Jinja templates or validates as JSON.
56+
- **`execute()`** branching logic:
57+
- If Jinja is detected in either query or variables → iterates over input `Entities`, renders per-entity, executes per entity via `process_entities()`.
58+
- Otherwise → single-shot execution against the endpoint with static variables.
59+
- Results are collected into a list; if `graphql_dataset` is set, payload is written to that CMEM dataset via `write_to_dataset()`.
60+
61+
### Key module: `workflow/utils.py`
62+
63+
- **`is_jinja_template(value)`** — renders through Jinja's `Environment`; if the rendered output differs from the input, Jinja variables were present.
64+
- **`get_dict(entities)`** — iterator that flattens `Entities` into per-entity dicts keyed by schema path.
65+
- **`get_entities_from_list(data)` / `create_entity(paths, dict_)`** — bidirectional helpers for converting between `list[dict]` and `Entities`.
66+
67+
## Dependencies
68+
69+
| Category | Key packages |
70+
|----------|-------------|
71+
| Runtime | `graphql-core`, `gql[all]`, `Jinja2`, `validators` |
72+
| CMEM base | `cmem-plugin-base ^4.19.0` (declared as a Poetry `[tool.poetry.dependencies.cmem-plugin-base]` extra) |
73+
| Dev | `ruff`, `mypy`, `deptry`, `trivy-py-ecc`, `pytest` + cov, html, memray, dotenv |
74+
75+
Python version: **3.13** (pinned in `.python-version`).
76+
77+
## CI/CD
78+
79+
- `.github/workflows/check.yml` — runs mypy, ruff, pytest, deptry, trivy on PRs/pushes to `main`/`develop`.
80+
- `.github/workflows/publish.yml` — publishes to PyPI on tag push or manual dispatch.
81+
- Pre-commit hooks mirror the CI linters (ruff, poetry-check, poetry-lock) plus trivy.

‎Taskfile.yaml‎

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,9 @@ tasks:
4444
cmds:
4545
- mkdir -p {{.DIST_DIR}}/coverage
4646

47-
poetry:check:
48-
internal: true
49-
platforms: [darwin, linux]
50-
summary: |
51-
Check poetry versioning plugin. Currently not under Windows
52-
run: once
53-
preconditions:
54-
- sh: '[ -d .git ]'
55-
msg: >
56-
Your newly created project directory needs to be initialized
57-
as a git repository.
58-
- sh: '[[ {{.PDV_VERSION}} > {{.PDV_VERSION_MIN}} ]]'
59-
msg: >
60-
This project needs the poetry-dynamic-versioning
61-
plugin > v{{.PDV_VERSION_MIN}}.
62-
63-
You can install it with the following command:
64-
poetry self add "poetry-dynamic-versioning[plugin]"
65-
vars:
66-
PDV_VERSION_MIN: 0.20
67-
PDV_VERSION:
68-
sh: >
69-
poetry self show --addons poetry-dynamic-versioning --tree
70-
| head -1 | cut -d " " -f 2 | cut -d "." -f 1-2
71-
7247
poetry:install:
7348
desc: Install dependencies managed by Poetry
7449
run: once
75-
deps:
76-
- poetry:check
7750
cmds:
7851
- poetry install
7952

@@ -112,7 +85,7 @@ tasks:
11285
- task: check:ruff
11386
- task: check:mypy
11487
- task: check:deptry
115-
- task: check:safety
88+
- task: check:trivy
11689

11790
check:pytest:
11891
desc: Run unit and integration tests
@@ -154,12 +127,17 @@ tasks:
154127
vars:
155128
JUNIT_FILE: ./{{.DIST_DIR}}/junit-mypy.xml
156129

157-
check:safety:
158-
desc: Complain about vulnerabilities in dependencies
130+
check:trivy:
131+
desc: Scan for vulnerabilities using Trivy
159132
<<: *preparation
160133
cmds:
161-
# ignore 51358 safety - dev dependency only
162-
- poetry run safety check -i 51358
134+
- >
135+
poetry run trivy fs
136+
--include-dev-deps
137+
--scanners vuln
138+
--skip-files .poetry/plugins/poetry.lock
139+
--exit-code 1
140+
.
163141
164142
check:deptry:
165143
desc: Complain about unused or missing dependencies
@@ -185,7 +163,7 @@ tasks:
185163
<<: *preparation
186164
deps:
187165
- clean
188-
- poetry:check
189166
cmds:
190167
- poetry build
168+
- poetry export --without=dev -f requirements.txt >dist/requirements.txt
191169

0 commit comments

Comments
 (0)