diff --git a/README.md b/README.md index 19cf14c..83ef71c 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,16 @@ VUE_APP_CLIENT_SECRET= **Step 4:-** install flask api dependencies and run api ``` -cd backend -virtualenv -p python3 venv -source venv/bin/activate +cd processing pip install -r requirements.txt -FLASK_APP=run.py flask run +python3 run.py +``` + +**Step 5:-** setup codebadge-bot for development +``` +cd codebadge-bot +npm i +nodemon ``` ## Stack used diff --git a/codebadge-bot/.env.example b/codebadge-bot/.env.example new file mode 100644 index 0000000..6e106aa --- /dev/null +++ b/codebadge-bot/.env.example @@ -0,0 +1,9 @@ +# The ID of your GitHub App +APP_ID= +WEBHOOK_SECRET=development + +# Use `trace` to get verbose logging or `info` to show less +LOG_LEVEL=debug + +# Go to https://smee.io/new set this to the URL that you are redirected to. +WEBHOOK_PROXY_URL= diff --git a/codebadge-bot/.gitignore b/codebadge-bot/.gitignore new file mode 100644 index 0000000..d79d786 --- /dev/null +++ b/codebadge-bot/.gitignore @@ -0,0 +1,7 @@ +node_modules +npm-debug.log +*.pem +!mock-cert.pem +.env +package-lock.json +coverage diff --git a/codebadge-bot/CODE_OF_CONDUCT.md b/codebadge-bot/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..d2ae124 --- /dev/null +++ b/codebadge-bot/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at an431999@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + diff --git a/codebadge-bot/CONTRIBUTING.md b/codebadge-bot/CONTRIBUTING.md new file mode 100644 index 0000000..8f36999 --- /dev/null +++ b/codebadge-bot/CONTRIBUTING.md @@ -0,0 +1,41 @@ +## Contributing + +[fork]: /fork +[pr]: /compare +[style]: https://standardjs.com/ +[code-of-conduct]: CODE_OF_CONDUCT.md + +Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. + +Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms. + +## Issues and PRs + +If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them. + +We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR. + +## Submitting a pull request + +1. [Fork][fork] and clone the repository. +1. Configure and install the dependencies: `npm install`. +1. Make sure the tests pass on your machine: `npm test`, note: these tests also apply the linter, so there's no need to lint separately. +1. Create a new branch: `git checkout -b my-branch-name`. +1. Make your change, add tests, and make sure the tests still pass. +1. Push to your fork and [submit a pull request][pr]. +1. Pat your self on the back and wait for your pull request to be reviewed and merged. + +Here are a few things you can do that will increase the likelihood of your pull request being accepted: + +- Follow the [style guide][style] which is using standard. Any linting errors should be shown when running `npm test`. +- Write and update tests. +- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. +- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). + +Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you. + +## Resources + +- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) +- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) +- [GitHub Help](https://help.github.com) diff --git a/codebadge-bot/LICENSE b/codebadge-bot/LICENSE new file mode 100644 index 0000000..daec891 --- /dev/null +++ b/codebadge-bot/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2020, ayushnagar123 + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/codebadge-bot/README.md b/codebadge-bot/README.md new file mode 100644 index 0000000..f1028b5 --- /dev/null +++ b/codebadge-bot/README.md @@ -0,0 +1,23 @@ +# codebadge-test1 + +> A GitHub App built with [Probot](https://github.com/probot/probot) that testing bot for codebadge-bot + +## Setup + +```sh +# Install dependencies +npm install + +# Run the bot +npm start +``` + +## Contributing + +If you have suggestions for how codebadge-test1 could be improved, or want to report a bug, open an issue! We'd love all and any contributions. + +For more, check out the [Contributing Guide](CONTRIBUTING.md). + +## License + +[ISC](LICENSE) © 2020 ayushnagar123 diff --git a/codebadge-bot/app.yml b/codebadge-bot/app.yml new file mode 100644 index 0000000..2491f5a --- /dev/null +++ b/codebadge-bot/app.yml @@ -0,0 +1,139 @@ +# This is a GitHub App Manifest. These settings will be used by default when +# initially configuring your GitHub App. +# +# NOTE: changing this file will not update your GitHub App settings. +# You must visit github.com/settings/apps/your-app-name to edit them. +# +# Read more about configuring your GitHub App: +# https://probot.github.io/docs/development/#configuring-a-github-app +# +# Read more about GitHub App Manifests: +# https://developer.github.com/apps/building-github-apps/creating-github-apps-from-a-manifest/ + +# The list of events the GitHub App subscribes to. +# Uncomment the event names below to enable them. +default_events: +- check_run +# - check_suite +- commit_comment +# - create +# - delete +# - deployment +# - deployment_status +# - fork +# - gollum +- issue_comment +- issues +- label +- milestone +# - member +# - membership +# - org_block +# - organization +# - page_build +# - project +- project_card +- project_column +# - public +- pull_request +- pull_request_review +- pull_request_review_comment +- push +# - release +- repository +- repository_import +- status +# - team +# - team_add +# - watch + +# The set of permissions needed by the GitHub App. The format of the object uses +# the permission name for the key (for example, issues) and the access type for +# the value (for example, write). +# Valid values are `read`, `write`, and `none` +default_permissions: + # Repository creation, deletion, settings, teams, and collaborators. + # https://developer.github.com/v3/apps/permissions/#permission-on-administration + administration: read + + # Checks on code. + # https://developer.github.com/v3/apps/permissions/#permission-on-checks + checks: read + + # Repository contents, commits, branches, downloads, releases, and merges. + # https://developer.github.com/v3/apps/permissions/#permission-on-contents + contents: read + + # Deployments and deployment statuses. + # https://developer.github.com/v3/apps/permissions/#permission-on-deployments + # deployments: read + + # Issues and related comments, assignees, labels, and milestones. + # https://developer.github.com/v3/apps/permissions/#permission-on-issues + issues: write + + # Search repositories, list collaborators, and access repository metadata. + # https://developer.github.com/v3/apps/permissions/#metadata-permissions + metadata: read + + # Retrieve Pages statuses, configuration, and builds, as well as create new builds. + # https://developer.github.com/v3/apps/permissions/#permission-on-pages + # pages: read + + # Pull requests and related comments, assignees, labels, milestones, and merges. + # https://developer.github.com/v3/apps/permissions/#permission-on-pull-requests + pull_requests: write + + # Manage the post-receive hooks for a repository. + # https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks + # repository_hooks: read + + # Manage repository projects, columns, and cards. + # https://developer.github.com/v3/apps/permissions/#permission-on-repository-projects + repository_projects: write + + # Retrieve security vulnerability alerts. + # https://developer.github.com/v4/object/repositoryvulnerabilityalert/ + # vulnerability_alerts: read + + # Commit statuses. + # https://developer.github.com/v3/apps/permissions/#permission-on-statuses + statuses: read + + # Organization members and teams. + # https://developer.github.com/v3/apps/permissions/#permission-on-members + # members: read + + # View and manage users blocked by the organization. + # https://developer.github.com/v3/apps/permissions/#permission-on-organization-user-blocking + # organization_user_blocking: read + + # Manage organization projects, columns, and cards. + # https://developer.github.com/v3/apps/permissions/#permission-on-organization-projects + # organization_projects: read + + # Manage team discussions and related comments. + # https://developer.github.com/v3/apps/permissions/#permission-on-team-discussions + # team_discussions: read + + # Manage the post-receive hooks for an organization. + # https://developer.github.com/v3/apps/permissions/#permission-on-organization-hooks + # organization_hooks: read + + # Get notified of, and update, content references. + # https://developer.github.com/v3/apps/permissions/ + # organization_administration: read + + +# The name of the GitHub App. Defaults to the name specified in package.json +name: Codebadge-bot + +# The homepage of your GitHub App. +# url: https://example.com/ + +# A description of the GitHub App. +# description: A description of my awesome app + +# Set to true when your GitHub App is available to the public or false when it is only accessible to the owner of the app. +# Default: true +# public: false diff --git a/codebadge-bot/badgeAllocation/levelBadge.js b/codebadge-bot/badgeAllocation/levelBadge.js new file mode 100644 index 0000000..7a715eb --- /dev/null +++ b/codebadge-bot/badgeAllocation/levelBadge.js @@ -0,0 +1,22 @@ +function new_commer(username){ + return true +} +function learners(username){ + return true +} +function experienced(username){ + return true +} +function coreContributor(username){ + return true +} +function expert(username){ + return true +} +module.exports={ + new_commer, + learners, + experienced, + expert, + coreContributor +} \ No newline at end of file diff --git a/codebadge-bot/badgeAllocation/speacialBadges.js b/codebadge-bot/badgeAllocation/speacialBadges.js new file mode 100644 index 0000000..9f51bc4 --- /dev/null +++ b/codebadge-bot/badgeAllocation/speacialBadges.js @@ -0,0 +1,18 @@ +function contributorOftheWeek(username){ + return true +} +function contributorOftheMonth(username){ + return true +} +function contributorOftheYear(username){ + return true +} +function BestContributor(username){ + return true +} +module.exports={ + contributorOftheWeek, + contributorOftheMonth, + contributorOftheYear, + BestContributor +} \ No newline at end of file diff --git a/codebadge-bot/index.js b/codebadge-bot/index.js new file mode 100644 index 0000000..f333b86 --- /dev/null +++ b/codebadge-bot/index.js @@ -0,0 +1,94 @@ +/** + * This is the main entrypoint to your Probot app + * @param {import('probot').Application} app + */ +// const attachments = require('probot-attachments'); +module.exports = app => { + // Your code here + const axios = require('axios') + app.log('Yay, the app was loaded!') + const levelBadges = require('./badgeAllocation/levelBadge') + const specialBadges = require('./badgeAllocation/speacialBadges') + app.on('issues.opened', async context => { + console.log(context.payload.issue.body) + var user = context.payload.issue.user.login + let data={ + text:context.payload.issue.body + } + axios.post("http://localhost:5000/issue/template",data) + .then(res=>{ + if(res.data.match){ + // increase points + var issueComment = context.issue({ body: `Hey @${user} 👋,thanks for raising this issue! Our team will have a look at it. Would you like to work on this issue?` }) + return context.github.issues.createComment(issueComment); + } + else{ + var issueComment = context.issue({ body: `Hey @${user} 👋. Please follow the issue template` }) + return context.github.issues.createComment(issueComment); + } + }) + .catch(err=>{console.log(err)}) + // return context.github.issues.createComment(issueComment) + }) + app.on('pull_request.opened', async context => { + const pr =context.payload.pull_request + const user = pr.user.login //Collecting Details of the person who created the PR + let data={ + text:context.payload.issue.body + } + axios.post("http://localhost:5000/pr/template",data) + .then(res=>{ + if(res.data.match){ + var issueComment = context.issue({ body: `Hey @${user} 👋,thanks for th pull request! Our team will have a look at it.` }) + return context.github.issues.createComment(issueComment); + } + else{ + var issueComment = context.issue({ body: `Hey @${user} 👋. Please follow the pull request template` }) + return context.github.issues.createComment(issueComment); + } + }) + .catch(err=>{console.log(err)}) + }) + + app.on('issue_comment.created', async context => { + // if(context.github.issues.t) + if(context.payload.comment.user.login!=="codebadge-test1[bot]"){ + // const issueComment = context.issue({ body: `Thanks for making a comment ` }) + const user = context.payload.comment.user.login + const org = context.payload.organization.login + // if(levelBadges.new_commer(context.payload.comment.user.login)){ + // const msg=context.issue({body:`Hey @${user} 👋, Thanks for the putting up your views !!! You looks to be a new commer to @${org}. You are earning a **bigginer's badge** for your first contribution. Keep contributing!:clap:\ndrawing `}) + // return context.github.issues.createComment(msg) + // } + // else if(levelBadges.learners(context.payload.comment.user.login)){ + // const msg=context.issue({body:`Hey @${user} 👋, Thanks for the putting up your views !!! You looks to be a new commer to @${org}. You are earning a **bigginer's badge** for your first contribution. Keep contributing!:clap:\ndrawing `}) + // return context.github.issues.createComment(msg) + // } + // else if(levelBadges.experienced(context.payload.comment.user.login)){ + // const msg=context.issue({body:`Hey @${user} 👋, Thanks for the putting up your views !!! You looks to be a new commer to @${org}. You are earning a **bigginer's badge** for your first contribution. Keep contributing!:clap:\ndrawing `}) + // return context.github.issues.createComment(msg) + // } + // else if(levelBadges.coreContributor(context.payload.comment.user.login)){ + // const msg=context.issue({body:`Hey @${user} 👋, Thanks for the putting up your views !!! You looks to be a new commer to @${org}. You are earning a **bigginer's badge** for your first contribution. Keep contributing!:clap:\ndrawing `}) + // return context.github.issues.createComment(msg) + // } + // else{ + // const url = "https://cdn5.vectorstock.com/i/1000x1000/03/39/expert-round-isolated-gold-badge-vector-16610339.jpg" + // const msg=context.issue({body:`Hey @${user} 👋, Thanks for the putting up your views !!! It looks that you have experticed working with @${org} and its projects. You are earning a **expert's badge** for your immence contribution. Keep contributing!:clap:\ndrawing `}) + // return context.github.issues.createComment(msg) + // } + // return context.github.issues.createComment(issueComment) + } + }) + + // app.on('push', async context => { + // const issueComment = context.issue({ body: 'Thanks for push' }) + // return context.github.pull_request.createComment(issueComment) + // }) + + // For more information on building apps: + // https://probot.github.io/docs/ + + // To get your app running against GitHub, see: + // https://probot.github.io/docs/development/ +} \ No newline at end of file diff --git a/codebadge-bot/package.json b/codebadge-bot/package.json new file mode 100644 index 0000000..29ba34c --- /dev/null +++ b/codebadge-bot/package.json @@ -0,0 +1,52 @@ +{ + "name": "codebadge-test1", + "version": "1.0.0", + "private": true, + "description": "testing bot for codebadge-bot", + "author": "ayushnagar123 ", + "license": "ISC", + "repository": "https://github.com/ayushnagar123/codebadge.git", + "homepage": "https://github.com/ayushnagar123/codebadge", + "bugs": "https://github.com/ayushnagar123/codebadge/issues", + "keywords": [ + "probot", + "github", + "probot-app" + ], + "scripts": { + "dev": "nodemon", + "start": "probot run ./index.js", + "lint": "standard --fix", + "test": "jest && standard", + "test:watch": "jest --watch --notify --notifyMode=change --coverage" + }, + "dependencies": { + "axios": "^0.19.2", + "probot": "^9.5.3" + }, + "devDependencies": { + "jest": "^24.9.0", + "nock": "^12.0.0", + "nodemon": "^2.0.0", + "smee-client": "^1.1.0", + "standard": "^14.3.1" + }, + "engines": { + "node": ">= 8.3.0" + }, + "standard": { + "env": [ + "jest" + ] + }, + "nodemonConfig": { + "exec": "npm start", + "watch": [ + ".env", + "." + ] + }, + "jest": { + "testEnvironment": "node" + } +} diff --git a/codebadge-bot/test/fixtures/issues.opened.json b/codebadge-bot/test/fixtures/issues.opened.json new file mode 100644 index 0000000..dfd976c --- /dev/null +++ b/codebadge-bot/test/fixtures/issues.opened.json @@ -0,0 +1,15 @@ +{ + "action": "opened", + "issue": { + "number": 1, + "user": { + "login": "hiimbex" + } + }, + "repository": { + "name": "testing-things", + "owner": { + "login": "hiimbex" + } + } +} diff --git a/codebadge-bot/test/fixtures/mock-cert.pem b/codebadge-bot/test/fixtures/mock-cert.pem new file mode 100644 index 0000000..f2f271c --- /dev/null +++ b/codebadge-bot/test/fixtures/mock-cert.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAli7V49NdZe+XYC1pLaHM0te8kiDmZBJ1u2HJHN8GdbROB6NO +VpC3xK7NxQn6xpvZ9ux20NvcDvGle+DOptZztBH+np6h2jZQ1/kD1yG1eQvVH4th +/9oqHuIjmIfO8lIe4Hyd5Fw5xHkGqVETTGR+0c7kdZIlHmkOregUGtMYZRUi4YG+ +q0w+uFemiHpGKXbeCIAvkq7aIkisEzvPWfSyYdA6WJHpxFk7tD7D8VkzABLVRHCq +AuyqPG39BhGZcGLXx5rGK56kDBJkyTR1t3DkHpwX+JKNG5UYNwOG4LcQj1fteeta +TdkYUMjIyWbanlMYyC+dq7B5fe7el99jXQ1gXwIDAQABAoIBADKfiPOpzKLOtzzx +MbHzB0LO+75aHq7+1faayJrVxqyoYWELuB1P3NIMhknzyjdmU3t7S7WtVqkm5Twz +lBUC1q+NHUHEgRQ4GNokExpSP4SU63sdlaQTmv0cBxmkNarS6ZuMBgDy4XoLvaYX +MSUf/uukDLhg0ehFS3BteVFtdJyllhDdTenF1Nb1rAeN4egt8XLsE5NQDr1szFEG +xH5lb+8EDtzgsGpeIddWR64xP0lDIKSZWst/toYKWiwjaY9uZCfAhvYQ1RsO7L/t +sERmpYgh+rAZUh/Lr98EI8BPSPhzFcSHmtqzzejvC5zrZPHcUimz0CGA3YBiLoJX +V1OrxmECgYEAxkd8gpmVP+LEWB3lqpSvJaXcGkbzcDb9m0OPzHUAJDZtiIIf0UmO +nvL68/mzbCHSj+yFjZeG1rsrAVrOzrfDCuXjAv+JkEtEx0DIevU1u60lGnevOeky +r8Be7pmymFB9/gzQAd5ezIlTv/COgoO986a3h1yfhzrrzbqSiivw308CgYEAwecI +aZZwqH3GifR+0+Z1B48cezA5tC8LZt5yObGzUfxKTWy30d7lxe9N59t0KUVt/QL5 +qVkd7mqGzsUMyxUN2U2HVnFTWfUFMhkn/OnCnayhILs8UlCTD2Xxoy1KbQH/9FIr +xf0pbMNJLXeGfyRt/8H+BzSZKBw9opJBWE4gqfECgYBp9FdvvryHuBkt8UQCRJPX +rWsRy6pY47nf11mnazpZH5Cmqspv3zvMapF6AIxFk0leyYiQolFWvAv+HFV5F6+t +Si1mM8GCDwbA5zh6pEBDewHhw+UqMBh63HSeUhmi1RiOwrAA36CO8i+D2Pt+eQHv +ir52IiPJcs4BUNrv5Q1BdwKBgBHgVNw3LGe8QMOTMOYkRwHNZdjNl2RPOgPf2jQL +d/bFBayhq0jD/fcDmvEXQFxVtFAxKAc+2g2S8J67d/R5Gm/AQAvuIrsWZcY6n38n +pfOXaLt1x5fnKcevpFlg4Y2vM4O416RHNLx8PJDehh3Oo/2CSwMrDDuwbtZAGZok +icphAoGBAI74Tisfn+aeCZMrO8KxaWS5r2CD1KVzddEMRKlJvSKTY+dOCtJ+XKj1 +OsZdcDvDC5GtgcywHsYeOWHldgDWY1S8Z/PUo4eK9qBXYBXp3JEZQ1dqzFdz+Txi +rBn2WsFLsxV9j2/ugm0PqWVBcU2bPUCwvaRu3SOms2teaLwGCkhr +-----END RSA PRIVATE KEY----- diff --git a/codebadge-bot/test/index.test.js b/codebadge-bot/test/index.test.js new file mode 100644 index 0000000..5e2923a --- /dev/null +++ b/codebadge-bot/test/index.test.js @@ -0,0 +1,58 @@ +const nock = require('nock') +// Requiring our app implementation +const myProbotApp = require('..') +const { Probot } = require('probot') +// Requiring our fixtures +const payload = require('./fixtures/issues.opened') +const issueCreatedBody = { body: 'Thanks for opening this issue!' } +const fs = require('fs') +const path = require('path') + +describe('My Probot app', () => { + let probot + let mockCert + + beforeAll((done) => { + fs.readFile(path.join(__dirname, 'fixtures/mock-cert.pem'), (err, cert) => { + if (err) return done(err) + mockCert = cert + done() + }) + }) + + beforeEach(() => { + nock.disableNetConnect() + probot = new Probot({ id: 123, cert: mockCert }) + // Load our app into probot + probot.load(myProbotApp) + }) + + test('creates a comment when an issue is opened', async () => { + // Test that we correctly return a test token + nock('https://api.github.com') + .post('/app/installations/2/access_tokens') + .reply(200, { token: 'test' }) + + // Test that a comment is posted + nock('https://api.github.com') + .post('/repos/hiimbex/testing-things/issues/1/comments', (body) => { + expect(body).toMatchObject(issueCreatedBody) + return true + }) + .reply(200) + + // Receive a webhook event + await probot.receive({ name: 'issues', payload }) + }) + + afterEach(() => { + nock.cleanAll() + nock.enableNetConnect() + }) +}) + +// For more information about testing with Jest see: +// https://facebook.github.io/jest/ + +// For more information about testing with Nock see: +// https://github.com/nock/nock diff --git a/.browserslistrc b/frontend/.browserslistrc similarity index 100% rename from .browserslistrc rename to frontend/.browserslistrc diff --git a/.eslintrc.js b/frontend/.eslintrc.js similarity index 100% rename from .eslintrc.js rename to frontend/.eslintrc.js diff --git a/.gitignore b/frontend/.gitignore similarity index 100% rename from .gitignore rename to frontend/.gitignore diff --git a/.travis.yml b/frontend/.travis.yml similarity index 100% rename from .travis.yml rename to frontend/.travis.yml diff --git a/CODE_OF_CONDUCT.md b/frontend/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to frontend/CODE_OF_CONDUCT.md diff --git a/babel.config.js b/frontend/babel.config.js similarity index 100% rename from babel.config.js rename to frontend/babel.config.js diff --git a/package.json b/frontend/package.json similarity index 100% rename from package.json rename to frontend/package.json diff --git a/postcss.config.js b/frontend/postcss.config.js similarity index 100% rename from postcss.config.js rename to frontend/postcss.config.js diff --git a/public/assets/badges/predefined/babysteps.png b/frontend/public/assets/badges/predefined/babysteps.png similarity index 100% rename from public/assets/badges/predefined/babysteps.png rename to frontend/public/assets/badges/predefined/babysteps.png diff --git a/public/assets/badges/special/topcommits.png b/frontend/public/assets/badges/special/topcommits.png similarity index 100% rename from public/assets/badges/special/topcommits.png rename to frontend/public/assets/badges/special/topcommits.png diff --git a/public/assets/badges/special/topmonthcommits.png b/frontend/public/assets/badges/special/topmonthcommits.png similarity index 100% rename from public/assets/badges/special/topmonthcommits.png rename to frontend/public/assets/badges/special/topmonthcommits.png diff --git a/public/assets/badges/special/topweekcommits.png b/frontend/public/assets/badges/special/topweekcommits.png similarity index 100% rename from public/assets/badges/special/topweekcommits.png rename to frontend/public/assets/badges/special/topweekcommits.png diff --git a/public/assets/badges/special/topyearcommits.png b/frontend/public/assets/badges/special/topyearcommits.png similarity index 100% rename from public/assets/badges/special/topyearcommits.png rename to frontend/public/assets/badges/special/topyearcommits.png diff --git a/public/favicon.ico b/frontend/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to frontend/public/favicon.ico diff --git a/public/index.html b/frontend/public/index.html similarity index 100% rename from public/index.html rename to frontend/public/index.html diff --git a/src/App.vue b/frontend/src/App.vue similarity index 100% rename from src/App.vue rename to frontend/src/App.vue diff --git a/src/assets/badges/predefined/badges.json b/frontend/src/assets/badges/predefined/badges.json similarity index 100% rename from src/assets/badges/predefined/badges.json rename to frontend/src/assets/badges/predefined/badges.json diff --git a/src/assets/badges/predefined/predefinedBadges.js b/frontend/src/assets/badges/predefined/predefinedBadges.js similarity index 100% rename from src/assets/badges/predefined/predefinedBadges.js rename to frontend/src/assets/badges/predefined/predefinedBadges.js diff --git a/src/assets/badges/special/badges.json b/frontend/src/assets/badges/special/badges.json similarity index 100% rename from src/assets/badges/special/badges.json rename to frontend/src/assets/badges/special/badges.json diff --git a/src/assets/badges/special/specialBadges.js b/frontend/src/assets/badges/special/specialBadges.js similarity index 100% rename from src/assets/badges/special/specialBadges.js rename to frontend/src/assets/badges/special/specialBadges.js diff --git a/src/assets/loaders/bars.svg b/frontend/src/assets/loaders/bars.svg similarity index 100% rename from src/assets/loaders/bars.svg rename to frontend/src/assets/loaders/bars.svg diff --git a/src/assets/loaders/block.svg b/frontend/src/assets/loaders/block.svg similarity index 100% rename from src/assets/loaders/block.svg rename to frontend/src/assets/loaders/block.svg diff --git a/src/assets/upload.svg b/frontend/src/assets/upload.svg similarity index 100% rename from src/assets/upload.svg rename to frontend/src/assets/upload.svg diff --git a/src/components/auth/Login.vue b/frontend/src/components/auth/Login.vue similarity index 100% rename from src/components/auth/Login.vue rename to frontend/src/components/auth/Login.vue diff --git a/src/components/badgeList/BadgeListItem.vue b/frontend/src/components/badgeList/BadgeListItem.vue similarity index 100% rename from src/components/badgeList/BadgeListItem.vue rename to frontend/src/components/badgeList/BadgeListItem.vue diff --git a/src/components/general/Toolbar.vue b/frontend/src/components/general/Toolbar.vue similarity index 100% rename from src/components/general/Toolbar.vue rename to frontend/src/components/general/Toolbar.vue diff --git a/src/components/home/OrgList.vue b/frontend/src/components/home/OrgList.vue similarity index 100% rename from src/components/home/OrgList.vue rename to frontend/src/components/home/OrgList.vue diff --git a/src/components/home/UserDetails.vue b/frontend/src/components/home/UserDetails.vue similarity index 100% rename from src/components/home/UserDetails.vue rename to frontend/src/components/home/UserDetails.vue diff --git a/src/components/newBadge/DrawButtons.vue b/frontend/src/components/newBadge/DrawButtons.vue similarity index 100% rename from src/components/newBadge/DrawButtons.vue rename to frontend/src/components/newBadge/DrawButtons.vue diff --git a/src/components/newBadge/ToolButtons.vue b/frontend/src/components/newBadge/ToolButtons.vue similarity index 100% rename from src/components/newBadge/ToolButtons.vue rename to frontend/src/components/newBadge/ToolButtons.vue diff --git a/src/components/org/ContributorItem.vue b/frontend/src/components/org/ContributorItem.vue similarity index 100% rename from src/components/org/ContributorItem.vue rename to frontend/src/components/org/ContributorItem.vue diff --git a/src/components/org/Org.vue b/frontend/src/components/org/Org.vue similarity index 100% rename from src/components/org/Org.vue rename to frontend/src/components/org/Org.vue diff --git a/src/components/org/OrgContributors.vue b/frontend/src/components/org/OrgContributors.vue similarity index 100% rename from src/components/org/OrgContributors.vue rename to frontend/src/components/org/OrgContributors.vue diff --git a/src/components/org/OrgDetails.vue b/frontend/src/components/org/OrgDetails.vue similarity index 100% rename from src/components/org/OrgDetails.vue rename to frontend/src/components/org/OrgDetails.vue diff --git a/src/components/org/OrgRepos.vue b/frontend/src/components/org/OrgRepos.vue similarity index 100% rename from src/components/org/OrgRepos.vue rename to frontend/src/components/org/OrgRepos.vue diff --git a/src/components/org/RepoContributors.vue b/frontend/src/components/org/RepoContributors.vue similarity index 100% rename from src/components/org/RepoContributors.vue rename to frontend/src/components/org/RepoContributors.vue diff --git a/src/config/AxiosHelper.js b/frontend/src/config/AxiosHelper.js similarity index 100% rename from src/config/AxiosHelper.js rename to frontend/src/config/AxiosHelper.js diff --git a/src/main.js b/frontend/src/main.js similarity index 100% rename from src/main.js rename to frontend/src/main.js diff --git a/src/plugins/vuetify.js b/frontend/src/plugins/vuetify.js similarity index 100% rename from src/plugins/vuetify.js rename to frontend/src/plugins/vuetify.js diff --git a/src/router.js b/frontend/src/router.js similarity index 100% rename from src/router.js rename to frontend/src/router.js diff --git a/src/services/authService.js b/frontend/src/services/authService.js similarity index 100% rename from src/services/authService.js rename to frontend/src/services/authService.js diff --git a/src/store.js b/frontend/src/store.js similarity index 100% rename from src/store.js rename to frontend/src/store.js diff --git a/src/views/AuthView.vue b/frontend/src/views/AuthView.vue similarity index 100% rename from src/views/AuthView.vue rename to frontend/src/views/AuthView.vue diff --git a/src/views/BadgeView.vue b/frontend/src/views/BadgeView.vue similarity index 100% rename from src/views/BadgeView.vue rename to frontend/src/views/BadgeView.vue diff --git a/src/views/HomeView.vue b/frontend/src/views/HomeView.vue similarity index 100% rename from src/views/HomeView.vue rename to frontend/src/views/HomeView.vue diff --git a/src/views/NewBadge.vue b/frontend/src/views/NewBadge.vue similarity index 100% rename from src/views/NewBadge.vue rename to frontend/src/views/NewBadge.vue diff --git a/src/views/OrgView.vue b/frontend/src/views/OrgView.vue similarity index 100% rename from src/views/OrgView.vue rename to frontend/src/views/OrgView.vue diff --git a/src/views/Upload.vue b/frontend/src/views/Upload.vue similarity index 100% rename from src/views/Upload.vue rename to frontend/src/views/Upload.vue diff --git a/vue.config.js b/frontend/vue.config.js similarity index 100% rename from vue.config.js rename to frontend/vue.config.js diff --git a/backend/colorpic.jpg b/processing/colorpic.jpg similarity index 100% rename from backend/colorpic.jpg rename to processing/colorpic.jpg diff --git a/backend/colors.csv b/processing/colors.csv similarity index 100% rename from backend/colors.csv rename to processing/colors.csv diff --git a/backend/requirements.txt b/processing/requirements.txt similarity index 100% rename from backend/requirements.txt rename to processing/requirements.txt diff --git a/backend/run.py b/processing/run.py similarity index 92% rename from backend/run.py rename to processing/run.py index 3c3c28f..4e0331d 100644 --- a/backend/run.py +++ b/processing/run.py @@ -8,6 +8,7 @@ from werkzeug.utils import secure_filename import os import pandas as pd +from webhook import issue app = Flask(__name__, static_folder = "./dist/static", @@ -88,13 +89,11 @@ def getColour(csv,R,G,B): @app.route('/api/picktool',methods=['GET','POST']) def picktool(): - data = request.files['image'] img = Image.open(request.files['image']) img = np.array(img) img = cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB) x,y,z = np.shape(img) - print(x,y,z) # r = g = b = 0 xpos = int(request.values['xpos']) ypos = int(request.values['ypos']) @@ -114,5 +113,11 @@ def picktool(): else: return jsonify({'name':'NONE' , 'hex':'-9999'}) +@app.route('/issue/template', methods=['POST']) +def check_issue(): + text = request.json['text'] + return jsonify(match=issue.template_match(text)) - +if __name__ == '__main__': + app.run(host='127.0.0.1', port=5000, debug=True) + diff --git a/backend/run.pyc b/processing/run.pyc similarity index 100% rename from backend/run.pyc rename to processing/run.pyc diff --git a/processing/webhook/__pycache__/issue.cpython-36.pyc b/processing/webhook/__pycache__/issue.cpython-36.pyc new file mode 100644 index 0000000..03e30ad Binary files /dev/null and b/processing/webhook/__pycache__/issue.cpython-36.pyc differ diff --git a/processing/webhook/comment.py b/processing/webhook/comment.py new file mode 100644 index 0000000..e69de29 diff --git a/processing/webhook/issue.py b/processing/webhook/issue.py new file mode 100644 index 0000000..e9f3c18 --- /dev/null +++ b/processing/webhook/issue.py @@ -0,0 +1,12 @@ +# from flask import Flask, render_template +import re +# app = Flask(__name__) + +def template_match(text_string): + print(text_string) + result = re.match("## Description of the problem[\r\n](?s).*[\r\n]## How to solve[\r\n](?s).*[\r\n]## Expected Outcome(?s).*", text_string) + if(result): + return True + else: + return False + \ No newline at end of file diff --git a/processing/webhook/pr.py b/processing/webhook/pr.py new file mode 100644 index 0000000..e69de29