Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Issue Creation Feature to Github-Discord Webhook to Improve Communication #82

Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ Thumbs.db
# Next.js
.next
out

# env
.env
10 changes: 10 additions & 0 deletions apps/discord-to-github-bot/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import antfu from '@antfu/eslint-config'
// import playwright from 'eslint-plugin-playwright'

export default antfu(
{
formatters: true,
react: true,

},
)
41 changes: 41 additions & 0 deletions apps/discord-to-github-bot/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "discord-to-github-bot",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/discord-to-github-bot/src",
"projectType": "application",
"tags": [],
"targets": {
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"dependsOn": ["build"],
"options": {
"buildTarget": "discord-to-github-bot:build",
"runBuildTargetDependencies": false
},
"configurations": {
"development": {
"buildTarget": "discord-to-github-bot:build:development"
},
"production": {
"buildTarget": "discord-to-github-bot:build:production"
}
}
},
"dev": {
"executor": "nx:run-commands",
"options": {
"command": "ts-node-dev --respawn src/main.ts",
"cwd": "apps/discord-to-github-bot",
"parallel": false
}
},
"unit-test": {
"executor": "nx:run-commands",
"options": {
"command": "vitest run",
"cwd": "apps/discord-to-github-bot"
}
}
}
}
Empty file.
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions apps/discord-to-github-bot/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
*/

import process from 'node:process'
import express from 'express'

const app = express()

app.get('/', (req, res) => {
res.send({ message: 'Welcome to discord-to-github-bot!' })
})

const port = process.env.PORT || 3333
const server = app.listen(port, () => {
})
server.on('error', console.error)
7 changes: 7 additions & 0 deletions apps/discord-to-github-bot/src/services/create-issue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function isValidIssue(issueContent: object) {
return issueContent
}

