contributebot

command module
v0.0.0-...-2152f20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

README

Contribute Bot

Contribute Bot is a small service (written using Go Cloud!) that performs automated checks on issues and pull requests to help keep contributions organized and easy to triage for maintainers.

Contribute Bot has two servers: a webhook endpoint and an event listener. The webhook endpoint publishes events to a Cloud Pub/Sub topic that are eventually processed by the event listener. GitHub has a 10 second webhook response time limit combined with a 5000 request/hour API rate limit, so this adds buffering with the assumption that incoming events are bursty.

Setup

To set up your own instance of Contribute Bot for local testing or deployment:

  1. Create a new GCP project.
  2. Set your project using gcloud config set project PROJECTID, where PROJECTID is the project's ID.
  3. Download default application credentials with gcloud auth application-default login.
  4. Enable App Engine with gcloud app create.
  5. Copy the prod directory to a directory called dev.
  6. In dev/main.tf, remove the backend "gcs" block and change the project IDs to your new GCP project.
  7. Run terraform init from the new dev directory.
  8. Run terraform apply to set up the infrastructure.
  9. Deploy the webhook, creating a random webhook secret.
  10. Create the GitHub application, setting the webhook URL to https://PROJECTID.appspot.com/webhook, where PROJECTID is your GCP project ID.
    • Set the Webhook secret to the random webhook secret you created above.
    • Make sure to give Read & Write access to Issues, Pull Requests, Checks, and Read-only access to Repository metadata.
    • Subscribe to pull request and issue events.
  11. Download a GitHub application secret key and copy the contents into a new Terraform variable file in the dev directory, setting the github_app_key variable. It's useful to use a "here doc". Then run terraform apply again to update the secret material. Your variable file should look something like this:
contributebot/dev$ cat terraform.tfvars
github_app_key = <<EOF
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
EOF

Developing

To run Contribute Bot locally for testing:

  1. Create a GitHub repository for testing.
  2. Install the GitHub application on your test repository (Settings > Developer Settings > Github Apps, then Edit your app and select Install App).
  3. Download a GitHub application secret key for your test application.
  4. Run contributebot, setting the flags for your test GCP project and GitHub application. You can find the App ID under About on the Github page for your app. Example:
go run . --project=your-project-name --github_app=42 --github_key=/foo.pem

Deploying

To production

To deploy an updated Contribute Bot to production, follow these steps.

# Build Docker image.
gcloud builds submit --config cloudbuild.yaml ../.. --project=go-cloud-contribute-bot

# Edit prod/k8s/contributebot.yaml and replace the image with the one
# you just created.

# Apply to cluster. Replace project and zone with the actual values.
gcloud container clusters get-credentials \
    --project=go-cloud-contribute-bot \
    --zone=us-central1-c \
    contributebot-cluster
kubectl apply -f prod/k8s

# Send a PR with the updated .yaml file.
Somewhere else

If you want to deploy to your own cluster, modify k8s/contributebot.yaml to replace go-cloud-contribute-bot with your own project ID, and 15206 with your own Github App ID. Run the commands above, using your own project ID in the command line arguments instead of go-cloud-contribute-bot.

Documentation

Overview

contributebot is a service for keeping the Go Cloud project tidy.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL