Skip to content

A simple Obelisk webhook endpoint and a workflow that monitors GitHub repositories.

License

Notifications You must be signed in to change notification settings

obeli-sk/demo-stargazers

Repository files navigation

Stargazers

A simple Obelisk webhook endpoint and a workflow that monitors GitHub repositories. Every step is persisted and replayed during crash recovery.

Workflow Code Example - star-added

fn star_added(login: String, repo: String) -> Result<(), String> {
    // 1. Persist the user giving a star to the project.
    let description = db::user::add_star_get_description(&login, &repo)?;
    if description.is_none() {
        // 2. Fetch the account info from GitHub.
        let info = github::account::account_info(&login)?;
        // 3. Fetch the prompt from the database.
        let settings_json = db::llm::get_settings_json()?;
        // 4. Generate the user's description.
        let description = llm::respond(&info, &settings_json)?;
        // 5. Persist the generated description.
        db::user::update_user_description(&login, &description)?;
    }
    Ok(())
}

Here is the complete workflow source and the WIT file describing the interface.

The following screenshot shows how the star-added workflow calls the activities with their respective numbers.

jaeger trace

Executions can be submitted, inspected etc. using the Web UI.

webui animation

Setting up

Setting up the external services

The activities require tokens to be present.

Turso activity

Follow the prerequisites section of the activity-db-turso README.

ChatGPT activity

Follow the prerequisites section of the activity-llm-chatgpt README.

GitHub activity

Follow the prerequisites section of the activity-account-github README.

GitHub webhook endpoint

Follow the prerequisites section of the webhook README.

Running

Set up the environment: If direnv and Nix are available:

cp .envrc-example .envrc
direnv allow

Otherwise install the following:

  • Obelisk
  • Optionally Rust for building the WASM components locally, version and other components are specified in rust-toolchain.toml
  • Optinally Wasmtime for integration testing of activities
  • Optinally Cloudflared for exposing the webhook endpoint

The exact versions of dependencies used for development and testing are in dev-deps.txt.

obelisk server run --config ./obelisk-oci.toml

The server will start downloading the WASM components from the Docker Hub. Wait for the following lines in the process output:

HTTP server `webhook_server` is listening on http://127.0.0.1:9090
HTTP server `webui` is listening on http://127.0.0.1:8080
Serving gRPC requests at 127.0.0.1:5005

The workflow can be started using the Web UI. The webhook endpoint can be triggered using curl or by seting up the webhook in a GitHub repo. See the webhook documentation for details on how to set up GitHub and a https tunnel to the local instance.

Building the WASM components locally

The configuration above downloads the WASM Components from the Docker Hub. To build all the components locally run

cargo build
obelisk server run --config ./obelisk-local.toml