export function createIssue(issueContent: object) {
return issueContent
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function getAllIssues() {
return ''
}

export function getIssue(issueTemplate: string) {
return issueTemplate
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function verifyCorrectMessage(message: string) {
return message
}
28 changes: 28 additions & 0 deletions apps/discord-to-github-bot/tests/unit/create-issue.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { describe, expect, it } from 'vitest'
import { createIssue, isValidIssue } from '@services/create-issue'

describe('create an issue test', () => {
it('should return true to signal that this is a valid issue format', () => {
const mockIssue = { title: 'bug', body: 'this is a mock issue', labels: ['bug'] }
const res = isValidIssue(mockIssue)
expect(res).toBe(true)
})

it('should return false because there is no title', () => {
const mockIssue = { title: '', body: 'this is a mock issue', labels: [''] } //
const res = isValidIssue(mockIssue)
expect(res).toBe(false)
})

it('should return false because the keys are invalid', () => {
const mockIssue = { title: '', content: 'this is a mock issue', labels: [''] } //
const res = isValidIssue(mockIssue)
expect(res).toBe(false)
})

it('should return successfully create an issue', () => {
const mockIssue = { title: 'bug', body: 'this is a mock issue', labels: ['bug'] }
const res = createIssue(mockIssue)
expect(res.message).toBe('Issue created')
})
})
29 changes: 29 additions & 0 deletions apps/discord-to-github-bot/tests/unit/get-issue-templates.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { describe, expect, it } from 'vitest'
import { getAllIssues, getIssue } from '@services/get-issue-templates'

describe('retrieving issue tests', () => {
it('should recieve the name of all issue tempaltes', () => {
const res = getAllIssues()
expect(res).toBe(['architectural-design-record--adr-.md', 'bug_report.md', 'feature-improvement.md', 'task.md'])
})
it('should recieve the issue template for a Bug Report', () => {
const res = getIssue('bug_report.md')
expect(res.name).toBe('Bug Report')
})
it('should recieve the issue template for an ADR', () => {
const res = getIssue('bug_report.md')
expect(res.name).toBe('Bug Report')
})
it('should recieve the issue template for a doc', () => {
const res = getIssue('docs.md')
expect(res.name).toBe('Docs')
})
it('should recieve the issue template for a feature', () => {
const res = getIssue('feature.md')
expect(res.name).toBe('feature')
})
it('should recieve no issue tempalte', () => {
const res = getIssue('not-a-real-issue.md')
expect(res.name).toBe('invalid')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest'
import { verifyCorrectMessage } from '@services/slash-command-verification'

describe('slash commands tests', () => {
it('should identify message as a slash command to create an issue', () => {
const message = '/create-issue'
const res = verifyCorrectMessage(message)
expect(res).toBe('create-issue')
})
it('should identify message as a slash command to retrieve all issue templates', () => {
const message = '/issue-templates'
const res = verifyCorrectMessage(message)
expect(res).toBe('retrieve-issue-templates')
})
it ('should identify message as a non-special slash command', () => {
const message = '/nothing'
const res = verifyCorrectMessage(message)
expect(res).toBe('command not found')
})
})
10 changes: 10 additions & 0 deletions apps/discord-to-github-bot/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"types": ["node", "express"],
"outDir": "../../dist/out-tsc"
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
}
22 changes: 22 additions & 0 deletions apps/discord-to-github-bot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": ".",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"paths": {
"@src/*": ["src/*"],
"@services/*": ["src/services/*"]
},
"esModuleInterop": true
},
"references": [
{
"path": "./tsconfig.app.json"
}
],
"files": [],
"include": [
"apps/discord-to-github-bot/src/**/*"
]
}
15 changes: 15 additions & 0 deletions apps/discord-to-github-bot/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import path from 'node:path'
import { defineConfig } from 'vitest/config'
// TODO: refactor after monorepo migration
// see: https://vitest.dev/guide/workspace.html
const config = defineConfig({
test: {
include: ['tests/unit/**/*.ts'],
name: 'discord-to-github-bot',
environment: 'node',
alias: {
'@services/': new URL('./src/services/', import.meta.url).pathname,
},
},
})
export default config
19 changes: 19 additions & 0 deletions apps/discord-to-github-bot/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { join } = require('node:path')
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin')

module.exports = {
output: {
path: join(__dirname, '../../dist/apps/discord-to-github-bot'),
},
plugins: [
new NxAppWebpackPlugin({
target: 'node',
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
assets: ['./src/assets'],
optimization: false,
outputHashing: 'none',
}),
],
}
8 changes: 8 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@
"options": {
"targetName": "test"
}
},
{
"plugin": "@nx/webpack/plugin",
"options": {
"buildTargetName": "build",
"serveTargetName": "serve",
"previewTargetName": "preview"
}
}
],
"generators": {
Expand Down
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"@remix-run/node": "^2.8.1",
"@remix-run/react": "^2.8.1",
"@remix-run/serve": "^2.8.1",
"axios": "^1.6.0",
"discord.js": "^14.15.3",
"express": "^4.19.2",
"fumadocs-core": "^13.0.4",
"fumadocs-docgen": "^1.1.0",
"fumadocs-mdx": "^9.0.0",
Expand All @@ -44,23 +47,29 @@
"@nx/devkit": "19.5.7",
"@nx/eslint": "19.5.7",
"@nx/eslint-plugin": "19.5.7",
"@nx/express": "19.5.7",
"@nx/jest": "19.5.7",
"@nx/js": "19.5.7",
"@nx/next": "19.5.7",
"@nx/node": "19.5.7",
"@nx/playwright": "19.5.7",
"@nx/remix": "19.5.7",
"@nx/vite": "^19.6.0",
"@nx/web": "19.5.7",
"@nx/webpack": "19.5.7",
"@nx/workspace": "19.5.7",
"@playwright/test": "^1.36.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@remix-run/dev": "^2.8.1",
"@remix-run/testing": "^2.8.1",
"@svgr/webpack": "^8.0.1",
"@swc-node/register": "~1.9.1",
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.11",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "15.0.6",
"@testing-library/user-event": "^14.5.2",
"@types/express": "^4.17.21",
"@types/jest": "^29.4.0",
"@types/mdx": "^2.0.13",
"@types/node": "18.16.9",
Expand Down Expand Up @@ -90,23 +99,28 @@
"inquirer": "^9.3.6",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jest-environment-node": "^29.4.1",
"jsdom": "~22.1.0",
"katex": "^0.16.11",
"lint-staged": "^15.2.8",
"lucide-react": "^0.427.0",
"nodemon": "^3.1.4",
"nx": "19.5.7",
"postcss": "8.4.38",
"prettier": "^2.6.2",
"react-refresh": "^0.10.0",
"rehype-katex": "^7.0.0",
"rehype-mermaid": "^2.1.0",
"remark-math": "^6.0.0",
"semantic-release": "^24.1.0",
"tailwindcss": "3.4.3",
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"ts-node": "10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "~5.5.2",
"vite": "^5.0.0",
"vitest": "^2.0.5"
"vitest": "^2.0.5",
"webpack-cli": "^5.1.4"
},
"lint-staged": {
"*": "eslint --cache --fix"
Expand Down
Loading
Loading