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
54 changes: 47 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
## DevRev Community SnapIns

This repository contains the SnapIns for DevRev Community.
## GitHub Health Check Snap-In Implementation
[GitHub Health Check Demo Video](https://www.youtube.com/watch?v=0Ax48cxkpIo)

### SnapIns
![GitHub Health Check](git_hub_health.png) <!-- Update the path as necessary -->

- [DevRev Community GitHub](https://github.com/devrev/devrev-community-github)
- [DevRev Community Slack](https://github.com/devrev/devrev-community-slack)
- [DevRev Community Discord](https://github.com/devrev/devrev-community-discord)
Our team has developed the "GitHub Health Check" Snap-In, which is implemented in the `index.ts` file located in the `code/src/functions/command_handler/` directory. This Snap-In automates the process of assessing the health of a GitHub repository and provides valuable insights directly within the DevRev ecosystem.

<!-- This repository would be responsible to add new snapIns from our DevRev Community to our Marketplace, contributors who want to add their snapIns to our Marketplace can do so by creating a new PR to this repository, mention how to do this in a contributions.md file -->
### Key Functionalities

1. **Extracting Repository Information**:
- We utilize the `extractOwnerAndRepo` function to parse the GitHub repository URL and extract the owner and repository name. This approach supports various URL formats and ensures accurate data retrieval.

2. **Fetching Repository Details**:
- The `getRepoDetails` function interacts with the GitHub API using the Octokit library to fetch essential repository details, including:
- Number of open issues
- Number of pull requests
- Last commit date
- Contributors
- Other relevant metrics
- Additionally, we calculate a health score based on various criteria, such as the presence of a description, the number of open issues, and community engagement metrics (forks and watchers).

3. **Generating Recommendations**:
- Our Snap-In provides actionable recommendations based on the health score and repository metrics. For instance, it suggests adding a description if one is missing or enabling the Wiki feature for improved documentation.

4. **Creating Timeline Comments**:
- The `createTimelineComment` function formats the repository health check results into a structured comment and posts it to the DevRev timeline. This includes:
- Basic repository details
- Health metrics
- Recommendations
- The comment is visually enhanced with emojis representing the health score.

5. **Handling Events**:
- The `handleEvent` function is responsible for processing incoming events. It initializes the Octokit client with a GitHub personal access token and the DevRev SDK with a service account token. It retrieves the repository URL from the event payload and calls the necessary functions to fetch repository details and create a timeline comment.

6. **Running the Snap-In**:
- The `run` function iterates over incoming events and processes each one using the `handleEvent` function, ensuring that multiple events can be handled in a single execution.

### Example Usage

To use the "GitHub Health Check" Snap-In, a developer or project manager can invoke the command with the following syntax:

```
/github_health_check OrgName RepoName
```

This command will trigger our Snap-In to fetch the health metrics of the specified GitHub repository and post the results to the DevRev timeline.

### Conclusion

The "GitHub Health Check" Snap-In, created by our team, streamlines the process of monitoring repository health, enabling developers and project managers to make informed decisions without the need for manual tracking. By integrating with both GitHub and DevRev, it enhances collaboration and repository management.
48 changes: 48 additions & 0 deletions code/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
extends: [
'airbnb-typescript/base',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended', // Makes ESLint and Prettier play nicely together
'plugin:import/recommended',
'plugin:import/typescript',
],
ignorePatterns: ['**/dist/*'],
overrides: [
{
files: ['**/*.test.ts'],
rules: {
'simple-import-sort/imports': 'off', // for test files we would want to load the mocked up modules later so on sorting the mocking mechanism will not work
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.eslint.json',
},
plugins: ['prettier', 'unused-imports', 'import', 'simple-import-sort', 'sort-keys-fix'],
root: true,
rules: {
'import/first': 'error',
// Removes unused imports automatically,
'@typescript-eslint/no-explicit-any': 'warn',

// Ensures all imports are at the top of the file
'import/newline-after-import': 'error',
// Ensures there’s a newline after the imports
'import/no-duplicates': 'error',
// Merges import statements from the same file
'import/order': 'off',
// Not compatible with simple-import-sort
'no-unused-vars': 'off',
// Handled by @typescript-eslint/no-unused-vars
'simple-import-sort/exports': 'error',
// Auto-formats exports
'simple-import-sort/imports': 'error',
// Auto-formats imports
'sort-imports': 'off',
// Not compatible with simple-import-sort
'sort-keys-fix/sort-keys-fix': ['error', 'asc', { natural: true }],
// Sorts long object key lists alphabetically
'unused-imports/no-unused-imports': 'error', // Allows any type with a warning
},
};
27 changes: 27 additions & 0 deletions code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Ignore node_modules directory
node_modules/

# Ignore logs and temporary files
*.log
*.tmp

# Ignore compiled output
dist/
build/

# Ignore environment-specific files
.env
.env.local
.env.*.local

# Ignore IDE and editor files
.vscode/
.idea/
*.sublime-project
*.sublime-workspace

# Ignore OS generated files
.DS_Store
Thumbs.db

build.tar.gz
1 change: 1 addition & 0 deletions code/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
4 changes: 4 additions & 0 deletions code/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting

/dist

15 changes: 15 additions & 0 deletions code/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxSingleQuote": false,
"arrowParens": "always",
"proseWrap": "never",
"htmlWhitespaceSensitivity": "strict",
"endOfLine": "lf",
"organizeImportsSkipDestructiveCodeActions": true
}
3 changes: 3 additions & 0 deletions code/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
};
12 changes: 12 additions & 0 deletions code/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text'],
coverageThreshold: {
'**/*': {
branches: 60,
},
},
preset: 'ts-jest',
testEnvironment: 'node',
};
5 changes: 5 additions & 0 deletions code/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"execMap": {
"ts": "ts-node"
}
}
Loading