Skip to content

Commit d8505fd

Browse files
author
Irving Popovetsky
authored
Merge pull request #421 from OperationCode/irving/enable_tracing
Enable Sentry tracing and re-add CI and fix a bunch of lint things
2 parents 7fca1a7 + 13585ff commit d8505fd

27 files changed

+1815
-165
lines changed

.github/dependabot.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: 2
2+
updates:
3+
# Python dependencies via Poetry
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
open-pull-requests-limit: 5
10+
groups:
11+
python-minor:
12+
patterns:
13+
- "*"
14+
update-types:
15+
- "minor"
16+
- "patch"
17+
labels:
18+
- "dependencies"
19+
- "python"
20+
21+
# GitHub Actions
22+
- package-ecosystem: "github-actions"
23+
directory: "/"
24+
schedule:
25+
interval: "weekly"
26+
day: "monday"
27+
open-pull-requests-limit: 5
28+
labels:
29+
- "dependencies"
30+
- "github-actions"
31+
32+
# Docker
33+
- package-ecosystem: "docker"
34+
directory: "/docker"
35+
schedule:
36+
interval: "weekly"
37+
day: "monday"
38+
labels:
39+
- "dependencies"
40+
- "docker"

.github/workflows/ci.yml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
env:
10+
POETRY_VERSION: "2.3.0"
11+
POETRY_VIRTUALENVS_IN_PROJECT: true
12+
13+
jobs:
14+
lint:
15+
name: Lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.14"
25+
26+
- name: Load cached Poetry installation
27+
id: cached-poetry
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.local
31+
key: poetry-${{ env.POETRY_VERSION }}-${{ runner.os }}
32+
33+
- name: Install Poetry
34+
if: steps.cached-poetry.outputs.cache-hit != 'true'
35+
uses: snok/install-poetry@v1
36+
with:
37+
version: ${{ env.POETRY_VERSION }}
38+
virtualenvs-create: true
39+
virtualenvs-in-project: true
40+
41+
- name: Load cached venv
42+
id: cached-venv
43+
uses: actions/cache@v4
44+
with:
45+
path: .venv
46+
key: venv-lint-${{ runner.os }}-py3.14-${{ hashFiles('poetry.lock') }}
47+
restore-keys: |
48+
venv-lint-${{ runner.os }}-py3.14-
49+
50+
- name: Install dependencies
51+
if: steps.cached-venv.outputs.cache-hit != 'true'
52+
run: poetry install --only dev --no-interaction
53+
54+
- name: Run Ruff linter
55+
run: poetry run ruff check .
56+
57+
- name: Run Ruff formatter check
58+
run: poetry run ruff format --check .
59+
60+
test:
61+
name: Test
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
67+
- name: Set up Python 3.14
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: "3.14"
71+
72+
- name: Load cached Poetry installation
73+
id: cached-poetry
74+
uses: actions/cache@v4
75+
with:
76+
path: ~/.local
77+
key: poetry-${{ env.POETRY_VERSION }}-${{ runner.os }}
78+
79+
- name: Install Poetry
80+
if: steps.cached-poetry.outputs.cache-hit != 'true'
81+
uses: snok/install-poetry@v1
82+
with:
83+
version: ${{ env.POETRY_VERSION }}
84+
virtualenvs-create: true
85+
virtualenvs-in-project: true
86+
87+
- name: Load cached venv
88+
id: cached-venv
89+
uses: actions/cache@v4
90+
with:
91+
path: .venv
92+
key: venv-test-${{ runner.os }}-py3.14-${{ hashFiles('poetry.lock') }}
93+
restore-keys: |
94+
venv-test-${{ runner.os }}-py3.14-
95+
96+
- name: Install dependencies
97+
if: steps.cached-venv.outputs.cache-hit != 'true'
98+
run: poetry install --no-interaction
99+
100+
- name: Run tests with coverage
101+
run: |
102+
poetry run pytest \
103+
--cov=pybot \
104+
--cov-report=xml \
105+
--cov-report=term-missing \
106+
-v \
107+
--tb=short
108+
env:
109+
SLACK_TOKEN: "xoxb-test-token"
110+
SLACK_ADMIN_TOKEN: "xoxb-admin-test-token"
111+
AIRTABLE_API_KEY: "test-key"
112+
AIRTABLE_BASE_ID: "test-base"
113+
114+
- name: Upload coverage to Codecov
115+
uses: codecov/codecov-action@v5
116+
with:
117+
files: ./coverage.xml
118+
fail_ci_if_error: false
119+
verbose: true
120+
121+
security:
122+
name: Security Scan
123+
runs-on: ubuntu-latest
124+
steps:
125+
- name: Checkout code
126+
uses: actions/checkout@v4
127+
128+
- name: Set up Python 3.14
129+
uses: actions/setup-python@v5
130+
with:
131+
python-version: "3.14"
132+
133+
- name: Load cached Poetry installation
134+
id: cached-poetry
135+
uses: actions/cache@v4
136+
with:
137+
path: ~/.local
138+
key: poetry-${{ env.POETRY_VERSION }}-${{ runner.os }}
139+
140+
- name: Install Poetry
141+
if: steps.cached-poetry.outputs.cache-hit != 'true'
142+
uses: snok/install-poetry@v1
143+
with:
144+
version: ${{ env.POETRY_VERSION }}
145+
virtualenvs-create: true
146+
virtualenvs-in-project: true
147+
148+
- name: Load cached venv
149+
id: cached-venv
150+
uses: actions/cache@v4
151+
with:
152+
path: .venv
153+
key: venv-security-${{ runner.os }}-py3.14-${{ hashFiles('poetry.lock') }}
154+
restore-keys: |
155+
venv-security-${{ runner.os }}-py3.14-
156+
157+
- name: Install dependencies
158+
if: steps.cached-venv.outputs.cache-hit != 'true'
159+
run: poetry install --no-interaction
160+
161+
- name: Run Bandit security linter
162+
run: poetry run bandit -r pybot -x pybot/_vendor --skip B101 -f json -o bandit-report.json || true
163+
164+
- name: Display Bandit results
165+
run: poetry run bandit -r pybot -x pybot/_vendor --skip B101 -f txt || true
166+
167+
- name: Check for known vulnerabilities
168+
run: poetry run safety scan --output text || true
169+
continue-on-error: true
170+
171+
# Final status check for branch protection
172+
ci-success:
173+
name: CI Success
174+
needs: [lint, test, security]
175+
runs-on: ubuntu-latest
176+
if: always()
177+
steps:
178+
- name: Check all jobs passed
179+
run: |
180+
if [[ "${{ needs.lint.result }}" != "success" ]]; then
181+
echo "Lint job failed"
182+
exit 1
183+
fi
184+
if [[ "${{ needs.test.result }}" != "success" ]]; then
185+
echo "Test job failed"
186+
exit 1
187+
fi
188+
# Security is informational, doesn't fail CI
189+
echo "All required jobs passed!"

