Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions circleci-snap-in/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CIRCLECI_TOKEN=
DEV_ORG=
USER_EMAIL=
DEVREV_TOKEN=
GROQ_API=
43 changes: 43 additions & 0 deletions circleci-snap-in/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# Testing
coverage/

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# System Files
.DS_Store
Thumbs.db

deps.json
results.json
before-run-data.json

node_modules/
.env

*/dist/*
*.tar.gz
.DS_Store
Binary file added circleci-snap-in/DesignLab_Documentation.pdf
Binary file not shown.
75 changes: 75 additions & 0 deletions circleci-snap-in/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# CircleCI Snap-in

Snap-in that syncs pipeline, workflow and jobs to DevRev using webhooks.
There is also a command to generate AI insights from the synced data.
The insights are as follows:
Intelligent Build Failure Analysis (build_failure_analysis)
1. Command pulls build logs from CircleCI.
2. Analyze the logs to identify root causes, error messages, and potential solutions.
3. AI agent posts a comment on the associated DevRev issue summarizing the analysis and suggesting troubleshooting steps.

### Concept Mapping:
1. CircleCI Project - DevRev Part
2. CircleCI Workflow - DevRev Issue (Each run of the workflow creates a timeline event)
3. CircleCI Job - DevRev Task

To run the command :
```
/generateInsights jobId
```

## Requirements
1. CircleCI Account API Key
2. CircleCI Project Slug
3. Configuration of CircleCI Outbound Webhook [refer here](https://circleci.com/docs/webhooks/)

## Demo Working Video
[Youtube](https://youtu.be/67SvpOmIiqU)

## Testing locally

Test the code by adding test events under `src/fixtures` similar to the example event provided. You can add [keyring](https://docs.devrev.ai/snap-ins/references/keyrings) values to the event payload to test API calls as well.

Run local tests using:

```
npm install
npm t
```

## Activating Snap-Ins

Once you are done with the testing, run the following commands to activate your snap_in:

1. Authenticate to devrev CLI
Navigate to the directory with ```manifest.yaml```
```
source .env
echo $DEVREV_TOKEN | devrev profiles set-token --org $DEV_ORG --usr $USER_EMAIL
```

2. Start test server
```
cd ./code
npm run test:server
```
Copy the url generated on replit.

3. Create a snap_in_version

```
devrev snap_in_package create-one --slug <slug_name>
devrev snap_in_version create-one --manifest ./manifest.yaml --testing-url <url>
```

4. Check if the Snap-In has activated
```
devrev snap_in_version show | jq
```

5. Install the Snap-In Draft
```
devrev snap_in draft | jq
```

6. Navigate to the URL returned by the last command on a web browser and setup the required keys.
1 change: 1 addition & 0 deletions circleci-snap-in/code/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
16 changes: 16 additions & 0 deletions circleci-snap-in/code/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
roots: ['./src'],
testPathIgnorePatterns: [
"/node_modules/"
],
collectCoverage: true,
coverageDirectory: "coverage",
coverageReporters: ["text"],
coverageThreshold: {
"**/*": {
branches: 60,
},
},
preset: "ts-jest",
testEnvironment: "node",
};
5 changes: 5 additions & 0 deletions circleci-snap-in/code/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"execMap": {
"ts": "ts-node"
}
}
Loading