emberpost 0.1.0__tar.gz → 0.2.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.
- emberpost-0.2.0/LICENSE +21 -0
- emberpost-0.1.0/README.md → emberpost-0.2.0/PKG-INFO +81 -21
- emberpost-0.1.0/PKG-INFO → emberpost-0.2.0/README.md +54 -32
- emberpost-0.2.0/pyproject.toml +116 -0
- emberpost-0.2.0/pyproject.toml.orig +101 -0
- emberpost-0.2.0/src/emberpost/cli.py +71 -0
- {emberpost-0.1.0 → emberpost-0.2.0}/src/emberpost/pagerduty.py +6 -0
- emberpost-0.2.0/src/emberpost/post.py +288 -0
- {emberpost-0.1.0 → emberpost-0.2.0}/src/emberpost/schedule_config.py +59 -18
- emberpost-0.2.0/src/emberpost/schemas/schedule.schema.json +270 -0
- {emberpost-0.1.0 → emberpost-0.2.0}/src/emberpost/slack.py +12 -6
- emberpost-0.1.0/pyproject.toml +0 -92
- emberpost-0.1.0/src/emberpost/post.py +0 -233
- {emberpost-0.1.0 → emberpost-0.2.0}/src/emberpost/__init__.py +0 -0
emberpost-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JSChronicles
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: emberpost
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Dispatch PagerDuty on-call schedules to Slack.
|
|
5
|
+
Author: JSChronicles
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: System Administrators
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: Communications :: Chat
|
|
16
|
+
Classifier: Topic :: System :: Monitoring
|
|
17
|
+
Requires-Dist: jsonschema>=4.26.0,<4.30.0
|
|
18
|
+
Requires-Dist: pagerduty>=7.0.1
|
|
19
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
20
|
+
Requires-Dist: slack-sdk>=3.44.1
|
|
21
|
+
Requires-Python: >=3.14, <3.15
|
|
22
|
+
Project-URL: Homepage, https://github.com/JSChronicles/emberpost
|
|
23
|
+
Project-URL: Repository, https://github.com/JSChronicles/emberpost
|
|
24
|
+
Project-URL: Issues, https://github.com/JSChronicles/emberpost/issues
|
|
25
|
+
Project-URL: Documentation, https://opsfoundry.dev/emberpost/
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
1
28
|
# emberpost
|
|
2
29
|
|
|
3
30
|
<a name="readme-top"></a>
|
|
@@ -5,6 +32,8 @@
|
|
|
5
32
|
<!-- PROJECT SHIELDS -->
|
|
6
33
|
[![pytest][pytest-badge]][pytest-url]
|
|
7
34
|
[![ruff][ruff-badge]][ruff-url]
|
|
35
|
+
[![release][release-badge]][release-url]
|
|
36
|
+
[![PyPI][pypi-badge]][pypi-url]
|
|
8
37
|
[![prek][prek-badge]][prek-url]
|
|
9
38
|
|
|
10
39
|
|
|
@@ -34,45 +63,42 @@ Use it to post an on-call summary, update a channel topic, or keep a Slack user
|
|
|
34
63
|
Start with [examples/01-minimal.yaml](examples/01-minimal.yaml) for the smallest working schedule shape, then add channel topics, user groups, headers, or footers as needed.
|
|
35
64
|
|
|
36
65
|
## Usage
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
1. uv run:
|
|
46
|
-
1. Run a command in the project environment.: `uv run example.py <args>`
|
|
47
|
-
1. uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run
|
|
48
|
-
1. Note that if you use uv run in a project, i.e. a directory with a pyproject.toml, it will install the current project before running the script.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- The `--frequency` flag is a guardrail for automation. A schedule file marked `weekly` is skipped when the command runs with `--frequency daily`, which lets daily and weekly jobs share the same command shape.
|
|
52
|
-
- Set `slack.set_channel_topic: true` in the schedule file to update the channel topic instead of posting a message:
|
|
66
|
+
|
|
67
|
+
Install the project and its dependencies with [uv](https://docs.astral.sh/uv/):
|
|
68
|
+
|
|
69
|
+
```console
|
|
70
|
+
uv sync
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Commands can then be run through `uv run`, which uses the project environment automatically. The `--frequency` flag is an automation guardrail: a `weekly` schedule is skipped during a `daily` run. Set `slack.set_channel_topic: true` to update a channel topic instead of posting a message.
|
|
53
74
|
|
|
54
75
|
Run a dry run before writing to Slack:
|
|
55
|
-
|
|
76
|
+
|
|
77
|
+
```console
|
|
56
78
|
uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run
|
|
57
79
|
```
|
|
58
80
|
|
|
59
81
|
Run the weekly schedule and update Slack:
|
|
60
|
-
|
|
82
|
+
|
|
83
|
+
```console
|
|
61
84
|
uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly
|
|
62
85
|
```
|
|
63
86
|
|
|
64
87
|
Process more than one schedule file in a single run:
|
|
65
|
-
|
|
88
|
+
|
|
89
|
+
```console
|
|
66
90
|
uv run emberpost --schedule-file schedules/oncall.yaml examples/03-full.yaml --frequency weekly
|
|
67
91
|
```
|
|
68
92
|
|
|
69
93
|
Run a manual schedule file:
|
|
70
|
-
|
|
94
|
+
|
|
95
|
+
```console
|
|
71
96
|
uv run emberpost --schedule-file examples/01-minimal.yaml --frequency manual --dry-run
|
|
72
97
|
```
|
|
73
98
|
|
|
74
99
|
Run with more logging while troubleshooting:
|
|
75
|
-
|
|
100
|
+
|
|
101
|
+
```console
|
|
76
102
|
uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run --log-level DEBUG
|
|
77
103
|
```
|
|
78
104
|
|
|
@@ -91,6 +117,36 @@ pagerduty:
|
|
|
91
117
|
label: "Backup Responder"
|
|
92
118
|
```
|
|
93
119
|
|
|
120
|
+
The top-level `slack` block is the default destination for every schedule group.
|
|
121
|
+
Any group can override `slack_space`, `slack_channel_id`, or
|
|
122
|
+
`set_channel_topic`; values omitted from the group inherit from the top-level
|
|
123
|
+
block:
|
|
124
|
+
|
|
125
|
+
```yaml
|
|
126
|
+
pagerduty:
|
|
127
|
+
tenant: example.pagerduty.com
|
|
128
|
+
schedule_groups:
|
|
129
|
+
Platform Coverage:
|
|
130
|
+
entries:
|
|
131
|
+
- schedule_id: PEXAMPLE1
|
|
132
|
+
label: "Primary Responder"
|
|
133
|
+
Database Coverage:
|
|
134
|
+
slack_space: database-team.slack.com
|
|
135
|
+
slack_channel_id: C0987654321
|
|
136
|
+
set_channel_topic: true
|
|
137
|
+
entries:
|
|
138
|
+
- schedule_id: PEXAMPLE2
|
|
139
|
+
label: "Database Responder"
|
|
140
|
+
|
|
141
|
+
slack:
|
|
142
|
+
slack_space: example.slack.com
|
|
143
|
+
slack_channel_id: C0123456789
|
|
144
|
+
set_channel_topic: false
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Here, `Platform Coverage` uses all three top-level defaults. `Database Coverage`
|
|
148
|
+
uses its own workspace and channel and updates that channel's topic.
|
|
149
|
+
|
|
94
150
|
## Setting up your Slack Bot
|
|
95
151
|
|
|
96
152
|
### Bot Information
|
|
@@ -169,6 +225,10 @@ settings:
|
|
|
169
225
|
[pytest-url]:https://github.com/JSChronicles/emberpost/actions/workflows/pytest.yaml
|
|
170
226
|
[ruff-badge]:https://github.com/JSChronicles/emberpost/actions/workflows/ruff.yaml/badge.svg?branch=main
|
|
171
227
|
[ruff-url]:https://github.com/JSChronicles/emberpost/actions/workflows/ruff.yaml
|
|
228
|
+
[release-badge]:https://github.com/JSChronicles/emberpost/actions/workflows/release.yaml/badge.svg?branch=main
|
|
229
|
+
[release-url]:https://github.com/JSChronicles/emberpost/actions/workflows/release.yaml
|
|
230
|
+
[pypi-badge]:https://img.shields.io/pypi/v/emberpost
|
|
231
|
+
[pypi-url]:https://pypi.org/project/emberpost/
|
|
172
232
|
|
|
173
233
|
[prek-badge]:https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json
|
|
174
234
|
[prek-url]:https://github.com/j178/prek
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: emberpost
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Dispatch PagerDuty on-call schedules to Slack.
|
|
5
|
-
Requires-Dist: jsonschema
|
|
6
|
-
Requires-Dist: pagerduty>=6.2.1
|
|
7
|
-
Requires-Dist: pyyaml>=6.0.3
|
|
8
|
-
Requires-Dist: slack-sdk>=3.41.0
|
|
9
|
-
Requires-Python: >=3.14, <3.15
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
|
|
12
1
|
# emberpost
|
|
13
2
|
|
|
14
3
|
<a name="readme-top"></a>
|
|
@@ -16,6 +5,8 @@ Description-Content-Type: text/markdown
|
|
|
16
5
|
<!-- PROJECT SHIELDS -->
|
|
17
6
|
[![pytest][pytest-badge]][pytest-url]
|
|
18
7
|
[![ruff][ruff-badge]][ruff-url]
|
|
8
|
+
[![release][release-badge]][release-url]
|
|
9
|
+
[![PyPI][pypi-badge]][pypi-url]
|
|
19
10
|
[![prek][prek-badge]][prek-url]
|
|
20
11
|
|
|
21
12
|
|
|
@@ -45,45 +36,42 @@ Use it to post an on-call summary, update a channel topic, or keep a Slack user
|
|
|
45
36
|
Start with [examples/01-minimal.yaml](examples/01-minimal.yaml) for the smallest working schedule shape, then add channel topics, user groups, headers, or footers as needed.
|
|
46
37
|
|
|
47
38
|
## Usage
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
1. uv run:
|
|
57
|
-
1. Run a command in the project environment.: `uv run example.py <args>`
|
|
58
|
-
1. uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run
|
|
59
|
-
1. Note that if you use uv run in a project, i.e. a directory with a pyproject.toml, it will install the current project before running the script.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- The `--frequency` flag is a guardrail for automation. A schedule file marked `weekly` is skipped when the command runs with `--frequency daily`, which lets daily and weekly jobs share the same command shape.
|
|
63
|
-
- Set `slack.set_channel_topic: true` in the schedule file to update the channel topic instead of posting a message:
|
|
39
|
+
|
|
40
|
+
Install the project and its dependencies with [uv](https://docs.astral.sh/uv/):
|
|
41
|
+
|
|
42
|
+
```console
|
|
43
|
+
uv sync
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Commands can then be run through `uv run`, which uses the project environment automatically. The `--frequency` flag is an automation guardrail: a `weekly` schedule is skipped during a `daily` run. Set `slack.set_channel_topic: true` to update a channel topic instead of posting a message.
|
|
64
47
|
|
|
65
48
|
Run a dry run before writing to Slack:
|
|
66
|
-
|
|
49
|
+
|
|
50
|
+
```console
|
|
67
51
|
uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run
|
|
68
52
|
```
|
|
69
53
|
|
|
70
54
|
Run the weekly schedule and update Slack:
|
|
71
|
-
|
|
55
|
+
|
|
56
|
+
```console
|
|
72
57
|
uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly
|
|
73
58
|
```
|
|
74
59
|
|
|
75
60
|
Process more than one schedule file in a single run:
|
|
76
|
-
|
|
61
|
+
|
|
62
|
+
```console
|
|
77
63
|
uv run emberpost --schedule-file schedules/oncall.yaml examples/03-full.yaml --frequency weekly
|
|
78
64
|
```
|
|
79
65
|
|
|
80
66
|
Run a manual schedule file:
|
|
81
|
-
|
|
67
|
+
|
|
68
|
+
```console
|
|
82
69
|
uv run emberpost --schedule-file examples/01-minimal.yaml --frequency manual --dry-run
|
|
83
70
|
```
|
|
84
71
|
|
|
85
72
|
Run with more logging while troubleshooting:
|
|
86
|
-
|
|
73
|
+
|
|
74
|
+
```console
|
|
87
75
|
uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run --log-level DEBUG
|
|
88
76
|
```
|
|
89
77
|
|
|
@@ -102,6 +90,36 @@ pagerduty:
|
|
|
102
90
|
label: "Backup Responder"
|
|
103
91
|
```
|
|
104
92
|
|
|
93
|
+
The top-level `slack` block is the default destination for every schedule group.
|
|
94
|
+
Any group can override `slack_space`, `slack_channel_id`, or
|
|
95
|
+
`set_channel_topic`; values omitted from the group inherit from the top-level
|
|
96
|
+
block:
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
pagerduty:
|
|
100
|
+
tenant: example.pagerduty.com
|
|
101
|
+
schedule_groups:
|
|
102
|
+
Platform Coverage:
|
|
103
|
+
entries:
|
|
104
|
+
- schedule_id: PEXAMPLE1
|
|
105
|
+
label: "Primary Responder"
|
|
106
|
+
Database Coverage:
|
|
107
|
+
slack_space: database-team.slack.com
|
|
108
|
+
slack_channel_id: C0987654321
|
|
109
|
+
set_channel_topic: true
|
|
110
|
+
entries:
|
|
111
|
+
- schedule_id: PEXAMPLE2
|
|
112
|
+
label: "Database Responder"
|
|
113
|
+
|
|
114
|
+
slack:
|
|
115
|
+
slack_space: example.slack.com
|
|
116
|
+
slack_channel_id: C0123456789
|
|
117
|
+
set_channel_topic: false
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Here, `Platform Coverage` uses all three top-level defaults. `Database Coverage`
|
|
121
|
+
uses its own workspace and channel and updates that channel's topic.
|
|
122
|
+
|
|
105
123
|
## Setting up your Slack Bot
|
|
106
124
|
|
|
107
125
|
### Bot Information
|
|
@@ -180,6 +198,10 @@ settings:
|
|
|
180
198
|
[pytest-url]:https://github.com/JSChronicles/emberpost/actions/workflows/pytest.yaml
|
|
181
199
|
[ruff-badge]:https://github.com/JSChronicles/emberpost/actions/workflows/ruff.yaml/badge.svg?branch=main
|
|
182
200
|
[ruff-url]:https://github.com/JSChronicles/emberpost/actions/workflows/ruff.yaml
|
|
201
|
+
[release-badge]:https://github.com/JSChronicles/emberpost/actions/workflows/release.yaml/badge.svg?branch=main
|
|
202
|
+
[release-url]:https://github.com/JSChronicles/emberpost/actions/workflows/release.yaml
|
|
203
|
+
[pypi-badge]:https://img.shields.io/pypi/v/emberpost
|
|
204
|
+
[pypi-url]:https://pypi.org/project/emberpost/
|
|
183
205
|
|
|
184
206
|
[prek-badge]:https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json
|
|
185
207
|
[prek-url]:https://github.com/j178/prek
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.12.15,<0.14"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "emberpost"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Dispatch PagerDuty on-call schedules to Slack."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.14,<3.15"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: System Administrators",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Topic :: Communications :: Chat",
|
|
22
|
+
"Topic :: System :: Monitoring",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"jsonschema>=4.26.0,<4.30.0",
|
|
26
|
+
"pagerduty>=7.0.1",
|
|
27
|
+
"pyyaml>=6.0.3",
|
|
28
|
+
"slack-sdk>=3.44.1",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "JSChronicles"
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/JSChronicles/emberpost"
|
|
36
|
+
Repository = "https://github.com/JSChronicles/emberpost"
|
|
37
|
+
Issues = "https://github.com/JSChronicles/emberpost/issues"
|
|
38
|
+
Documentation = "https://opsfoundry.dev/emberpost/"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
emberpost = "emberpost.cli:main"
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest-cov>=7.1.0,<8.0.0",
|
|
46
|
+
"pytest>=9.1.1,<10.0.0",
|
|
47
|
+
"prek>=0.4.12,<0.6.0",
|
|
48
|
+
"ruff>=0.16.0,<0.20.0",
|
|
49
|
+
"ty>=0.0.60,<0.20.0",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
pythonpath = "src"
|
|
54
|
+
addopts = "-s -v --cov=emberpost --cov-report=term-missing --cov-fail-under=50"
|
|
55
|
+
norecursedirs = [
|
|
56
|
+
".git",
|
|
57
|
+
"__pycache__",
|
|
58
|
+
".venv",
|
|
59
|
+
]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
|
|
62
|
+
[tool.coverage.run]
|
|
63
|
+
omit = ["tests/*"]
|
|
64
|
+
|
|
65
|
+
[tool.semantic_release]
|
|
66
|
+
allow_zero_version = true
|
|
67
|
+
build_command = """
|
|
68
|
+
uv lock --upgrade-package emberpost
|
|
69
|
+
git add uv.lock
|
|
70
|
+
"""
|
|
71
|
+
commit_message = """
|
|
72
|
+
chore(release): v{version}
|
|
73
|
+
|
|
74
|
+
Automatically generated by python-semantic-release"""
|
|
75
|
+
commit_parser = "conventional"
|
|
76
|
+
major_on_zero = false
|
|
77
|
+
tag_format = "v{version}"
|
|
78
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
79
|
+
|
|
80
|
+
[tool.semantic_release.branches.main]
|
|
81
|
+
match = "main"
|
|
82
|
+
prerelease = false
|
|
83
|
+
|
|
84
|
+
[tool.semantic_release.changelog]
|
|
85
|
+
mode = "update"
|
|
86
|
+
template_dir = ".semantic_release/changelog_templates"
|
|
87
|
+
|
|
88
|
+
[tool.semantic_release.changelog.default_templates]
|
|
89
|
+
changelog_file = "CHANGELOG.md"
|
|
90
|
+
output_format = "md"
|
|
91
|
+
|
|
92
|
+
[tool.ruff]
|
|
93
|
+
target-version = "py314"
|
|
94
|
+
|
|
95
|
+
[tool.ruff.lint]
|
|
96
|
+
select = [
|
|
97
|
+
"N",
|
|
98
|
+
"E4",
|
|
99
|
+
"E7",
|
|
100
|
+
"E9",
|
|
101
|
+
"F",
|
|
102
|
+
]
|
|
103
|
+
task-tags = [
|
|
104
|
+
"TODO",
|
|
105
|
+
"FIXME",
|
|
106
|
+
"HACK",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[tool.ruff.format]
|
|
110
|
+
skip-magic-trailing-comma = true
|
|
111
|
+
|
|
112
|
+
[tool.uv]
|
|
113
|
+
exclude-newer = "1 week"
|
|
114
|
+
|
|
115
|
+
[tool.uv.exclude-newer-package]
|
|
116
|
+
uv-build = false
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.12.15,<0.14"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "emberpost"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Dispatch PagerDuty on-call schedules to Slack."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.14,<3.15"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "JSChronicles" },
|
|
13
|
+
]
|
|
14
|
+
license = "MIT"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: System Administrators",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Communications :: Chat",
|
|
25
|
+
"Topic :: System :: Monitoring",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"jsonschema>=4.26.0,<4.30.0",
|
|
29
|
+
"pagerduty>=7.0.1",
|
|
30
|
+
"pyyaml>=6.0.3",
|
|
31
|
+
"slack-sdk>=3.44.1",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/JSChronicles/emberpost"
|
|
36
|
+
Repository = "https://github.com/JSChronicles/emberpost"
|
|
37
|
+
Issues = "https://github.com/JSChronicles/emberpost/issues"
|
|
38
|
+
Documentation = "https://opsfoundry.dev/emberpost/"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
emberpost = "emberpost.cli:main"
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest-cov>=7.1.0,<8.0.0",
|
|
46
|
+
"pytest>=9.1.1,<10.0.0",
|
|
47
|
+
"prek>=0.4.12,<0.6.0",
|
|
48
|
+
"ruff>=0.16.0,<0.20.0",
|
|
49
|
+
"ty>=0.0.60,<0.20.0",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
pythonpath = "src"
|
|
54
|
+
addopts = "-s -v --cov=emberpost --cov-report=term-missing --cov-fail-under=50"
|
|
55
|
+
norecursedirs = [".git", "__pycache__", ".venv"]
|
|
56
|
+
testpaths = ["tests"]
|
|
57
|
+
|
|
58
|
+
[tool.coverage.run]
|
|
59
|
+
omit = [
|
|
60
|
+
"tests/*",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
# Keep release assets empty; update and stage uv.lock without uploading it.
|
|
64
|
+
[tool.semantic_release]
|
|
65
|
+
allow_zero_version = true
|
|
66
|
+
build_command = """
|
|
67
|
+
uv lock --upgrade-package emberpost
|
|
68
|
+
git add uv.lock
|
|
69
|
+
"""
|
|
70
|
+
commit_message = "chore(release): v{version}\n\nAutomatically generated by python-semantic-release"
|
|
71
|
+
commit_parser = "conventional"
|
|
72
|
+
major_on_zero = false
|
|
73
|
+
tag_format = "v{version}"
|
|
74
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
75
|
+
|
|
76
|
+
[tool.semantic_release.branches.main]
|
|
77
|
+
match = "main"
|
|
78
|
+
prerelease = false
|
|
79
|
+
|
|
80
|
+
[tool.semantic_release.changelog]
|
|
81
|
+
mode = "update"
|
|
82
|
+
template_dir = ".semantic_release/changelog_templates"
|
|
83
|
+
|
|
84
|
+
[tool.semantic_release.changelog.default_templates]
|
|
85
|
+
changelog_file = "CHANGELOG.md"
|
|
86
|
+
output_format = "md"
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
[tool.ruff]
|
|
90
|
+
target-version = "py314"
|
|
91
|
+
|
|
92
|
+
[tool.ruff.lint]
|
|
93
|
+
select = ["N", "E4", "E7", "E9", "F"]
|
|
94
|
+
task-tags = ["TODO", "FIXME", "HACK"]
|
|
95
|
+
|
|
96
|
+
[tool.ruff.format]
|
|
97
|
+
skip-magic-trailing-comma = true
|
|
98
|
+
|
|
99
|
+
[tool.uv]
|
|
100
|
+
exclude-newer = "1 week"
|
|
101
|
+
exclude-newer-package = { uv-build = false }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import logging
|
|
3
|
+
from importlib import metadata as importlib_metadata
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from emberpost.post import dispatch_schedule_files
|
|
7
|
+
from emberpost.schedule_config import Frequency
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _package_version(distribution_name: str) -> str:
|
|
11
|
+
"""Return the installed distribution version."""
|
|
12
|
+
try:
|
|
13
|
+
return importlib_metadata.version(distribution_name)
|
|
14
|
+
except importlib_metadata.PackageNotFoundError:
|
|
15
|
+
return "unknown"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def parse_args() -> argparse.Namespace:
|
|
19
|
+
"""Parse Emberpost command-line arguments."""
|
|
20
|
+
parser = argparse.ArgumentParser(
|
|
21
|
+
description="Dispatch PagerDuty on-call schedules to Slack."
|
|
22
|
+
)
|
|
23
|
+
parser.add_argument(
|
|
24
|
+
"--version",
|
|
25
|
+
action="version",
|
|
26
|
+
version=f"emberpost {_package_version('emberpost')}",
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"--schedule-file",
|
|
30
|
+
nargs="+",
|
|
31
|
+
type=Path,
|
|
32
|
+
required=True,
|
|
33
|
+
help="One or more schedule YAML files to process.",
|
|
34
|
+
)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"--frequency",
|
|
37
|
+
choices=list(Frequency),
|
|
38
|
+
required=True,
|
|
39
|
+
help="Only process schedules matching this frequency.",
|
|
40
|
+
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"--dry-run",
|
|
43
|
+
action="store_true",
|
|
44
|
+
help="Resolve on-call users and print intended Slack changes without writing to Slack.",
|
|
45
|
+
)
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"--log-level",
|
|
48
|
+
default="INFO",
|
|
49
|
+
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
|
|
50
|
+
help="Logging level.",
|
|
51
|
+
)
|
|
52
|
+
return parser.parse_args()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main() -> None:
|
|
56
|
+
"""Run the Emberpost command-line application."""
|
|
57
|
+
args = parse_args()
|
|
58
|
+
logging.basicConfig(
|
|
59
|
+
level=getattr(logging, args.log_level),
|
|
60
|
+
format=("%(levelname)-8s [%(filename)s:%(funcName)s:%(lineno)d] %(message)s"),
|
|
61
|
+
)
|
|
62
|
+
if args.log_level != "DEBUG":
|
|
63
|
+
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
64
|
+
|
|
65
|
+
dispatch_schedule_files(
|
|
66
|
+
args.schedule_file, Frequency(args.frequency), dry_run=args.dry_run
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
main()
|
|
@@ -7,16 +7,22 @@ import pagerduty
|
|
|
7
7
|
|
|
8
8
|
@dataclass(frozen=True)
|
|
9
9
|
class PagerDutyOnCall:
|
|
10
|
+
"""Resolved PagerDuty on-call identity."""
|
|
11
|
+
|
|
10
12
|
email: str
|
|
11
13
|
name: str
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
class PagerDutyClient:
|
|
17
|
+
"""Tenant-scoped adapter for PagerDuty on-call resolution."""
|
|
18
|
+
|
|
15
19
|
def __init__(self, tenant: str) -> None:
|
|
20
|
+
"""Initialize a PagerDuty client using the tenant-specific API key."""
|
|
16
21
|
self.tenant = tenant
|
|
17
22
|
self.client = pagerduty.RestApiV2Client(self._api_key())
|
|
18
23
|
|
|
19
24
|
def get_oncalls(self, schedule_ids: list[str]) -> dict[str, PagerDutyOnCall]:
|
|
25
|
+
"""Return the earliest current on-call identity for each schedule."""
|
|
20
26
|
if not schedule_ids:
|
|
21
27
|
return {}
|
|
22
28
|
|