pretalx-gitlab-trigger 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pretalx_gitlab_trigger-1.0.0/LICENSE +13 -0
- pretalx_gitlab_trigger-1.0.0/MANIFEST.in +2 -0
- pretalx_gitlab_trigger-1.0.0/PKG-INFO +55 -0
- pretalx_gitlab_trigger-1.0.0/README.rst +34 -0
- pretalx_gitlab_trigger-1.0.0/justfile +76 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger/__init__.py +1 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger/apps.py +22 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger/signals.py +59 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger.egg-info/PKG-INFO +55 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger.egg-info/SOURCES.txt +15 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger.egg-info/dependency_links.txt +1 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger.egg-info/entry_points.txt +2 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger.egg-info/requires.txt +7 -0
- pretalx_gitlab_trigger-1.0.0/pretalx_gitlab_trigger.egg-info/top_level.txt +1 -0
- pretalx_gitlab_trigger-1.0.0/pyproject.toml +138 -0
- pretalx_gitlab_trigger-1.0.0/setup.cfg +4 -0
- pretalx_gitlab_trigger-1.0.0/tests/test_signals.py +89 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Jozef Mlich
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pretalx-gitlab-trigger
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Start a GitLab pipeline when the schedule, slides or PeerTube links change.
|
|
5
|
+
Author-email: Jozef Mlich <jmlich83@gmail.com>
|
|
6
|
+
Maintainer-email: Jozef Mlich <jmlich83@gmail.com>
|
|
7
|
+
License: Apache Software License
|
|
8
|
+
Project-URL: homepage, https://github.com/jmlich/pretalx-gitlab-trigger
|
|
9
|
+
Project-URL: repository, https://github.com/jmlich/pretalx-gitlab-trigger.git
|
|
10
|
+
Keywords: pretalx
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/x-rst
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: djangofmt; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest; extra == "dev"
|
|
17
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest-django; extra == "dev"
|
|
19
|
+
Requires-Dist: ruff; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
GitLab pipeline trigger
|
|
23
|
+
=======================
|
|
24
|
+
|
|
25
|
+
This is a plugin for `pretalx`_. It starts a GitLab pipeline when:
|
|
26
|
+
|
|
27
|
+
- the schedule is released,
|
|
28
|
+
- a speaker or organiser adds, changes or deletes a session resource (slides),
|
|
29
|
+
- a PeerTube link from `pretalx-peertube`_ is added, changed or deleted.
|
|
30
|
+
|
|
31
|
+
The pipeline can download the new data from the pretalx API and rebuild a static website.
|
|
32
|
+
|
|
33
|
+
Configuration
|
|
34
|
+
-------------
|
|
35
|
+
|
|
36
|
+
1. In GitLab, create a pipeline trigger token in **Settings > CI/CD > Pipeline trigger tokens**.
|
|
37
|
+
2. Add the trigger URL to ``pretalx.cfg``::
|
|
38
|
+
|
|
39
|
+
[plugin:pretalx_gitlab_trigger]
|
|
40
|
+
url = https://gitlab.com/api/v4/projects/PROJECT_ID/ref/BRANCH/trigger/pipeline?token=TRIGGER_TOKEN
|
|
41
|
+
|
|
42
|
+
``PROJECT_ID`` is the numeric project ID or the URL-encoded path, for example ``OpenAlt%2Fopenalt-cz``.
|
|
43
|
+
3. Restart pretalx.
|
|
44
|
+
4. Enable the plugin in the event settings. Only events with the plugin enabled start the pipeline.
|
|
45
|
+
|
|
46
|
+
The plugin sends one POST request per change, after the database commit. A failed request is logged and does not
|
|
47
|
+
stop the change in pretalx.
|
|
48
|
+
|
|
49
|
+
Development
|
|
50
|
+
-----------
|
|
51
|
+
|
|
52
|
+
Run the tests with ``just test``.
|
|
53
|
+
|
|
54
|
+
.. _pretalx: https://github.com/pretalx/pretalx
|
|
55
|
+
.. _pretalx-peertube: https://github.com/jmlich/pretalx-peertube
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
GitLab pipeline trigger
|
|
2
|
+
=======================
|
|
3
|
+
|
|
4
|
+
This is a plugin for `pretalx`_. It starts a GitLab pipeline when:
|
|
5
|
+
|
|
6
|
+
- the schedule is released,
|
|
7
|
+
- a speaker or organiser adds, changes or deletes a session resource (slides),
|
|
8
|
+
- a PeerTube link from `pretalx-peertube`_ is added, changed or deleted.
|
|
9
|
+
|
|
10
|
+
The pipeline can download the new data from the pretalx API and rebuild a static website.
|
|
11
|
+
|
|
12
|
+
Configuration
|
|
13
|
+
-------------
|
|
14
|
+
|
|
15
|
+
1. In GitLab, create a pipeline trigger token in **Settings > CI/CD > Pipeline trigger tokens**.
|
|
16
|
+
2. Add the trigger URL to ``pretalx.cfg``::
|
|
17
|
+
|
|
18
|
+
[plugin:pretalx_gitlab_trigger]
|
|
19
|
+
url = https://gitlab.com/api/v4/projects/PROJECT_ID/ref/BRANCH/trigger/pipeline?token=TRIGGER_TOKEN
|
|
20
|
+
|
|
21
|
+
``PROJECT_ID`` is the numeric project ID or the URL-encoded path, for example ``OpenAlt%2Fopenalt-cz``.
|
|
22
|
+
3. Restart pretalx.
|
|
23
|
+
4. Enable the plugin in the event settings. Only events with the plugin enabled start the pipeline.
|
|
24
|
+
|
|
25
|
+
The plugin sends one POST request per change, after the database commit. A failed request is logged and does not
|
|
26
|
+
stop the change in pretalx.
|
|
27
|
+
|
|
28
|
+
Development
|
|
29
|
+
-----------
|
|
30
|
+
|
|
31
|
+
Run the tests with ``just test``.
|
|
32
|
+
|
|
33
|
+
.. _pretalx: https://github.com/pretalx/pretalx
|
|
34
|
+
.. _pretalx-peertube: https://github.com/jmlich/pretalx-peertube
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
set shell := ["bash", "-euo", "pipefail", "-c"]
|
|
2
|
+
set quiet
|
|
3
|
+
set fallback
|
|
4
|
+
set positional-arguments
|
|
5
|
+
set default-list
|
|
6
|
+
|
|
7
|
+
uv_dev := "uv run --extra=dev"
|
|
8
|
+
|
|
9
|
+
# Run ruff format
|
|
10
|
+
[group('linting')]
|
|
11
|
+
format *args=".":
|
|
12
|
+
{{ uv_dev }} ruff format "$@"
|
|
13
|
+
|
|
14
|
+
# Run ruff check
|
|
15
|
+
[group('linting')]
|
|
16
|
+
check *args=".":
|
|
17
|
+
{{ uv_dev }} ruff check "$@"
|
|
18
|
+
|
|
19
|
+
# Format Django templates with djangofmt.
|
|
20
|
+
[group('linting')]
|
|
21
|
+
djangofmt *args="":
|
|
22
|
+
-{{ uv_dev }} djangofmt {{ args }} .
|
|
23
|
+
|
|
24
|
+
[group('linting')]
|
|
25
|
+
djangofmt-check:
|
|
26
|
+
just djangofmt
|
|
27
|
+
git diff --exit-code -- '*.html' || (echo "HTML templates are not formatted. Run 'just djangofmt' to fix." && exit 1)
|
|
28
|
+
|
|
29
|
+
# Run all formatters and linters
|
|
30
|
+
[group('linting')]
|
|
31
|
+
[parallel]
|
|
32
|
+
fmt: format (check "--fix") djangofmt && fmt-done
|
|
33
|
+
|
|
34
|
+
[private]
|
|
35
|
+
fmt-done:
|
|
36
|
+
echo '{{ GREEN }}Formatting complete{{ NORMAL }}'
|
|
37
|
+
|
|
38
|
+
# Run all code quality checks
|
|
39
|
+
[group('linting')]
|
|
40
|
+
fmt-check: (format "--check") check djangofmt-check && check-done
|
|
41
|
+
|
|
42
|
+
[private]
|
|
43
|
+
check-done:
|
|
44
|
+
echo '{{ GREEN }}All checks passed{{ NORMAL }}'
|
|
45
|
+
|
|
46
|
+
# Run tests (installs pretalx if not already present)
|
|
47
|
+
[group('tests')]
|
|
48
|
+
test *args: ensure-pretalx
|
|
49
|
+
{{ uv_dev }} pytest "$@"
|
|
50
|
+
|
|
51
|
+
# Install pretalx from git
|
|
52
|
+
[group('development')]
|
|
53
|
+
install-pretalx:
|
|
54
|
+
uv pip install "pretalx[dev] @ git+https://github.com/pretalx/pretalx@main"
|
|
55
|
+
|
|
56
|
+
# Install a local editable copy of pretalx (for development)
|
|
57
|
+
[group('development')]
|
|
58
|
+
install-pretalx-local path:
|
|
59
|
+
uv pip install -e "{{ path }}[dev]"
|
|
60
|
+
|
|
61
|
+
# Ensure pretalx is importable, installing it from git if needed
|
|
62
|
+
[private]
|
|
63
|
+
ensure-pretalx:
|
|
64
|
+
{{ uv_dev }} python -c "import pretalx" 2>/dev/null || just install-pretalx
|
|
65
|
+
|
|
66
|
+
# Generate locale files
|
|
67
|
+
[group('development')]
|
|
68
|
+
[script('bash')]
|
|
69
|
+
localegen: ensure-pretalx
|
|
70
|
+
module=$(find . -maxdepth 1 -type d -name 'pretalx_*' -not -name '*.egg-info' | head -1)
|
|
71
|
+
{{ uv_dev }} django-admin makemessages --add-location file -i build -i dist -i "*egg*" $(find "$module/locale/" -mindepth 1 -maxdepth 1 -type d -printf "-l %f " 2>/dev/null)
|
|
72
|
+
|
|
73
|
+
# Compile locale files
|
|
74
|
+
[group('development')]
|
|
75
|
+
localecompile: ensure-pretalx
|
|
76
|
+
{{ uv_dev }} django-admin compilemessages
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from django.apps import AppConfig
|
|
2
|
+
from django.utils.translation import gettext_lazy
|
|
3
|
+
|
|
4
|
+
from . import __version__
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PluginApp(AppConfig):
|
|
8
|
+
name = "pretalx_gitlab_trigger"
|
|
9
|
+
verbose_name = "GitLab pipeline trigger"
|
|
10
|
+
|
|
11
|
+
class PretalxPluginMeta:
|
|
12
|
+
name = gettext_lazy("GitLab pipeline trigger")
|
|
13
|
+
author = "Jozef Mlich"
|
|
14
|
+
description = gettext_lazy(
|
|
15
|
+
"Start a GitLab pipeline when the schedule is released, or when slides or PeerTube links change."
|
|
16
|
+
)
|
|
17
|
+
visible = True
|
|
18
|
+
version = __version__
|
|
19
|
+
category = "INTEGRATION"
|
|
20
|
+
|
|
21
|
+
def ready(self):
|
|
22
|
+
from . import signals # noqa: F401, PLC0415
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import urllib.request
|
|
3
|
+
from functools import partial
|
|
4
|
+
|
|
5
|
+
from django.conf import settings
|
|
6
|
+
from django.db import transaction
|
|
7
|
+
from django.db.models.signals import post_delete, post_save
|
|
8
|
+
from django.dispatch import receiver
|
|
9
|
+
|
|
10
|
+
from pretalx.schedule.signals import schedule_release
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def trigger_pipeline(event):
|
|
16
|
+
if "pretalx_gitlab_trigger" not in event.plugin_list:
|
|
17
|
+
return
|
|
18
|
+
url = settings.PLUGIN_SETTINGS.get("pretalx_gitlab_trigger", {}).get("url")
|
|
19
|
+
if not url:
|
|
20
|
+
return
|
|
21
|
+
request = urllib.request.Request(url, method="POST") # noqa: S310 -- URL comes from pretalx.cfg
|
|
22
|
+
try:
|
|
23
|
+
with urllib.request.urlopen(request, timeout=10) as response: # noqa: S310
|
|
24
|
+
logger.info(
|
|
25
|
+
"GitLab trigger for event %s returned HTTP %s",
|
|
26
|
+
event.slug,
|
|
27
|
+
response.status,
|
|
28
|
+
)
|
|
29
|
+
except OSError:
|
|
30
|
+
# The URL contains the trigger token, so do not log the exception message.
|
|
31
|
+
logger.warning("GitLab trigger failed for event %s", event.slug)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@receiver(schedule_release, dispatch_uid="gitlab_trigger_schedule_release")
|
|
35
|
+
def on_schedule_release(sender, **kwargs):
|
|
36
|
+
trigger_pipeline(sender)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@receiver(
|
|
40
|
+
post_save, sender="submission.Resource", dispatch_uid="gitlab_trigger_resource_save"
|
|
41
|
+
)
|
|
42
|
+
@receiver(
|
|
43
|
+
post_delete,
|
|
44
|
+
sender="submission.Resource",
|
|
45
|
+
dispatch_uid="gitlab_trigger_resource_delete",
|
|
46
|
+
)
|
|
47
|
+
@receiver(
|
|
48
|
+
post_save,
|
|
49
|
+
sender="pretalx_peertube.PeertubeLink",
|
|
50
|
+
dispatch_uid="gitlab_trigger_peertube_save",
|
|
51
|
+
)
|
|
52
|
+
@receiver(
|
|
53
|
+
post_delete,
|
|
54
|
+
sender="pretalx_peertube.PeertubeLink",
|
|
55
|
+
dispatch_uid="gitlab_trigger_peertube_delete",
|
|
56
|
+
)
|
|
57
|
+
def on_talk_data_change(sender, instance, **kwargs):
|
|
58
|
+
# Send after the commit, so the pipeline already downloads the new data.
|
|
59
|
+
transaction.on_commit(partial(trigger_pipeline, instance.submission.event))
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pretalx-gitlab-trigger
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Start a GitLab pipeline when the schedule, slides or PeerTube links change.
|
|
5
|
+
Author-email: Jozef Mlich <jmlich83@gmail.com>
|
|
6
|
+
Maintainer-email: Jozef Mlich <jmlich83@gmail.com>
|
|
7
|
+
License: Apache Software License
|
|
8
|
+
Project-URL: homepage, https://github.com/jmlich/pretalx-gitlab-trigger
|
|
9
|
+
Project-URL: repository, https://github.com/jmlich/pretalx-gitlab-trigger.git
|
|
10
|
+
Keywords: pretalx
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/x-rst
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: djangofmt; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest; extra == "dev"
|
|
17
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest-django; extra == "dev"
|
|
19
|
+
Requires-Dist: ruff; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
GitLab pipeline trigger
|
|
23
|
+
=======================
|
|
24
|
+
|
|
25
|
+
This is a plugin for `pretalx`_. It starts a GitLab pipeline when:
|
|
26
|
+
|
|
27
|
+
- the schedule is released,
|
|
28
|
+
- a speaker or organiser adds, changes or deletes a session resource (slides),
|
|
29
|
+
- a PeerTube link from `pretalx-peertube`_ is added, changed or deleted.
|
|
30
|
+
|
|
31
|
+
The pipeline can download the new data from the pretalx API and rebuild a static website.
|
|
32
|
+
|
|
33
|
+
Configuration
|
|
34
|
+
-------------
|
|
35
|
+
|
|
36
|
+
1. In GitLab, create a pipeline trigger token in **Settings > CI/CD > Pipeline trigger tokens**.
|
|
37
|
+
2. Add the trigger URL to ``pretalx.cfg``::
|
|
38
|
+
|
|
39
|
+
[plugin:pretalx_gitlab_trigger]
|
|
40
|
+
url = https://gitlab.com/api/v4/projects/PROJECT_ID/ref/BRANCH/trigger/pipeline?token=TRIGGER_TOKEN
|
|
41
|
+
|
|
42
|
+
``PROJECT_ID`` is the numeric project ID or the URL-encoded path, for example ``OpenAlt%2Fopenalt-cz``.
|
|
43
|
+
3. Restart pretalx.
|
|
44
|
+
4. Enable the plugin in the event settings. Only events with the plugin enabled start the pipeline.
|
|
45
|
+
|
|
46
|
+
The plugin sends one POST request per change, after the database commit. A failed request is logged and does not
|
|
47
|
+
stop the change in pretalx.
|
|
48
|
+
|
|
49
|
+
Development
|
|
50
|
+
-----------
|
|
51
|
+
|
|
52
|
+
Run the tests with ``just test``.
|
|
53
|
+
|
|
54
|
+
.. _pretalx: https://github.com/pretalx/pretalx
|
|
55
|
+
.. _pretalx-peertube: https://github.com/jmlich/pretalx-peertube
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.rst
|
|
4
|
+
justfile
|
|
5
|
+
pyproject.toml
|
|
6
|
+
pretalx_gitlab_trigger/__init__.py
|
|
7
|
+
pretalx_gitlab_trigger/apps.py
|
|
8
|
+
pretalx_gitlab_trigger/signals.py
|
|
9
|
+
pretalx_gitlab_trigger.egg-info/PKG-INFO
|
|
10
|
+
pretalx_gitlab_trigger.egg-info/SOURCES.txt
|
|
11
|
+
pretalx_gitlab_trigger.egg-info/dependency_links.txt
|
|
12
|
+
pretalx_gitlab_trigger.egg-info/entry_points.txt
|
|
13
|
+
pretalx_gitlab_trigger.egg-info/requires.txt
|
|
14
|
+
pretalx_gitlab_trigger.egg-info/top_level.txt
|
|
15
|
+
tests/test_signals.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pretalx_gitlab_trigger
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pretalx-gitlab-trigger"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Start a GitLab pipeline when the schedule, slides or PeerTube links change."
|
|
5
|
+
readme = "README.rst"
|
|
6
|
+
license = {text = "Apache Software License"}
|
|
7
|
+
keywords = ["pretalx"]
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Jozef Mlich", email = "jmlich83@gmail.com"},
|
|
10
|
+
]
|
|
11
|
+
maintainers = [
|
|
12
|
+
{name = "Jozef Mlich", email = "jmlich83@gmail.com"},
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
requires-python = ">=3.11"
|
|
16
|
+
dependencies = []
|
|
17
|
+
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
dev = [
|
|
20
|
+
"djangofmt",
|
|
21
|
+
"pytest",
|
|
22
|
+
"pytest-cov",
|
|
23
|
+
"pytest-django",
|
|
24
|
+
"ruff",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
homepage = "https://github.com/jmlich/pretalx-gitlab-trigger"
|
|
29
|
+
repository = "https://github.com/jmlich/pretalx-gitlab-trigger.git"
|
|
30
|
+
|
|
31
|
+
[project.entry-points."pretalx.plugin"]
|
|
32
|
+
pretalx_gitlab_trigger = "pretalx_gitlab_trigger:PretalxPluginMeta"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
build-backend = "setuptools.build_meta"
|
|
36
|
+
requires = ["setuptools"]
|
|
37
|
+
|
|
38
|
+
[tool.setuptools]
|
|
39
|
+
include-package-data = true
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.dynamic]
|
|
42
|
+
version = {attr = "pretalx_gitlab_trigger.__version__"}
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.packages.find]
|
|
45
|
+
include = ["pretalx*"]
|
|
46
|
+
|
|
47
|
+
[tool.check-manifest]
|
|
48
|
+
ignore = [".*", "tests/*", "tools/*", "justfile"]
|
|
49
|
+
|
|
50
|
+
[tool.pytest.ini_options]
|
|
51
|
+
DJANGO_SETTINGS_MODULE = "pretalx.common.settings.test_settings"
|
|
52
|
+
django_find_project = false
|
|
53
|
+
testpaths = "tests"
|
|
54
|
+
addopts = "--cov=pretalx_gitlab_trigger --cov-report=term-missing:skip-covered --cov-config=pyproject.toml"
|
|
55
|
+
|
|
56
|
+
[tool.coverage.run]
|
|
57
|
+
branch = true
|
|
58
|
+
relative_files = true
|
|
59
|
+
source = ["pretalx_gitlab_trigger"]
|
|
60
|
+
omit = ["*/migrations/*", "*/urls.py", "*/tests/*"]
|
|
61
|
+
|
|
62
|
+
[tool.coverage.report]
|
|
63
|
+
exclude_also = [
|
|
64
|
+
"def __repr__",
|
|
65
|
+
"def __str__",
|
|
66
|
+
"if settings.DEBUG",
|
|
67
|
+
"NOQA",
|
|
68
|
+
"noqa",
|
|
69
|
+
"NotImplementedError",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.ruff.format]
|
|
73
|
+
skip-magic-trailing-comma = true
|
|
74
|
+
|
|
75
|
+
[tool.ruff.lint]
|
|
76
|
+
select = ["ALL"]
|
|
77
|
+
ignore = [
|
|
78
|
+
"ANN", # We do not do annotations
|
|
79
|
+
"ARG", # Unused method arguments are often ok
|
|
80
|
+
"C901", # We do do complexity
|
|
81
|
+
"COM812", # Trailing commas are formatter territory
|
|
82
|
+
"CPY", # We do not use copyright header notices
|
|
83
|
+
"D", # We do not enforce docstyles
|
|
84
|
+
"DJ001", # We live in a state of sin
|
|
85
|
+
"E501", # Long lines are formatter territory
|
|
86
|
+
"EM", # Formatting strings is fine, actually
|
|
87
|
+
"FBT", # Booleans are fine, actually
|
|
88
|
+
"FIX", # TODO comments are fine, actually
|
|
89
|
+
"PLR", # Refactoring: Too many branches, arguments, statements, etc
|
|
90
|
+
"RET502", # Just returning is fine, actually
|
|
91
|
+
"RET503", # Just not returning is fine, actually
|
|
92
|
+
"RUF012", # Mutable default in class attribute is just how django rolls
|
|
93
|
+
"RUF100", # Unused noqa; problematic when run in isolation
|
|
94
|
+
"TRY003", # Error messages are fine, actually
|
|
95
|
+
]
|
|
96
|
+
allowed-confusables = ["–", "'", "×"]
|
|
97
|
+
|
|
98
|
+
[tool.ruff.lint.per-file-ignores]
|
|
99
|
+
"tools/**.py" = [
|
|
100
|
+
"DTZ", # Local time is fine in a manual test tool
|
|
101
|
+
"INP001", # Scripts, not a package
|
|
102
|
+
"T201", # Printing is the point of the tool
|
|
103
|
+
]
|
|
104
|
+
"tests/**.py" = [
|
|
105
|
+
"DTZ", # TODO: do not use naive datetimes in tests
|
|
106
|
+
"INP001", # Tests don't need __init__.py
|
|
107
|
+
"RUF", # Ignore ambiguous characters in tests, may be security tests
|
|
108
|
+
"S", # Tests do not need cryptographic randomness and other security features
|
|
109
|
+
"S101", # Ignore `assert` rules in tests
|
|
110
|
+
"SLF001", # TODO: remove SLF001, fix private access
|
|
111
|
+
"TRY", # Exception handling is special in tests
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
[tool.ruff.lint.flake8-pytest-style]
|
|
115
|
+
parametrize-values-type = "tuple"
|
|
116
|
+
|
|
117
|
+
[tool.ruff.lint.flake8-self]
|
|
118
|
+
extend-ignore-names = ["_base_manager", "_default_manager", "_meta"]
|
|
119
|
+
|
|
120
|
+
[tool.ruff.lint.isort]
|
|
121
|
+
split-on-trailing-comma = false
|
|
122
|
+
section-order = ["future", "standard-library", "third-party", "pretalx", "first-party", "local-folder"]
|
|
123
|
+
|
|
124
|
+
[tool.ruff.lint.isort.sections]
|
|
125
|
+
pretalx = ["pretalx"]
|
|
126
|
+
|
|
127
|
+
[tool.ruff.lint.pep8-naming]
|
|
128
|
+
extend-ignore-names = [
|
|
129
|
+
"allDay",
|
|
130
|
+
"api_urls",
|
|
131
|
+
"EventSettings",
|
|
132
|
+
"extendMarkdown",
|
|
133
|
+
"get_allDay",
|
|
134
|
+
"orga_urls",
|
|
135
|
+
"SendMailException",
|
|
136
|
+
"setUpTestData",
|
|
137
|
+
"urls",
|
|
138
|
+
]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from django.core.files.uploadedfile import SimpleUploadedFile
|
|
5
|
+
from django_scopes import scope
|
|
6
|
+
|
|
7
|
+
from pretalx.event.models import Event
|
|
8
|
+
from pretalx.schedule.domain.release import freeze_schedule
|
|
9
|
+
from pretalx.submission.models import Resource
|
|
10
|
+
|
|
11
|
+
from pretalx_gitlab_trigger import signals
|
|
12
|
+
|
|
13
|
+
pytestmark = pytest.mark.django_db
|
|
14
|
+
|
|
15
|
+
TRIGGER_URL = "https://gitlab.example.org/api/v4/projects/1/ref/main/trigger/pipeline?token=secret"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.fixture
|
|
19
|
+
def trigger_url(settings):
|
|
20
|
+
settings.PLUGIN_SETTINGS = {"pretalx_gitlab_trigger": {"url": TRIGGER_URL}}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def sent_urls(urlopen):
|
|
24
|
+
return [call.args[0].full_url for call in urlopen.call_args_list]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_schedule_release_triggers_pipeline(event, trigger_url):
|
|
28
|
+
with patch.object(signals.urllib.request, "urlopen") as urlopen, scope(event=event):
|
|
29
|
+
freeze_schedule(event.wip_schedule, name="v1")
|
|
30
|
+
assert sent_urls(urlopen) == [TRIGGER_URL]
|
|
31
|
+
assert urlopen.call_args.args[0].method == "POST"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_resource_changes_trigger_pipeline(
|
|
35
|
+
event, confirmed_submission, trigger_url, django_capture_on_commit_callbacks
|
|
36
|
+
):
|
|
37
|
+
with (
|
|
38
|
+
patch.object(signals.urllib.request, "urlopen") as urlopen,
|
|
39
|
+
django_capture_on_commit_callbacks(execute=True),
|
|
40
|
+
scope(event=event),
|
|
41
|
+
):
|
|
42
|
+
resource = Resource.objects.create(
|
|
43
|
+
submission=confirmed_submission,
|
|
44
|
+
resource=SimpleUploadedFile("slides.pdf", b"%PDF-1.4"),
|
|
45
|
+
description="Slides",
|
|
46
|
+
)
|
|
47
|
+
resource.description = "New slides"
|
|
48
|
+
resource.save()
|
|
49
|
+
resource.delete()
|
|
50
|
+
assert sent_urls(urlopen) == [TRIGGER_URL] * 3
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_peertube_link_changes_trigger_pipeline(
|
|
54
|
+
event, confirmed_submission, trigger_url, django_capture_on_commit_callbacks
|
|
55
|
+
):
|
|
56
|
+
peertube_models = pytest.importorskip("pretalx_peertube.models")
|
|
57
|
+
with (
|
|
58
|
+
patch.object(signals.urllib.request, "urlopen") as urlopen,
|
|
59
|
+
django_capture_on_commit_callbacks(execute=True),
|
|
60
|
+
):
|
|
61
|
+
link = peertube_models.PeertubeLink.objects.create(
|
|
62
|
+
submission=confirmed_submission, link="https://peertube.example.org/w/abc"
|
|
63
|
+
)
|
|
64
|
+
link.delete()
|
|
65
|
+
assert sent_urls(urlopen) == [TRIGGER_URL] * 2
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_inactive_plugin_does_not_trigger(event, trigger_url):
|
|
69
|
+
Event.objects.filter(pk=event.pk).update(plugins="")
|
|
70
|
+
event.refresh_from_db()
|
|
71
|
+
with patch.object(signals.urllib.request, "urlopen") as urlopen:
|
|
72
|
+
signals.trigger_pipeline(event)
|
|
73
|
+
urlopen.assert_not_called()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_missing_url_does_not_trigger(event, settings):
|
|
77
|
+
settings.PLUGIN_SETTINGS = {}
|
|
78
|
+
with patch.object(signals.urllib.request, "urlopen") as urlopen:
|
|
79
|
+
signals.trigger_pipeline(event)
|
|
80
|
+
urlopen.assert_not_called()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_failed_request_is_logged_without_token(event, trigger_url, caplog):
|
|
84
|
+
with patch.object(
|
|
85
|
+
signals.urllib.request, "urlopen", side_effect=OSError(TRIGGER_URL)
|
|
86
|
+
):
|
|
87
|
+
signals.trigger_pipeline(event)
|
|
88
|
+
assert "GitLab trigger failed for event test" in caplog.text
|
|
89
|
+
assert "secret" not in caplog.text
|