Skip to content
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
2 changes: 1 addition & 1 deletion .copier-answers.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changes here will be overwritten by Copier
project_slug=mattermost
package_dir=cmem_plugin_mattermost

3 changes: 2 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Changes here will be overwritten by Copier
_commit: v6.1.0
_commit: v7.3.0-24-g169e035
_src_path: gh:eccenca/cmem-plugin-template
author_mail: hannes.hartmann@eccenca.com
author_name: Hannes Hartmann
github_page: https://github.com/eccenca/cmem-plugin-mattermost
project_description: Send messages to Mattermost channels and users.
project_slug: mattermost
project_type: plugin
pypi: true

12 changes: 8 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Install Task
uses: arduino/setup-task@v1
uses: arduino/setup-task@v2

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: '3.11'
python-version: '3.13'

- name: Install and configure poetry
uses: snok/install-poetry@v1
Expand Down Expand Up @@ -57,6 +57,10 @@ jobs:
run: |
task check:pytest

- name: deptry
run: |
task check:deptry

- name: safety
run: |
task check:safety
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Install Task
uses: arduino/setup-task@v1
uses: arduino/setup-task@v2

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: '3.11'
python-version: '3.13'

- name: Install and configure poetry
uses: snok/install-poetry@v1
Expand Down
13 changes: 8 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
default:
image: docker-registry.eccenca.com/eccenca-python:v3.11.4
image: docker-registry.eccenca.com/eccenca-python:v3.13.8
# all jobs can be interrupted in case a new commit is pushed
interruptible: true
before_script:
Expand Down Expand Up @@ -53,10 +53,12 @@ pytest:
junit:
- dist/junit-pytest.xml
paths:
- dist/badge-coverage.svg
- dist/badge-tests.svg
- dist/coverage
- dist/coverage.xml
- dist/*

deptry:
stage: test
script:
- task check:deptry

safety:
stage: test
Expand All @@ -69,6 +71,7 @@ build:
- mypy
- pytest
- safety
- deptry
script:
- task build
artifacts:
Expand Down
2 changes: 1 addition & 1 deletion .idea/cmem-plugin-mattermost.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11
3.13
19 changes: 19 additions & 0 deletions .tasks-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://taskfile.dev
---
version: '3'

tasks:

install:
desc: Install plugin package in Corporate Memory
cmds:
- task build
- poetry run cmemc admin workspace python install dist/cmem_plugin_mattermost*.tar.gz
- poetry run cmemc admin workspace python list-plugins

uninstall:
desc: Unnstall plugin package in Corporate Memory
cmds:
- task build
- poetry run cmemc admin workspace python uninstall cmem-plugin-mattermost
- poetry run cmemc admin workspace python list-plugins
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

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

## [2.3.0] 2025-10-20

### Changed

- upgrade template for python 3.13 compatability
- changed from pytest_docker_compose to pytest-docker in test suite
- this was needed since urllib required a certain docker version that pytest_docker_compose could not fulfill

## [2.2.0] 2024-03-24

### Changed
Expand Down
20 changes: 16 additions & 4 deletions README-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

Send messages to [Mattermost](https://mattermost.com/). channels and users.

This is a plugin for [eccenca](https://eccenca.com) [Corporate Memory](https://documentation.eccenca.com).
[![eccenca Corporate Memory][cmem-shield]][cmem-link]

You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line
clients like this:
This is a plugin for [eccenca](https://eccenca.com) [Corporate Memory](https://documentation.eccenca.com). You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line client like this:

```shell-session
```
cmemc admin workspace python install cmem-plugin-mattermost
```
[![workflow](https://github.com/eccenca/cmem-plugin-mattermost/actions/workflows/check.yml/badge.svg)](https://github.com/eccenca/cmem-plugin-mattermost/actions) [![pypi version](https://img.shields.io/pypi/v/cmem-plugin-mattermost)](https://pypi.org/project/cmem-plugin-mattermost) [![license](https://img.shields.io/pypi/l/cmem-plugin-mattermost)](https://pypi.org/project/cmem-plugin-mattermost)
[![poetry][poetry-shield]][poetry-link] [![ruff][ruff-shield]][ruff-link] [![mypy][mypy-shield]][mypy-link] [![copier][copier-shield]][copier]

[cmem-link]: https://documentation.eccenca.com
[cmem-shield]: https://img.shields.io/endpoint?url=https://dev.documentation.eccenca.com/badge.json
[poetry-link]: https://python-poetry.org/
[poetry-shield]: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
[ruff-link]: https://docs.astral.sh/ruff/
[ruff-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&label=Code%20Style
[mypy-link]: https://mypy-lang.org/
[mypy-shield]: https://www.mypy-lang.org/static/mypy_badge.svg
[copier]: https://copier.readthedocs.io/
[copier-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-purple.json
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Send messages to [Mattermost](https://mattermost.com/) channels and users.

[![eccenca Corporate Memory](https://img.shields.io/badge/eccenca-Corporate%20Memory-orange)](https://documentation.eccenca.com) [![workflow](https://github.com/eccenca/cmem-plugin-mattermost/actions/workflows/check.yml/badge.svg)](https://github.com/eccenca/cmem-plugin-mattermost/actions) [![pypi version](https://img.shields.io/pypi/v/cmem-plugin-mattermost)](https://pypi.org/project/cmem-plugin-mattermost) [![license](https://img.shields.io/pypi/l/cmem-plugin-mattermost)](https://pypi.org/project/cmem-plugin-mattermost)
[![eccenca Corporate Memory][cmem-shield]][cmem-link][![workflow](https://github.com/eccenca/cmem-plugin-mattermost/actions/workflows/check.yml/badge.svg)](https://github.com/eccenca/cmem-plugin-mattermost/actions) [![pypi version](https://img.shields.io/pypi/v/cmem-plugin-mattermost)](https://pypi.org/project/cmem-plugin-mattermost) [![license](https://img.shields.io/pypi/l/cmem-plugin-mattermost)](https://pypi.org/project/cmem-plugin-mattermost)
[![poetry][poetry-shield]][poetry-link] [![ruff][ruff-shield]][ruff-link] [![mypy][mypy-shield]][mypy-link] [![copier][copier-shield]][copier]

## Development

Expand Down Expand Up @@ -117,3 +118,13 @@ User-ID : "3j4wossgfirburd63ftd5mq16c"
| mattermost:db:load | Load the mattermost database from volume/db.sql |
| mattermost:start | Start or restart the mattermost orchestration |
| mattermost:stop | Stop the mattermost orchestration |
[cmem-link]: https://documentation.eccenca.com
[cmem-shield]: https://img.shields.io/endpoint?url=https://dev.documentation.eccenca.com/badge.json
[poetry-link]: https://python-poetry.org/
[poetry-shield]: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
[ruff-link]: https://docs.astral.sh/ruff/
[ruff-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&label=Code%20Style
[mypy-link]: https://mypy-lang.org/
[mypy-shield]: https://www.mypy-lang.org/static/mypy_badge.svg
[copier]: https://copier.readthedocs.io/
[copier-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-purple.json
44 changes: 27 additions & 17 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# https://taskfile.dev
#
# This is a generated file. We dot not suggest to edit it.
# Instead, create a file `TaskfileCustom.yml` and add your additions there.
---
version: '3'

Expand All @@ -10,13 +13,18 @@ dotenv: ['.copier-answers.env', '.env']
- check:prepare

vars:
PACKAGE: cmem_plugin_$project_slug
PACKAGE: $package_dir
DIST_DIR: dist

includes:
custom:
taskfile: ./TaskfileCustom.yaml
optional: true
flatten: true
plugin:
taskfile: .tasks-plugin.yml
optional: true
flatten: true

tasks:

Expand All @@ -43,6 +51,10 @@ tasks:
Check poetry versioning plugin. Currently not under Windows
run: once
preconditions:
- sh: '[ -d .git ]'
msg: >
Your newly created project directory needs to be initialized
as a git repository.
- sh: '[[ {{.PDV_VERSION}} > {{.PDV_VERSION_MIN}} ]]'
msg: >
This project needs the poetry-dynamic-versioning
Expand All @@ -58,7 +70,6 @@ tasks:
| head -1 | cut -d " " -f 2 | cut -d "." -f 1-2

poetry:install:
internal: true
desc: Install dependencies managed by Poetry
run: once
deps:
Expand Down Expand Up @@ -100,6 +111,7 @@ tasks:
cmds:
- task: check:ruff
- task: check:mypy
- task: check:deptry
- task: check:safety

check:pytest:
Expand All @@ -113,23 +125,26 @@ tasks:
poetry run pytest --junitxml={{.JUNIT_FILE}}
--cov-report term --cov-report xml:{{.COVERAGE_FILE}}
--cov-report html:{{.COVERAGE_DIR}} --cov={{.PACKAGE}}
--html={{.HTML_FILE}} --self-contained-html
- platforms: [darwin, linux]
cmd: >
poetry run pytest --memray --junitxml={{.JUNIT_FILE}}
--cov-report term --cov-report xml:{{.COVERAGE_FILE}}
--cov-report html:{{.COVERAGE_DIR}} --cov={{.PACKAGE}}
--html={{.HTML_FILE}} --self-contained-html
- cmd: >
poetry run genbadge coverage -l
-i {{.COVERAGE_FILE}} -o {{.BADGE_COVERAGE}}
- cmd: >
poetry run genbadge tests -l
-i {{.JUNIT_FILE}} -o {{.BADGE_TESTS}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-pytest.xml
COVERAGE_FILE: ./{{.DIST_DIR}}/coverage.xml
COVERAGE_DIR: ./{{.DIST_DIR}}/coverage
BADGE_COVERAGE: ./{{.DIST_DIR}}/badge-coverage.svg
BADGE_TESTS: ./{{.DIST_DIR}}/badge-tests.svg
COVERAGE_DIR: ./{{.DIST_DIR}}/coverage
COVERAGE_FILE: ./{{.DIST_DIR}}/coverage.xml
HTML_FILE: ./{{.DIST_DIR}}/pytest.html
JUNIT_FILE: ./{{.DIST_DIR}}/junit-pytest.xml

check:mypy:
desc: Complain about typing errors
Expand All @@ -148,27 +163,24 @@ tasks:
# ignore 61489 pillow - dev dependency only
- poetry run safety check -i 39611 -i 51358 -i 61489

check:deptry:
desc: Complain about unused or missing dependencies
<<: *preparation
cmds:
- poetry run deptry .

check:ruff:
desc: Complain about everything else
<<: *preparation
cmds:
- poetry run ruff check --exit-zero tests {{.PACKAGE}} {{.XML_PARAMS}}
- poetry run ruff check --show-source tests {{.PACKAGE}}
- poetry run ruff check --output-format=concise tests {{.PACKAGE}}
- poetry run ruff format --check tests {{.PACKAGE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-ruff.xml
XML_PARAMS: --output-format junit --output-file {{.JUNIT_FILE}}

# }}}
# {{{ build and deploy tasks

deploy:
desc: Install plugin package in Corporate Memory
deps:
- build
cmds:
- cmemc admin workspace python install dist/*.tar.gz
- cmemc admin workspace python list-plugins

build:
desc: Build a tarball and a wheel package
Expand All @@ -179,5 +191,3 @@ tasks:
cmds:
- poetry build

# }}}

2 changes: 1 addition & 1 deletion cmem_plugin_mattermost/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""mattermost - main package"""
"""cmem-plugin-mattermost"""
7 changes: 4 additions & 3 deletions cmem_plugin_mattermost/workflow/mattermost_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A Mattermost integration Plugin"""

from collections.abc import Sequence
from typing import Any

Expand Down Expand Up @@ -153,7 +154,7 @@ def autocomplete(
PluginParameter(
name="bot_name",
label="Bot name",
description="The name or display name of the bot you want to use to" " connect.",
description="The name or display name of the bot you want to use to connect.",
),
PluginParameter(
name="access_token",
Expand Down Expand Up @@ -258,7 +259,7 @@ def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> None
channel_counter += 1
elif _ == "message" and param_value != "":
self.message = param_value
i += 1
i += 1 # noqa: SIM113
self.send_message()
users = list(dict.fromkeys(users))
channels = list(dict.fromkeys(channels))
Expand Down Expand Up @@ -295,7 +296,7 @@ def get_id(self, obj_name: str) -> str:
_["username"],
_["nickname"],
_["email"],
f'{_["first_name"]} {_["last_name"]}',
f"{_['first_name']} {_['last_name']}",
):
return _["id"] # type: ignore[no-any-return]
raise ValueError(f"ID not found, check {obj_name} parameter.")
Expand Down
Loading