Skip to content

Commit e457884

Browse files
committed
Genesis commit!
Refers to hash of genesis commit in the new Brood repository, as well.
1 parent c0400ed commit e457884

File tree

163 files changed

+19257
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+19257
-2
lines changed

.github/workflows/lint.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Lint Spire
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-python@v2
11+
with:
12+
python-version: "3.8"
13+
- name: Create requirements file for lint environment
14+
run: grep -v -e "brood$" requirements.txt | tee requirements.lint.txt
15+
- name: Install test requirements
16+
run: pip install -r requirements.lint.txt
17+
- name: Mypy type check (spire)
18+
run: mypy spire/
19+
- name: Black syntax check (spire)
20+
run: black --check spire/

.github/workflows/locust.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Locust summary
2+
3+
on: [pull_request_target]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- name: PR head repo
10+
id: head_repo_name
11+
run: |
12+
HEAD_REPO_NAME=$(jq -r '.pull_request.head.repo.full_name' "$GITHUB_EVENT_PATH")
13+
echo "PR head repo: $HEAD_REPO_NAME"
14+
echo "::set-output name=repo::$HEAD_REPO_NAME"
15+
- name: Checkout git repo
16+
uses: actions/checkout@v2
17+
with:
18+
repository: ${{ steps.head_repo_name.outputs.repo }}
19+
fetch-depth: 0
20+
- name: Install python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: "3.8"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip setuptools
27+
pip install bugout-locust
28+
- name: Generate and send Locust summary
29+
env:
30+
BUGOUT_SECRET: ${{ secrets.BUGOUT_SECRET }}
31+
run: |
32+
locust.github publish

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,27 @@ venv.bak/
120120
# mkdocs documentation
121121
/site
122122

123+
### Pycharm ###
124+
.idea
125+
123126
# mypy
124127
.mypy_cache/
125128
.dmypy.json
126129
dmypy.json
127130

131+
# VS Code
132+
.vscode/
133+
128134
# Pyre type checker
129135
.pyre/
136+
.spire/
137+
dev.env
138+
prod.env
139+
test.env
140+
alembic.dev.ini
141+
alembic.prod.ini
142+
alembic.test.ini
143+
144+
# Custom
145+
.secrets/
146+
scratch

README.md

