{"id":13672296,"url":"https://github.com/rust-lang/triagebot","last_synced_at":"2025-05-15T07:02:33.207Z","repository":{"id":37492959,"uuid":"170012962","full_name":"rust-lang/triagebot","owner":"rust-lang","description":"Automation/tooling for Rust spaces","archived":false,"fork":false,"pushed_at":"2025-04-04T17:16:12.000Z","size":4120,"stargazers_count":187,"open_issues_count":103,"forks_count":81,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-07T02:14:42.623Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://triage.rust-lang.org","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-10T18:46:04.000Z","updated_at":"2025-04-05T14:14:59.000Z","dependencies_parsed_at":"2023-09-29T02:49:39.820Z","dependency_job_id":"86d17b92-0daa-4193-a90b-9e1c00da6e48","html_url":"https://github.com/rust-lang/triagebot","commit_stats":{"total_commits":1925,"total_committers":48,"mean_commits":"40.104166666666664","dds":"0.45766233766233766","last_synced_commit":"38b904f010338e3847bf1eba651356985c6f1df1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Ftriagebot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Ftriagebot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Ftriagebot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Ftriagebot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-lang","download_url":"https://codeload.github.com/rust-lang/triagebot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248862670,"owners_count":21173855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:31.582Z","updated_at":"2025-05-15T07:02:33.196Z","avatar_url":"https://github.com/rust-lang.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Triagebot\n\nThis is the triage and team assistance bot for the rust-lang organization.\n\nPlease see the [forge] for our documentation, and feel free to contribute edits\nif you find something helpful!\n\n[forge]: https://forge.rust-lang.org/triagebot/index.html\n\n## How triagebot works\n\nTriagebot consists of a webserver with several endpoints.\nThe `/github-hook` and `/zulip-hook` endpoints receive webhook notifications from the respective services.\nTriagebot can then respond to those notifications to perform various actions such as adjusting labels.\n\nThe Triagebot webserver also includes several other endpoints intended for users to access directly, such as https://triage.rust-lang.org/agenda.\n\nTriagebot uses a Postgres database to retain some state.\nIn production, it uses [RDS](https://aws.amazon.com/rds/).\n\nThe server at https://triage.rust-lang.org/ runs on ECS and is configured via [Terraform](https://github.com/rust-lang/simpleinfra/blob/master/terraform/shared/services/triagebot/main.tf#L8).\nUpdates are automatically deployed when merged to master.\n\n## Installation\n\nTo compile the Triagebot you need OpenSSL development library to be installed (e.g. for Ubuntu-like Linux distributions `sudo apt install libssl-dev`).\n\nRun `cargo build` to compile the triagebot.\n\n## Running triagebot\n\nIt is possible to run triagebot yourself, and test changes against your own repository.\nSome developers may settle with testing in production as the risks tend to be low, but the more intrepid may find it easier to iterate separately.\n\nThe general overview of what you will need to do:\n\n1. Create a repo on GitHub to run tests on.\n2. [Configure a database](#configure-a-database)\n3. [Configure webhook forwarding](#configure-webhook-forwarding)\n4. Configure the `.env` file:\n\n    1. Copy `.env.sample` to `.env`\n    2. `GITHUB_TOKEN`: This is a token needed for Triagebot to send requests to GitHub. Go to GitHub Settings \u003e Developer Settings \u003e Personal Access Token, and create a new token. The `repo` permission should be sufficient.\n       If this is not set, Triagebot will also look in `~/.gitconfig` in the `github.oauth-token` setting.\n    3. `DATABASE_URL`: This is the URL to the database. See [Configuring a database](#configuring-a-database).\n    4. `GITHUB_WEBHOOK_SECRET`: Enter the secret you entered in the webhook above.\n    5. `RUST_LOG`: Set this to `debug`.\n\n5. Run `cargo run --bin triagebot`. This starts the http server listening for webhooks on port 8000.\n6. Add a `triagebot.toml` file to the main branch of your GitHub repo with whichever services you want to try out.\n7. Try interacting with your repo, such as issuing `@rustbot` commands or interacting with PRs and issues (depending on which services you enabled in `triagebot.toml`). Watch the logs from the server to see what's going on.\n\n### Configure a database\n\nTo use Postgres, you will need to install it and configure it:\n\n1. Install Postgres. Look online for any help with installing and setting up Postgres (particularly if you need to create a user and set up permissions).\n2. Create a database: `createdb triagebot`\n3. In the `.env` file, set the `DATABASE_URL`:\n\n   ```sh\n   DATABASE_URL=postgres://eric@localhost/triagebot\n   ```\n\n   replacing `eric` with the username on your local system.\n\n### Configure webhook forwarding\n\nI recommend at least skimming the [GitHub webhook documentation](https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks) if you are not familiar with webhooks.\nIn order for GitHub's webhooks to reach your triagebot server, you'll need to figure out some way to route them to your machine.\nThere are various options on how to do this.\nYou can poke holes into your firewall or use a proxy, but you shouldn't expose your machine to the the internet.\nThere are various services which help with this problem.\nThese generally involve running a program on your machine that connects to an external server which relays the hooks into your machine.\nThere are several to choose from:\n\n* [gh webhook](#gh-webhook) — This is a GitHub-native service. This is the easiest to use.\n* [ngrok](#ngrok) — This is pretty easy to use, but requires setting up a free account.\n* \u003chttps://smee.io/\u003e — This is another service recommended by GitHub.\n* \u003chttps://localtunnel.github.io/www/\u003e — This is another service recommended by GitHub.\n\n#### gh webhook\n\nThe [`gh` CLI](https://github.com/cli/cli) is the official CLI tool which I highly recommend getting familiar with.\nThere is an official extension which provides webhook forwarding and also takes care of all the configuration.\nSee [cli/gh-webhook](https://docs.github.com/en/developers/webhooks-and-events/webhooks/receiving-webhooks-with-the-github-cli) for more information on installing it.\n\nThis is super easy to use, and doesn't require manually configuring webhook settings.\nThe command to run looks something like:\n\n```sh\ngh webhook forward --repo=ehuss/triagebot-test --events=* \\\n  --url=http://127.0.0.1:8000/github-hook --secret somelongsekrit\n```\n\nWhere the value in `--secret` is the secret value you place in `GITHUB_WEBHOOK_SECRET` in the `.env` file, and `--repo` is the repo you want to test against.\n\n### Zulip testing\n\nIf you are modifying code that sends message to Zulip and want to test your changes, you can register a [new free Zulip instance](https://zulip.com/new/). Before launching the triagebot locally, set the Zulip env vars to connect to your test instance (see example in `.env.sample`).\n\nYou can also test Zulip webhooks locally with `curl`. For example, to test the Zulip hooks (commands sent to the\nTriagebot from the Rust lang Zulip), you start the triagebot on `localhost:8000` and then simulate a\nZulip hook payload:\n``` sh\ncurl http://localhost:8000/zulip-hook \\\n    -H \"Content-Type: application/json\" \\\n    -d '{\n        \"data\": \"\u003cCMD\u003e\",\n        \"token\": \"\u003cZULIP_TOKEN\u003e\",\n        \"message\": {\n            \"sender_id\": \u003cYOUR_ID\u003e,\n            \"recipient_id\": \u003cYOUR_ID\u003e,\n            \"sender_full_name\": \"Randolph Carter\",\n            \"sender_email\": \"r.carter@rust-lang.org\",\n            \"type\": \"stream\"\n            }\n        }'\n```\n\nWhere:\n- `CMD` is the exact command you would issue @triagebot on Zulip (ex. open a direct chat with the\n  bot and send \"work show\")\n- `ZULIP_TOKEN`: can be anything. Must correspond to the env var `$ZULIP_TOKEN` on your workstation\n- `YOUR_ID`: your GitHub user ID. Must be existing in your local triagebot database (table `users` and as\n  foreign key also in `review_prefs`)\n\n#### ngrok\n\nThe following is an example of using \u003chttps://ngrok.com/\u003e to provide webhook forwarding.\nYou need to sign up for a free account, and also deal with configuring the GitHub webhook settings.\n\n1. Install ngrok.\n2. Run `ngrok http 8000`. This will forward webhook events to localhost on port 8000.\n3. Configure GitHub webhooks in the test repo you created.\n   In short:\n\n    1. Go to the settings page for your GitHub repo.\n    2. Go to the webhook section.\n    3. Click \"Add webhook\"\n    4. Include the settings:\n\n        * Payload URL: This is the URL to your Triagebot server, for example http://7e9ea9dc.ngrok.io/github-hook. This URL is displayed when you ran the `ngrok` command above.\n        * Content type: application/json\n        * Secret: Enter a shared secret (some longish random text)\n        * Events: \"Send me everything\"\n\n### Cargo tests\n\nYou can run Cargo tests using `cargo test`. If you also want to run tests that access a Postgres database, you can specify an environment variables `TEST_DB_URL`, which should contain a connection string pointing to a running Postgres database instance:\n\n```bash\n$ docker run --rm -it -p5432:5432 \\\n  -e POSTGRES_USER=triagebot \\\n  -e POSTGRES_PASSWORD=triagebot \\\n  -e POSTGRES_DB=triagebot \\\n  postgres:14\n$ TEST_DB_URL=postgres://triagebot:triagebot@localhost:5432/triagebot cargo test\n```\n\n## License\n\nTriagebot is distributed under the terms of both the MIT license and the\nApache License (Version 2.0).\n\nSee [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang%2Ftriagebot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-lang%2Ftriagebot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang%2Ftriagebot/lists"}