Skip to content

Commit b359d8d

Browse files
ChengaDevclaude
andcommitted
Restructure docs: lean README with nav links to dedicated files
- README: removed tech stack, running locally, and full examples sections - Added nav links: Why OpsAgent? · Examples · Running locally · Contributing - WHY_OPSAGENT.md: moved "Is OpsAgent right for you?" content - EXAMPLES.md: all GitHub Actions, GitLab CI, Jenkins examples - RUNNING_LOCALLY.md: mock mode, production mode, build executable, tests - CONTRIBUTING.md + CODE_OF_CONDUCT.md: community health files for GitHub tabs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 21adc45 commit b359d8d

6 files changed

Lines changed: 415 additions & 441 deletions

File tree

CODE_OF_CONDUCT.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity, level of experience, nationality, personal appearance, race, religion, or sexual identity.
6+
7+
## Our Standards
8+
9+
**Positive behaviour includes:**
10+
- Using welcoming and inclusive language
11+
- Being respectful of differing viewpoints and experiences
12+
- Gracefully accepting constructive criticism
13+
- Focusing on what is best for the community
14+
15+
**Unacceptable behaviour includes:**
16+
- Harassment, insulting, or derogatory comments
17+
- Public or private harassment
18+
- Publishing others' private information without permission
19+
- Other conduct which could reasonably be considered inappropriate
20+
21+
## Enforcement
22+
23+
Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by opening an issue or contacting the maintainers directly. All complaints will be reviewed and investigated.
24+
25+
## Attribution
26+
27+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Contributing to OpsAgent
2+
3+
Contributions are welcome. Please open an issue first for anything beyond a small bug fix so we can align on direction before you invest time in a PR.
4+
5+
## Requirements for every PR
6+
7+
- **Tests are mandatory.** Every change to behaviour must include tests. PRs without tests covering the new or changed code will not be merged.
8+
- All existing tests must continue to pass (`pytest tests/ -v`).
9+
- Keep new dependencies minimal — ask in an issue if you're unsure.
10+
11+
## Getting started
12+
13+
```bash
14+
git clone https://github.com/ChengaDev/opsagent.git
15+
cd opsagent
16+
python3 -m venv .venv && source .venv/bin/activate
17+
pip install -e ".[all-providers]"
18+
pytest tests/ -v
19+
```
20+
21+
## Good first areas
22+
23+
- **New MCP servers** — Jira, PagerDuty, Datadog log fetcher, `kubectl` live pod state
24+
- **New log patterns** — add to `_PATTERNS` in `mcp_tools/log_analyzer.py` with a matching fixture and test
25+
- **Streaming output** — stream Claude's reasoning in real time
26+
27+
## Adding a new log pattern
28+
29+
1. Add a `(regex, IssueKind, group_index)` entry to `_PATTERNS` in `mcp_tools/log_analyzer.py`
30+
2. Add a realistic fixture log to `tests/fixtures/`
31+
3. Add a test class in the appropriate test file following the existing pattern
32+
4. Run `pytest tests/ -v` to confirm