README.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
<div align="center">
2-
<a href="https://operationcode.org" height="750" width="750">
2+
<a href="https://operationcode.org">
33
<img
4-
alt="Operation Code Hacktoberfest Banner"
5-
src="https://operation-code-assets.s3.us-east-2.amazonaws.com/operationcode_hacktoberfest_2020.jpg"
4+
alt="Operation Code Logo"
5+
src="https://operation-code-assets.s3.us-east-2.amazonaws.com/branding/logos/large-blue-logo.png"
6+
width="400"
67
>
78
</a>
89
</div>
9-
<br />
10-
<br />
11-
12-
1310
<br />
1411

1512
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
16-
[![Twitter Follow](https://img.shields.io/twitter/follow/operation_code.svg?style=social&label=Follow&style=social)](https://twitter.com/operation_code)
17-
[![Code-style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
18-
19-
20-
[![CircleCI](https://circleci.com/gh/OperationCode/operationcode-pybot.svg?style=svg)](https://circleci.com/gh/OperationCode/operationcode-pybot)
21-
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=OperationCode/operationcode-pybot)](https://dependabot.com)
13+
[![CI](https://github.com/OperationCode/operationcode-pybot/actions/workflows/ci.yml/badge.svg)](https://github.com/OperationCode/operationcode-pybot/actions/workflows/ci.yml)
14+
[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
2215
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://contributor-covenant.org/)
2316

2417
# [OperationCode-Pybot](https://github.com/OperationCode/operationcode-pybot)
@@ -41,7 +34,7 @@ The vendored code has been modernized with:
4134
- Removed deprecated `asyncio.coroutine()` usage
4235
- Fixed deprecated `loop=` parameter patterns
4336
- Replaced removed `cgi` module with `email.message`
44-
- Added Python 3.12 type hints
37+
- Added Python 3.12+ type hints
4538

4639
## Resources
4740
* [Slack Bot Tutorial](https://www.digitalocean.com/community/tutorials/how-to-build-a-slackbot-in-python-on-ubuntu-20-04)
@@ -54,9 +47,9 @@ Bug reports and pull requests are welcome on [Github](https://github.com/Operati
5447

5548
## Quick Start
5649
Recommended versions of tools used within the repo:
57-
- `python@3.12` or greater (Python 3.13+ also supported)
50+
- `python@3.14` or greater
5851
- `git@2.17.1` or greater
59-
- `poetry@1.0` or greater
52+
- `poetry@2.0` or greater
6053
- [Poetry](https://python-poetry.org/) is a packaging and dependency manager, similar to pip or pipenv
6154
- Install via: `curl -sSL https://install.python-poetry.org | python3 -`
6255
- See https://python-poetry.org/docs/
@@ -73,7 +66,7 @@ poetry run python -m pybot
7366
poetry run pytest
7467

7568
# Run formatting and linting
76-
poetry run black pybot/ tests/
69+
poetry run ruff format pybot/ tests/
7770
poetry run ruff check pybot/ tests/
7871
```
7972

@@ -253,7 +246,7 @@ Command | Description | Usage Hint
253246
/ticket | submit ticket to admins | (text of ticket)
254247

255248

256-
**👋 IMPORTANT!**
249+
**IMPORTANT!**
257250

258251
The `/lunch` command requires a valid Yelp API token stored in the `YELP_TOKEN`
259252
environment variable. See https://www.yelp.com/developers/faq
@@ -264,7 +257,7 @@ functionality please reach out to the `#oc-python-projects` channel for help get
264257

265258
### Airtable Authentication
266259

267-
**⚠️ IMPORTANT:** Airtable deprecated API keys on February 1, 2024. You must use a **Personal Access Token (PAT)**:
260+
**IMPORTANT:** Airtable deprecated API keys on February 1, 2024. You must use a **Personal Access Token (PAT)**:
268261

269262
1. Go to [Airtable Developer Hub](https://airtable.com/create/tokens)
270263
2. Click **Create new token**

manage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ async def replay_team_join(
125125
except Exception as e:
126126
logger.error(f" Failed to link backend user: {e}")
127127
else:
128-
logger.error(" Backend authentication failed - check BACKEND_USERNAME/BACKEND_PASS")
128+
logger.error(
129+
" Backend authentication failed - check BACKEND_USERNAME/BACKEND_PASS"
130+
)
129131
else:
130132
logger.info("Skipping backend linking (--skip-backend)")
131133

0 commit comments

Comments
 (0)