Skip to content

Commit

Permalink
Merge pull request #341 from vishnoianil/pr-post
Browse files Browse the repository at this point in the history
Add UI for submitting the PR for skill and knowledge
  • Loading branch information
mergify[bot] authored May 15, 2024
2 parents ee3eea1 + 6d8745c commit 7a3161d
Show file tree
Hide file tree
Showing 21 changed files with 1,955 additions and 17 deletions.
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude_paths:
- compose.yaml
- .github/
- ui/
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ILBOT_WEBHOOK_PROXY_URL=https://smee.io/your-webhook-proxy-url
# Github App Id after bot's registration.
ILBOT_GITHUB_INTEGRATION_ID=your-github-app-id

# Taxonomy URL
ILBOT_TAXONOMY_REPO=<taxonomy-repo-url>

# Webhook secret created during bot registration
ILBOT_GITHUB_WEBHOOK_SECRET=your-webhook-secret

Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"deploy/ansible/*.yml": "ansible"
},
"cSpell.words": [
"githttp",
"Pallinder",
"triagers"
]
}
3 changes: 3 additions & 0 deletions deploy/compose/dev-single-worker-with-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ services:
- ../../.env
depends_on:
- redis
ports:
- 8081:8081


bot-ui:
container_name: ui
Expand Down
24 changes: 21 additions & 3 deletions gobot/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ var (
HTTPAddress string
HTTPPort int
GithubIntegrationID int
TaxonomyRepo string
GithubURL string
GithubWebhookSecret string
GithubAppPrivateKey string
WebhookProxyURL string
GithubUsername string
GithubToken string
RequiredLabels []string
Maintainers []string
BotUsername string
Expand All @@ -51,12 +54,15 @@ var (
func init() {
rootCmd.PersistentFlags().StringVarP(&RedisHost, "redis", "", "redis:6379", "The Redis instance to connect to")
rootCmd.PersistentFlags().StringVarP(&HTTPAddress, "http-address", "", "127.0.0.1", "HTTP Address to bind to")
rootCmd.PersistentFlags().IntVarP(&HTTPPort, "http-port", "", 8080, "HTTP Port to bind to")
rootCmd.PersistentFlags().IntVarP(&HTTPPort, "http-port", "", 8081, "HTTP Port to bind to")
rootCmd.PersistentFlags().IntVarP(&GithubIntegrationID, "github-integration-id", "", 0, "The GitHub App Integration ID")
rootCmd.PersistentFlags().StringVarP(&TaxonomyRepo, "taxonomy-repo", "", "https://github.com/instructlab/taxonomy.git", "The GitHub repository to use for the taxonomy")
rootCmd.PersistentFlags().StringVarP(&GithubURL, "github-url", "", "https://api.github.com/", "The URL of the GitHub instance")
rootCmd.PersistentFlags().StringVarP(&GithubWebhookSecret, "github-webhook-secret", "", "", "The GitHub App Webhook Secret")
rootCmd.PersistentFlags().StringVarP(&GithubAppPrivateKey, "github-app-private-key", "", "", "The GitHub App Private Key")
rootCmd.PersistentFlags().StringVarP(&WebhookProxyURL, "webhook-proxy-url", "", "", "Get an ID from https://smee.io/new. If blank, the app will not use a webhook proxy")
rootCmd.PersistentFlags().StringVarP(&GithubUsername, "github-username", "u", "instructlab-bot", "The GitHub username to use for authentication")
rootCmd.PersistentFlags().StringVarP(&GithubToken, "github-token", "g", "", "The GitHub token to use for authentication")
rootCmd.PersistentFlags().StringSliceVarP(&RequiredLabels, "required-labels", "", []string{}, "Label(s) required before a PR can be tested")
rootCmd.PersistentFlags().StringSliceVarP(&Maintainers, "maintainers", "", []string{}, "GitHub users or groups that are considered maintainers")
rootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "d", false, "Enable debug logging")
Expand Down Expand Up @@ -117,19 +123,28 @@ func run(logger *zap.SugaredLogger) error {
Maintainers: Maintainers,
}

prHandler := &handlers.PullRequestHandler{
prHandler := &handlers.PullRequestEventHandler{
ClientCreator: cc,
Logger: logger,
RequiredLabels: RequiredLabels,
BotUsername: BotUsername,
Maintainers: Maintainers,
}

prCreateHandler := &handlers.PullRequestCreateHandler{
ClientCreator: cc,
Logger: logger,
TaxonomyRepo: TaxonomyRepo,
GithubUsername: GithubUsername,
GithubToken: GithubToken,
}

webhookHandler := githubapp.NewDefaultEventDispatcher(ghConfig, prCommentHandler, prHandler)

http.Handle(githubapp.DefaultWebhookRoute, webhookHandler)

addr := net.JoinHostPort(HTTPAddress, strconv.Itoa(HTTPPort))
//addr := net.JoinHostPort(HTTPAddress, strconv.Itoa(HTTPPort))
addr := net.JoinHostPort("", strconv.Itoa(HTTPPort))

ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT)
defer cancel()
Expand Down Expand Up @@ -160,6 +175,9 @@ func run(logger *zap.SugaredLogger) error {
}
wg.Add(1)
httpServer := &http.Server{Addr: addr}
http.HandleFunc("/pr/skill", prCreateHandler.SkillPRHandler)
http.HandleFunc("/pr/knowledge", prCreateHandler.KnowledgePRHandler)

go func() {
logger.Infof("Starting server on %s...", addr)
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
Expand Down
26 changes: 23 additions & 3 deletions gobot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,57 @@ go 1.21
require (
github.com/chmouel/gosmee v0.21.0
github.com/go-redis/redis/v8 v8.11.5
github.com/google/go-github/v60 v60.0.0
github.com/google/go-github/v61 v61.0.0
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
github.com/palantir/go-githubapp v0.25.0
github.com/pkg/errors v0.9.1
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
github.com/spf13/cobra v1.8.0
go.uber.org/zap v1.27.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/google/go-github/v61 v61.0.0 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-github/v60 v60.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/tools v0.16.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

require (
github.com/Pallinder/go-randomdata v1.2.0
github.com/bradleyfalzon/ghinstallation/v2 v2.10.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-chi/chi/v5 v5.0.11 // indirect
github.com/go-git/go-git/v5 v5.12.0
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/google/go-github/v57 v57.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand Down
Loading

0 comments on commit 7a3161d

Please sign in to comment.