EXAMPLES.md

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# GitHub Actions Examples
2+
3+
> **Tip:** Always use `set -o pipefail` before piping through `tee` — without it, the pipeline returns `tee`'s exit code (0) even when your command fails, so `if: failure()` never triggers.
4+
5+
## Python / pytest
6+
7+
```yaml
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.11'
16+
17+
- name: Install dependencies
18+
run: pip install -r requirements.txt
19+
20+
- name: Run tests
21+
run: |
22+
set -o pipefail
23+
pytest tests/ -v 2>&1 | tee "${{ runner.temp }}/pytest.log"
24+
25+
- name: Run OpsAgent RCA
26+
if: failure()
27+
uses: ChengaDev/opsagent@v1
28+
with:
29+
log-path: ${{ runner.temp }}/pytest.log
30+
workspace: ${{ github.workspace }}
31+
slack-webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
32+
env:
33+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
34+
```
35+
36+
## Node.js / npm
37+
38+
```yaml
39+
jobs:
40+
build:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: '20'
47+
48+
- name: Install and build
49+
run: |
50+
npm ci
51+
set -o pipefail
52+
npm run build 2>&1 | tee "${{ runner.temp }}/build.log"
53+
54+
- name: Run tests
55+
run: |
56+
set -o pipefail
57+
npm test 2>&1 | tee "${{ runner.temp }}/test.log"
58+
59+
- name: Run OpsAgent RCA
60+
if: failure()
61+
uses: ChengaDev/opsagent@v1
62+
with:
63+
log-path: ${{ runner.temp }}/test.log
64+
workspace: ${{ github.workspace }}
65+
slack-webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
66+
env:
67+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
68+
```
69+
70+
## Post RCA as a PR comment
71+
72+
```yaml
73+
- name: Run OpsAgent RCA
74+
if: failure()
75+
uses: ChengaDev/opsagent@v1
76+
with:
77+
log-path: ${{ runner.temp }}/test.log
78+
workspace: ${{ github.workspace }}
79+
github-token: ${{ secrets.GITHUB_TOKEN }}
80+
env:
81+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
82+
```
83+
84+
OpsAgent posts the full RCA as a comment on the pull request that triggered the failure — no webhook configuration needed.
85+
86+
## Save the RCA to a file
87+
88+
```yaml
89+
- name: Run OpsAgent RCA
90+
if: failure()
91+
uses: ChengaDev/opsagent@v1
92+
with:
93+
log-path: ${{ runner.temp }}/test.log
94+
workspace: ${{ github.workspace }}
95+
output: ${{ runner.temp }}/rca.md
96+
env:
97+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
98+
99+
- name: Upload RCA report
100+
if: failure()
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: rca-report
104+
path: ${{ runner.temp }}/rca.md
105+
```
106+
107+
## Use a custom model
108+
109+
```yaml
110+
- name: Run OpsAgent RCA
111+
if: failure()
112+
uses: ChengaDev/opsagent@v1
113+
with:
114+
log-path: ${{ runner.temp }}/test.log
115+
workspace: ${{ github.workspace }}
116+
model: claude-opus-4-6
117+
investigate-model: claude-haiku-4-5-20251001
118+
env:
119+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
120+
```
121+
122+
## Use a different provider
123+
124+
```yaml
125+
# Google Gemini
126+
- name: Run OpsAgent RCA
127+
if: failure()
128+
uses: ChengaDev/opsagent@v1
129+
with:
130+
log-path: ${{ runner.temp }}/test.log
131+
workspace: ${{ github.workspace }}
132+
provider: google
133+
env:
134+
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
135+
```
136+
137+
```yaml
138+
# OpenAI
139+
- name: Run OpsAgent RCA
140+
if: failure()
141+
uses: ChengaDev/opsagent@v1
142+
with:
143+
log-path: ${{ runner.temp }}/test.log
144+
workspace: ${{ github.workspace }}
145+
provider: openai
146+
env:
147+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
148+
```
149+
150+
## CD pipeline — Helm deploy
151+
152+
```yaml
153+
- name: Deploy
154+
run: |
155+
set -o pipefail
156+
helm upgrade --install my-service ./charts/my-service \
157+
--namespace production \
158+
--set image.tag=${{ github.sha }} \
159+
--wait --timeout 5m 2>&1 | tee "${{ runner.temp }}/deploy.log"
160+
161+
- name: Run OpsAgent RCA
162+
if: failure()
163+
uses: ChengaDev/opsagent@v1
164+
with:
165+
log-path: ${{ runner.temp }}/deploy.log
166+
workspace: ${{ github.workspace }}
167+
slack-webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
168+
webhook-url: ${{ secrets.WEBHOOK_URL }}
169+
env:
170+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
171+
```
172+
173+
## CD pipeline — Terraform
174+
175+
```yaml
176+
- name: Terraform apply
177+
run: |
178+
set -o pipefail
179+
terraform apply -auto-approve 2>&1 | tee "${{ runner.temp }}/tf.log"
180+
181+
- name: Run OpsAgent RCA
182+
if: failure()
183+
uses: ChengaDev/opsagent@v1
184+
with:
185+
log-path: ${{ runner.temp }}/tf.log
186+
workspace: ${{ github.workspace }}
187+
slack-webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
188+
webhook-url: ${{ secrets.WEBHOOK_URL }}
189+
env:
190+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
191+
```
192+
193+
## GitLab CI
194+
195+
```yaml
196+
rca:
197+
stage: .post
198+
when: on_failure
199+
script:
200+
- pip install "git+https://github.com/ChengaDev/opsagent.git[all-providers]"
201+
- opsagent --log-path build.log --workspace .
202+
variables:
203+
ANTHROPIC_API_KEY: $ANTHROPIC_API_KEY
204+
```
205+
206+
## Jenkins
207+
208+
```groovy
209+
post {
210+
failure {
211+
sh '''
212+
pip install "git+https://github.com/ChengaDev/opsagent.git[all-providers]"
213+
opsagent --log-path build.log --workspace .
214+
'''
215+
}
216+
}
217+
```

0 commit comments

Comments
 (0)