sourcegraph/dev/linearhooks
Greg Magolan be015c58c2
refactor: upgrade to rules_oci 2.0 (2nd attempt) (#63829)
2nd attempt of #63111, a follow up
https://github.com/sourcegraph/sourcegraph/pull/63085

rules_oci 2.0 brings a lot of performance improvement around oci_image
and oci_pull, which will benefit Sourcegraph. It will also make RBE
faster and have less load on remote cache.

However, 2.0 makes some breaking changes like

- oci_tarball's default output is no longer a tarball
- oci_image no longer compresses layers that are uncompressed, somebody
has to make sure all `pkg_tar` targets have a `compression` attribute
set to compress it beforehand.
- there is no curl fallback, but this is fine for sourcegraph as it
already uses bazel 7.1.

I checked all targets that use oci_tarball as much as i could to make
sure nothing depends on the default tarball output of oci_tarball. there
was one target which used the default output which i put a TODO for
somebody else (somebody who is more on top of the repo) to tackle
**later**.

## Test plan

CI. Also run delivery on this PR (don't land those changes)

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
2024-08-07 22:21:49 +01:00
..
internal msp/runtime: split contract into JobContract and ServiceContract (#63494) 2024-06-26 19:46:10 +00:00
.env.example dev/linearhooks: add POC (#62367) 2024-05-07 00:14:05 -07:00
BUILD.bazel refactor: upgrade to rules_oci 2.0 (2nd attempt) (#63829) 2024-08-07 22:21:49 +01:00
config.example.yaml dev/linearhooks: add support for project modifier (#62521) 2024-05-08 17:15:58 +00:00
image_test.yaml dev/linearhooks: add POC (#62367) 2024-05-07 00:14:05 -07:00
main.go dev/linearhooks: add POC (#62367) 2024-05-07 00:14:05 -07:00
README.md dev/linearhooks: add POC (#62367) 2024-05-07 00:14:05 -07:00

Linear Webhooks

Development

Caution

DO NOT commit your api key

First make a copy of the dotenv file and set the API key and webhook signing secrets in .env based on the Linear API settings. If you don't have access, reach out to #wg-linear-trial.

cp .env.example .env
source .env
go run .

Use ngrok to get a public URL for receiving webhook events:

ngrok http 3000

Set the webhook URL in Linear.

Deployment

This service is deployed as a MSP service. Learn more from go/msp.

Caution

Keep your secret safe

In production, it's recommended to create a Linear OAuth2 application, and create a developer token using application identity as actor. Then, set the developer token as LINEAR_PERSONAL_API_KEY in the deployment. Othewise, your personal identity will be associated with all requests.

Unfortunately, Linear only supports authorization_code grant type, but not client_credentials. Authenticating through the web interface (e.g., OAuth callback) is a lot of added complexity for a simply webhook service. We will revisit in the future.

Configuration

Refer to config.example.yaml