+84-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,84 @@
1-
# spire-new
2-
Bugout knowledgebase module.
1+
# Spire
2+
3+
Bugout custom knowledge bases
4+
5+
### Setup:
6+
* Clone git repository
7+
* Install postgresql (https://www.postgresql.org/download/linux/ubuntu/)
8+
* Install elasticsearch (https://www.elastic.co/guide/en/elasticsearch/reference/7.9/deb.html)
9+
* Install requirements
10+
* Create dev version and manage app at https://api.slack.com/apps/
11+
* Copy sample.env to dev.env and fill `dev` fields
12+
```
13+
export BUGOUT_SLACK_[your info for slack apps]
14+
...
15+
export SPIRE_DB_URI="postgresql://postgres:postgres@localhost/brood_dev"
16+
export ELASTICSEARCH_[your info for elasticsearch]
17+
...
18+
export BUGOUT_JOURNAL_EMOJI="beetle"
19+
export SPIRE_API_URL="http://0.0.0.0:7475"
20+
export BUGOUT_AUTH_URL="http://localhost:7474"
21+
```
22+
* Copy `alembic.sample.ini` to `alembic.dev.ini` and correct field
23+
```
24+
sqlalchemy.url = postgresql://postgres:postgres@localhost/brood_dev
25+
```
26+
* Run alembic migration
27+
```
28+
> ./alembic.sh -c alembic.dev.ini upgrade head
29+
```
30+
* Install ngrok (https://ngrok.com/download)
31+
* Run ngrok tunnel
32+
```
33+
> ngrok http 7475
34+
```
35+
* Run server
36+
```
37+
> ./dev.sh
38+
```
39+
* Set slack `OAuth & Permissions` Redirect URLs to ngrok
40+
```
41+
https://60843a634907.ngrok.io/slack/oauth
42+
```
43+
* Add OAuth Scopes
44+
```
45+
app_mentions:read
46+
channels:history
47+
channels:read
48+
chat:write
49+
commands
50+
emoji:read
51+
groups:history
52+
groups:read
53+
im:history
54+
im:write
55+
links:read
56+
mpim:history
57+
reactions:read
58+
reactions:write
59+
users.profile:read
60+
```
61+
* Set slack `Event Subscriptions` Request URL to ngrok
62+
```
63+
https://60843a634907.ngrok.io/slack/event
64+
```
65+
* Add events
66+
```
67+
app_mentions
68+
app_uninstalled
69+
channel_rename
70+
emoji_changed
71+
link_shared
72+
message.im
73+
reaction_added
74+
reaction_removed
75+
```
76+
* Run brood local server
77+
* Create brood user `slack_installation` with hard password (this user will be managing
78+
whole slack workspaces), generate token for this user and add it to environment at `dev.env`
79+
```
80+
export BUGOUT_INSTALLATION_TOKEN="<installation user token from brood>"
81+
```
82+
* Add slack dev bot to slack
83+
84+
* For Shortcuts use readme (https://github.com/simiotics/spire/blob/bug-9-visual-slack-search/spire/slack/shortcuts.md)

alembic.sample.ini

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts
5+
script_location = alembic
6+
7+
# template used to generate migration files
8+
# file_template = %%(rev)s_%%(slug)s
9+
10+
# timezone to use when rendering the date
11+
# within the migration file as well as the filename.
12+
# string value is passed to dateutil.tz.gettz()
13+
# leave blank for localtime
14+
# timezone =
15+
16+
# max length of characters to apply to the
17+
# "slug" field
18+
# truncate_slug_length = 40
19+
20+
# set to 'true' to run the environment during
21+
# the 'revision' command, regardless of autogenerate
22+
# revision_environment = false
23+
24+
# set to 'true' to allow .pyc and .pyo files without
25+
# a source .py file to be detected as revisions in the
26+
# versions/ directory
27+
# sourceless = false
28+
29+
# version location specification; this defaults
30+
# to alembic/versions. When using multiple version
31+
# directories, initial revisions must be specified with --version-path
32+
# version_locations = %(here)s/bar %(here)s/bat alembic/versions
33+
34+
# the output encoding used when revision files
35+
# are written from script.py.mako
36+
# output_encoding = utf-8
37+
38+
sqlalchemy.url = driver://user:pass@localhost/dbname
39+
40+
41+
[post_write_hooks]
42+
# post_write_hooks defines scripts or Python functions that are run
43+
# on newly generated revision scripts. See the documentation for further
44+
# detail and examples
45+
46+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
47+
# hooks=black
48+
# black.type=console_scripts
49+
# black.entrypoint=black
50+
# black.options=-l 79
51+
52+
# Logging configuration
53+
[loggers]
54+
keys = root,sqlalchemy,alembic
55+
56+
[handlers]
57+
keys = console
58+
59+
[formatters]
60+
keys = generic
61+
62+
[logger_root]
63+
level = WARN
64+
handlers = console
65+
qualname =
66+
67+
[logger_sqlalchemy]
68+
level = WARN
69+
handlers =
70+
qualname = sqlalchemy.engine
71+
72+
[logger_alembic]
73+
level = INFO
74+
handlers =
75+
qualname = alembic
76+
77+
[handler_console]
78+
class = StreamHandler
79+
args = (sys.stderr,)
80+
level = NOTSET
81+
formatter = generic
82+
83+
[formatter_generic]
84+
format = %(levelname)-5.5s [%(name)s] %(message)s
85+
datefmt = %H:%M:%S

alembic.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
PYTHONPATH=".:$PYTHONPATH" alembic "$@"

alembic/README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic single-database configuration.

0 commit comments

Comments
 (0)