|
1 | 1 | # Cirq Triage Party |
2 | 2 |
|
3 | | -See the [triaging process](../../docs/dev/triage.md). |
| 3 | +[Triage Party](https://github.com/google/triage-party) is an issue and pull request triaging tool |
| 4 | +for GitHub. For more information about the triaging process used in the Cirq project, please refer |
| 5 | +to the [triage process documentation for Cirq](../../docs/dev/triage.md). |
4 | 6 |
|
5 | | -## Configuration |
| 7 | +## Local testing |
6 | 8 |
|
7 | | -For the dashboard you will have to edit the embedded YAML config in |
8 | | -[configmap.yaml](kubernetes/02_deployment/configmap.yaml). Please refer to the |
9 | | -[triage party |
10 | | -docs](https://github.com/google/triage-party/blob/main/docs/config.md) for |
11 | | -configuration details. |
| 9 | +It is possible to run an instance of Triage Party on your local host. This is useful for testing |
| 10 | +configuration changes. |
12 | 11 |
|
13 | | -## Secret |
| 12 | +1. Generate a personal access token on GitHub with read-only permissions for `public_repo`. (Please |
| 13 | + refer to the GitHub documentation for [personal access tokens] for information on how to do |
| 14 | + that.) The token will be a string of characters that begins with the letters `gho_`. |
14 | 15 |
|
15 | | -Triage party needs a Github token. This is a one-time setup (per cluster |
16 | | -creation): |
| 16 | +2. Store this token string in the environment variable `GITHUB_TOKEN`: |
17 | 17 |
|
18 | | -```shell |
19 | | -kubectl create secret generic triage-party-github-token -n triage-party --from-file=token=$HOME/.github-token |
| 18 | + ```shell |
| 19 | + export GITHUB_TOKEN="yourtokenhere" |
| 20 | + ``` |
| 21 | + |
| 22 | +3. Run Triage Party locally in a container using either Podman or Docker. The script |
| 23 | + `./run-local.sh` makes this convenient; it pulls an image for Triage Party from a container |
| 24 | + registry and runs it with the appropriate Cirq configuration files. (Note: this produces |
| 25 | + _a lot_ of output.) |
| 26 | + |
| 27 | + ```shell |
| 28 | + ./run-local.sh |
| 29 | + ``` |
| 30 | + |
| 31 | +After some time and many lines of logs printed, if all went well, the output should end with a line |
| 32 | +that looks more or less something like this: |
| 33 | + |
| 34 | +```text |
| 35 | +I0601 21:40:01.954553 1 updater.go:250] update cycle #1 took 7.005642265s |
20 | 36 | ``` |
21 | 37 |
|
22 | | -where `$HOME/.github-token` is a file containing the token. |
| 38 | +The exact numbers printed in the output are not important; what matters is that it did not end with |
| 39 | +an error message and did not return to the shell, but rather paused with `update cycle #1` as the |
| 40 | +final message. The Triage Party server will then be listening for web browser connections on port |
| 41 | +8080 on your local host. It will produce more output as it detects that files have changed. |
| 42 | + |
| 43 | +[personal access tokens]: https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line |
| 44 | + |
| 45 | +## Cloud configuration & Setup |
| 46 | + |
| 47 | +The deployment of Cirq's Triage Party instance on a Google Cloud server is managed using Kubernetes, |
| 48 | +an open-source platform that automates the deployment, scaling, and management of containerized |
| 49 | +applications. Specifically, we use the tools Kustomize and Skaffold. |
| 50 | +
|
| 51 | +### 1. Application Configuration |
| 52 | +
|
| 53 | +To customize the Triage Party dashboard (e.g., modifying collections, rules, and members), edit the |
| 54 | +standalone YAML configuration file located at [kubernetes/02_deployment/config.yaml][config]. |
| 55 | +This file is read by the program `kustomize` to generate the `triage-party-config` ConfigMap for |
| 56 | +Kubernetes. |
| 57 | +
|
| 58 | +Please refer to the official [Triage Party documentation] for details on the available configuration |
| 59 | +options. |
| 60 | +
|
| 61 | +[Triage Party documentation]: https://github.com/google/triage-party/blob/main/docs/config.md |
| 62 | +
|
| 63 | +### 2. Static Resources & Theming (CSS & Favicon) |
| 64 | +
|
| 65 | +Extra resources like custom styling and the site's favicon are also managed automatically via |
| 66 | +Kustomize: |
| 67 | + |
| 68 | +- **Custom CSS**: Overrides to the default Triage Party look and feel are defined in |
| 69 | + [kubernetes/02_deployment/custom.css][custom_css] as a ConfigMap. |
| 70 | + |
| 71 | +- **Favicon**: The favicon is bundled directly from the image file |
| 72 | + [kubernetes/02_deployment/cirq-icon-very-small.png][cirq_icon]. Kustomize reads this binary |
| 73 | + file and creates the `triage-party-favicon` ConfigMap automatically as defined in |
| 74 | + [kubernetes/kustomization.yaml][kustomization]. |
23 | 75 |
|
24 | | -## Cloud Build based deployment |
| 76 | +There is no need to manually run `kubectl create configmap` commands for these resources. |
25 | 77 |
|
26 | | -On every push to main Triage Party is redeployed as defined by |
27 | | -[cloudbuild-deploy.yaml](cloudbuild-deploy.yaml). |
| 78 | +[cirq_icon]: kubernetes/02_deployment/cirq-icon-very-small.png |
| 79 | +[config]: kubernetes/02_deployment/config.yaml |
| 80 | +[custom_css]: kubernetes/02_deployment/custom.css |
| 81 | +[kustomization]: kubernetes/kustomization.yaml |
28 | 82 |
|
29 | | -## Deploying Triage Party manually |
| 83 | +### 3. GitHub Token Secret (One-time Setup) |
30 | 84 |
|
31 | | -See [the cirq-infra documentation](../cirq-infra/README.md) for the required |
32 | | -tools. |
| 85 | +Triage Party requires a GitHub personal access token so that it can query the GitHub API to get data |
| 86 | +about issues and pull requests. The token creation and assignment is a one-time setup. You must |
| 87 | +create a Kubernetes Secret containing a GitHub token. Follow these steps: |
| 88 | + |
| 89 | +1. Obtain a new token from GitHub. |
| 90 | + |
| 91 | +2. Set the environment variable `GITHUB_TOKEN` to the token to be used. |
| 92 | + |
| 93 | +3. Run the following command in a terminal on your local host: |
| 94 | + |
| 95 | + ```shell |
| 96 | + # Authenticate to Google Cloud. |
| 97 | + gcloud auth login |
| 98 | +
|
| 99 | + # Provision your underlying Application Default Credentials (ADC). |
| 100 | + gcloud auth application-default login |
| 101 | +
|
| 102 | + # Authenticate your local terminal with the Kubernetes cluster running |
| 103 | + # on Google Kubernetes Engine (GKE) and save values in ~/.kube/config. |
| 104 | + gcloud container clusters get-credentials cirq-infra --zone us-central1-a |
| 105 | +
|
| 106 | + # Finally, create the secret inside the cluster. |
| 107 | + kubectl create secret generic triage-party-github-token \ |
| 108 | + -n triage-party --from-literal=token="${GITHUB_TOKEN}" |
| 109 | + ``` |
| 110 | + |
| 111 | +## Deployment |
| 112 | + |
| 113 | +Google Cloud Build is Google Cloud Platform's (GCP) serverless CI/CD service. When code is pushed, |
| 114 | +Cloud Build automatically imports the changes, executes the build files, compiles the necessary |
| 115 | +containers, and safely applies them to the production environment without manual intervention. |
| 116 | +Please refer to the [cirq-infra documentation](../cirq-infra/README.md) to find out more about the |
| 117 | +software tools needed and how to install them. |
| 118 | +
|
| 119 | +### Google Cloud Build deployment |
| 120 | +
|
| 121 | +On every push to the `main` branch that involves files in `dev_tools/triage-party/`, the Cirq Triage |
| 122 | +Party instance is automatically redeployed using the steps defined in the file |
| 123 | +[cloudbuild-deploy.yaml](./cloudbuild-deploy.yaml). This is achieved thanks to a Cloud Build Trigger |
| 124 | +defined in the `cirq-infra` project in GCP. Thus, when changes to the Triage Party configuration are |
| 125 | +merged into the `main` branch on GitHub, the server instance will be updated automatically. |
| 126 | +
|
| 127 | +### Manual Deployment |
| 128 | +
|
| 129 | +It is possible to update the Triage Party deployment manually (e.g., for applying an immediate fix). |
| 130 | +This can be done using the command-line tool `skaffold`. Execute these commands from the top level |
| 131 | +of the Cirq repository: |
33 | 132 |
|
34 | 133 | ```shell |
| 134 | +# Authenticate to Google Cloud. |
| 135 | +gcloud auth login |
| 136 | +
|
| 137 | +# Provision your underlying Application Default Credentials (ADC). |
| 138 | +gcloud auth application-default login |
| 139 | +
|
| 140 | +# Authenticate your local terminal with the remote Kubernetes cluster running |
| 141 | +# on Google Kubernetes Engine (GKE) and save values in ~/.kube/config. |
35 | 142 | gcloud container clusters get-credentials cirq-infra --zone us-central1-a |
| 143 | +
|
| 144 | +# Bundle the config, generate ConfigMaps, and deploy. |
36 | 145 | skaffold run --force -f=dev_tools/triage-party/skaffold.yaml |
37 | 146 | ``` |
0 commit comments