-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from lsst-sqre/tickets/DM-39043
DM-39043: Add Kafka producer for Slack messages and migrate to a client-server architecture
- Loading branch information
Showing
77 changed files
with
3,477 additions
and
1,704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
name: CI | ||
|
||
"on": | ||
merge_group: {} | ||
pull_request: {} | ||
push: | ||
branches-ignore: | ||
# These should always correspond to pull requests, so ignore them for | ||
# the push trigger and let them be triggered by the pull_request | ||
# trigger, avoiding running the workflow twice. This is a minor | ||
# optimization so there's no need to ensure this is comprehensive. | ||
- "dependabot/**" | ||
- "gh-readonly-queue/**" | ||
- "renovate/**" | ||
- "tickets/**" | ||
- "u/**" | ||
tags: | ||
- "*" | ||
pull_request: {} | ||
|
||
jobs: | ||
lint: | ||
|
@@ -26,19 +28,38 @@ jobs: | |
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.11" | ||
|
||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
|
||
test: | ||
test-client: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python: | ||
- "3.11" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run tox | ||
uses: lsst-sqre/run-tox@v1 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
tox-envs: "typing" | ||
cache-key-prefix: "client" | ||
working-directory: "./client" | ||
|
||
test-server: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python: | ||
- "3.10" | ||
- "3.11" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -48,6 +69,8 @@ jobs: | |
with: | ||
python-version: ${{ matrix.python }} | ||
tox-envs: "py,coverage-report,typing" | ||
cache-key-prefix: "server" | ||
working-directory: "./server" | ||
|
||
docs: | ||
runs-on: ubuntu-latest | ||
|
@@ -68,9 +91,10 @@ jobs: | |
- name: Run tox | ||
uses: lsst-sqre/run-tox@v1 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.11" | ||
tox-envs: "docs" | ||
cache-key-prefix: "docs" | ||
working-directory: "./server" | ||
|
||
# Only attempt documentation uploads for long-lived branches, tagged | ||
# releases, and pull requests from ticket branches. This avoids version | ||
|
@@ -84,13 +108,14 @@ jobs: | |
username: ${{ secrets.LTD_USERNAME }} | ||
password: ${{ secrets.LTD_PASSWORD }} | ||
if: > | ||
github.event_name != 'pull_request' | ||
|| startsWith(github.head_ref, 'tickets/') | ||
github.event_name != 'merge_group' | ||
&& (github.event_name != 'pull_request' | ||
|| startsWith(github.head_ref, 'tickets/')) | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
needs: [lint, test] | ||
needs: [lint, test-server] | ||
|
||
# Only do Docker builds of tagged releases and pull requests from ticket | ||
# branches. This will still trigger on pull requests from untrusted | ||
|
@@ -125,11 +150,29 @@ jobs: | |
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
ghcr.io/lsst-sqre/squarebot:${{ steps.vars.outputs.tag }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
pypi: | ||
|
||
runs-on: ubuntu-latest | ||
needs: [lint, test-client, docs] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # full history for setuptools_scm | ||
|
||
- name: Build and publish | ||
uses: lsst-sqre/build-and-publish-to-pypi@v1 | ||
with: | ||
pypi-token: ${{ secrets.PYPI_SQRE_ADMIN }} | ||
python-version: "3.11" | ||
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | ||
working-directory: "./client" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
changelog.d/_template.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
.PHONY: update-deps | ||
update-deps: | ||
pip install --upgrade pip-tools pip setuptools | ||
pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/main.txt requirements/main.in | ||
pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/dev.txt requirements/dev.in | ||
|
||
# Useful for testing against a Git version of Safir. | ||
.PHONY: update-deps-no-hashes | ||
update-deps-no-hashes: | ||
pip install --upgrade pip-tools pip setuptools | ||
pip-compile --upgrade --build-isolation --allow-unsafe --output-file requirements/main.txt requirements/main.in | ||
pip-compile --upgrade --build-isolation --allow-unsafe --output-file requirements/dev.txt requirements/dev.in | ||
# pip-compile --upgrade --build-isolation --generate-hashes --output-file server/requirements/main.hashed.txt server/requirements/main.in | ||
# pip-compile --upgrade --build-isolation --generate-hashes --output-file server/requirements/dev.hashed.txt server/requirements/dev.in | ||
pip-compile --upgrade --build-isolation --allow-unsafe --output-file server/requirements/main.txt server/requirements/main.in | ||
pip-compile --upgrade --build-isolation --allow-unsafe --output-file server/requirements/dev.txt server/requirements/dev.in | ||
|
||
.PHONY: init | ||
init: | ||
pip install --editable . | ||
pip install --upgrade -r requirements/main.txt -r requirements/dev.txt | ||
rm -rf .tox | ||
pip install --upgrade pre-commit tox | ||
pip install --editable "./client[dev]" | ||
pip install --editable ./server | ||
pip install --upgrade -r server/requirements/main.txt -r server/requirements/dev.txt | ||
rm -rf ./server/.tox | ||
rm -rf ./client/.tox | ||
pip install --upgrade pre-commit tox scriv | ||
pre-commit install | ||
|
||
.PHONY: update | ||
update: update-deps init | ||
|
||
.PHONY: run | ||
run: | ||
tox -e=run | ||
cd server && tox run -e=run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Squarebot | ||
|
||
Squarebot is the nexus service for ChatOps and event-driven bots for Rubin Observatory. | ||
As a Slack app, Squarebot receives events from Slack and publishes them into specific _Square Events_ Kafka topics in the [Roundtable Kubernetes cluster](https://phalanx.lsst.io/environments/roundtable-prod/index.html). | ||
Other applications on Roundtable can consume these events and act on them, such as by posting messages back to Slack or by performing some other background automation. | ||
|
||
```mermaid | ||
flowchart LR | ||
subgraph Slack | ||
message[Slack message] | ||
interaction[Slack interaction] | ||
end | ||
subgraph sqrbot ["Squarebot"] | ||
eventapi["/slack/event"] | ||
interactionapi["/slack/interaction"] | ||
message -->|HTTP POST| eventapi | ||
interaction -->|HTTP POST| interactionapi | ||
end | ||
subgraph kafka ["Kafka Topics"] | ||
topicmention["lsst.square-events.squarebot.slack.app.mention"] | ||
topicchannel["lsst.square-events.squarebot.slack.message.channel"] | ||
topicgroup["lsst.square-events.squarebot.slack.message.group"] | ||
topicim["lsst.square-events.squarebot.slack.message.im"] | ||
topicmpim["lsst.square-events.squarebot.slack.message.mpim"] | ||
topicinteraction["lsst.square-events.squarebot.slack.interaction"] | ||
end | ||
eventapi --> topicmention | ||
eventapi --> topicchannel | ||
eventapi --> topicgroup | ||
eventapi --> topicim | ||
eventapi --> topicmpim | ||
interactionapi --> topicinteraction | ||
subgraph backends ["Backends"] | ||
backend1["Backend 1"] | ||
backend2["Backend 2"] | ||
end | ||
topicchannel --> backend1 | ||
topicgroup --> backend1 | ||
topicmention --> backend2 | ||
topicinteraction --> backend2 | ||
``` | ||
|
||
Slack integration is implemented at the time. | ||
We plan to add support for other event sources, such as GitHub, in the future. | ||
|
||
Squarebot is built on top of [FastAPI](https://fastapi.tiangolo.com/), a modern Python web framework, with Rubin/SQuaRE libraries [Safir](https://safir.lsst.io) (FastAPI application libraries) and [Kafkit](https://kafkit.lsst.io) (Kafka integration). |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!-- Delete the sections that don't apply --> | ||
{%- for cat in config.categories %} | ||
|
||
### {{ cat }} | ||
|
||
- | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../README.md |
Oops, something went wrong.