Skip to content

Commit

Permalink
Merge branch 'development' into feat/cspell
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Sep 25, 2023
2 parents 291bb75 + 3c83d93 commit 6475180
Show file tree
Hide file tree
Showing 86 changed files with 4,939 additions and 2,487 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ SUPABASE_KEY=
AUTO_PAY_MODE=
ANALYTICS_MODE=


# Use `trace` to get verbose logging or `info` to show less
LOG_LEVEL=debug
LOGDNA_INGESTION_KEY=
OPENAI_API_HOST=https://api.openai.com
OPENAI_API_KEY=
CHATGPT_USER_PROMPT_FOR_IMPORTANT_WORDS="I need your help to find important words (e.g. unique adjectives) from github issue below and I want to parse them easily so please separate them using #(No other contexts needed). Please separate the words by # so I can parse them easily. Please answer simply as I only need the important words. Here is the issue content.\n"
CHATGPT_USER_PROMPT_FOR_MEASURE_SIMILARITY='I have two github issues and I need to measure the possibility of the 2 issues are the same content (No other contents needed and give me only the number in %).\n Give me in number format and add % after the number.\nDo not tell other things since I only need the number (e.g. 85%). Here are two issues:\n 1. "%first%"\n2. "%second%"'
SIMILARITY_THRESHOLD=80
MEASURE_SIMILARITY_AI_TEMPERATURE=0
IMPORTANT_WORDS_AI_TEMPERATURE=0
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@

* @0xcodercrane
15 changes: 12 additions & 3 deletions .github/ISSUE_TEMPLATE/bounty-template.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
name: "Bounty Proposal"
description: Have a suggestion for how to improve UbiquiBot? Let us know!
title: "Bounty Proposal:"
title: "Bounty Proposal: "

body:
- type: markdown
attributes:
value: |
## Feature Request Form
Thank you for taking the time to file a feature request! Please let us know what you're trying to do, and how UbiquiBot can help.
Thank you for taking the time to file a feature request.
If you register your wallet address, you will be eligible for compensation if this is accepted!
Please let us know how we can improve the bot.
- type: textarea
attributes:
label: Describe the background or context
description: Please let us know what inspired you to write this proposal. Backlinking to specific comments is usually sufficient context.
description: Please let us know what inspired you to write this proposal. Backlinking to specific comments on GitHub, and leaving a remark about how the bot should have interacted with it is usually sufficient context.
validations:
required: false

Expand All @@ -22,3 +24,10 @@ body:
description: A clear description of what you want to happen. Add any considered drawbacks.
validations:
required: true

- type: textarea
attributes:
label: Remarks
description: Any closing remarks?
validations:
required: false
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Telegram Group Chat
url: https://t.me/UbiquityDAO/29891
about: "Join us on Telegram!"
- name: UbiquiBot Development Group Chat
url: https://t.me/UbiquityDAO/31132
about: "Live chat with us on Telegram!"
14 changes: 9 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!-- RULES TO CONTRIBUTE TO UBIQUIBOT
1. You must link the issue number e.g. "Resolves #1234"
2. You must link proof that your code works from a test issue on your forked repo e.g. "Quality Assurance https://github.com/user/repo/issues/1#issuecomment-1"
3. Please do not replace the keyword "Resolves" https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

Resolves #

<!--
- You must link the issue number e.g. "Resolves #1234"
- You must link the QA issue on your forked repo e.g. "QA for #1234"
- Please do not replace the keyword "Resolves" https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->
Quality Assurance:
44 changes: 6 additions & 38 deletions .github/ubiquibot-config.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
evm-network-id: 100
price-multiplier: 1.5
time-labels:
- name: "Time: <1 Hour"
weight: 0.125
value: 3600
- name: "Time: <2 Hours"
weight: 0.25
value: 7200
- name: "Time: <4 Hours"
weight: 0.5
value: 14400
- name: "Time: <1 Day"
weight: 1
value: 86400
- name: "Time: <1 Week"
weight: 2
value: 604800
priority-labels:
- name: "Priority: 0 (Normal)"
weight: 1
- name: "Priority: 1 (Medium)"
weight: 2
- name: "Priority: 2 (High)"
weight: 3
- name: "Priority: 3 (Urgent)"
weight: 4
- name: "Priority: 4 (Emergency)"
weight: 5
default-labels:
- "Time: <1 Hour"
- "Priority: 0 (Normal)"
payment-permit-max-price: 1000
comment-incentives: true
max-concurrent-bounties: 2
promotion-comment: "\n<h6>If you enjoy the DevPool experience, please follow <a href='https://github.com/ubiquity'>Ubiquity on GitHub</a> and star <a href='https://github.com/ubiquity/devpool-directory'>this repo</a> to show your support. It helps a lot!</h6>"
register-wallet-with-verification: false
assistive-pricing: true
priceMultiplier: 1.5
# newContributorGreeting:
# enabled: true
# header: "Thank you for contributing to UbiquiBot! Please be sure to set your wallet address before completing your first bounty so that the automatic payout upon task completion will work for you."
# helpMenu: true
# footer: "###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!"
2 changes: 1 addition & 1 deletion .github/workflows/bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ jobs:
X25519_PRIVATE_KEY: 'QCDb30UHUkwJAGhLWC-R2N0PiEbd4vQY6qH2Wloybyo'
FOLLOW_UP_TIME: '4 days'
DISQUALIFY_TIME: '7 days'
run: yarn start:serverless
run: yarn start:serverless
37 changes: 37 additions & 0 deletions .github/workflows/deploy-logger-page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy Log Web App to Cloudflare Worker

on:
workflow_run:
workflows: ["Conventional Commits"]
types:
- completed

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Deploy to Cloudflare Worker

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20.3.0"

- name: Build TypeScript
run: cd ./log-app && npm install && npm run build

- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
directory: ${{ secrets.LOGGER_WEB_APP_DIRECTORY }}
# Enable Wrangler v3
wranglerVersion: "3"
1 change: 1 addition & 0 deletions .github/workflows/kebab-case.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
"\.sql$"
"\.md$"
"\.d.ts$"
"^\.\/\log-app"
)
while read -r file; do
basefile=$(basename "$file")
Expand Down
110 changes: 89 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Ubiquity DAO's GitHub Bot to automate DevPool management.
git clone https://github.com/ubiquity/ubiquibot.git
cd ubiquibot
yarn
yarn tsc
yarn build
yarn start:watch
```

Expand All @@ -23,6 +23,15 @@ yarn start:watch
- `LOGDNA_INGESTION_KEY`: Get it from [Memzo](https://app.mezmo.com/) by creating an account, adding an organization, and copying the ingestion key on the next screen.
- `FOLLOWUP_TIME`: (optional) Set a custom follow-up time (default: 4 days).
- `DISQUALIFY_TIME`: (optional) Set a custom disqualify time (default: 7 days).
- `OPENAI_API_HOST`: (optional) Set OpenAI host url (default: https://api.openai.com).
- `OPENAI_API_KEY`: Set OpenAI key.
- `CHATGPT_USER_PROMPT_FOR_IMPORTANT_WORDS`: (optional) Set a custom user prompt for finding important words
(default: "I need your help to find important words (e.g. unique adjectives) from github issue below and I want to parse them easily so please separate them using #(No other contexts needed). Please separate the words by # so I can parse them easily. Please answer simply as I only need the important words. Here is the issue content.\n").
- `CHATGPT_USER_PROMPT_FOR_MEASURE_SIMILARITY`: (optional) Set a custom user prompt for measuring similarity
(default: 'I have two github issues and I need to measure the possibility of the 2 issues are the same content (No other contents needed and give me only the number in %).\n Give me in number format and add % after the number.\nDo not tell other things since I only need the number (e.g. 85%). Here are two issues:\n 1. "%first%"\n2. "%second%"').
- `SIMILARITY_THRESHOLD`: (optional) Set similarity threshold (default: 80).
- `MEASURE_SIMILARITY_AI_TEMPERATURE`: (optional) Set ChatGPT temperature for measuring similarity (default: 0).
- `IMPORTANT_WORDS_AI_TEMPERATURE`: (optional) Set ChatGPT temperature for finding important words (default: 0).

`APP_ID` and `PRIVATE_KEY` are [here](https://t.me/c/1588400061/1627) for internal developers to use.
If you are an external developer, `APP_ID`and `PRIVATE_KEY` are automatically generated when you install the app on your repository.
Expand All @@ -45,38 +54,55 @@ To test the bot, you can:

1. Create a new issue
2. Add a time label, ex: `Time: <1 Day`
3. At this point the bot should add a price label.
3. Add a priority label, ex: `Priority: 0 (Normal)`
4. At this point the bot should add a price label.

## Configuration

`chain-id` is ID of the EVM-compatible network that will be used for payouts.
`evm-network-id` is ID of the EVM-compatible network that will be used for payouts.

`base-multiplier` is a base number that will be used to calculate bounty price based on the following formula: `price = base-multiplier * time-label-weight * priority-label-weight / 10`
`price-multiplier` is a base number that will be used to calculate bounty price based on the following formula: `price = price-multiplier * time-label-weight * priority-label-weight * 100`

`time-labels` are labels for marking the time limit of the bounty:

- `name` is a human-readable name
- `weight` is a number that will be used to calculate the bounty price
- `value` is number of seconds that corresponds to the time limit of the bounty

`priority-labels` are labels for marking the priority of the bounty:

- `name` is a human-readable name
- `weight` is a number that will be used to calculate the bounty price

`command-settings` are setting to enable or disable a command

- `name` is the name of the command
- `enabled` is a `true` or `false` value to enable or disable a command

`default-labels` are labels that are applied when an issue is created without any time or priority labels.

`auto-pay-mode` can be `true` or `false` that enables or disables automatic payout of bounties when the issue is closed.
`assistive-pricing` to create a new pricing label if it doesn't exist. Can be `true` or `false`.

`disable-analytics` can be `true` or `false` that disables or enables weekly analytics collection by Ubiquity.

`payment-permit-max-price` sets the max amount for automatic payout of bounties when the issue is closed.

`comment-incentives` can be `true` or `false` that enable or disable comment incentives. These are payments generated for comments in the issue by contributors, excluding the assignee.

`issue-creator-multiplier` is a number that defines a base multiplier for calculating incentive for the creator of the issue.

`analytics-mode` can be `true` or `false` that enables or disables weekly analytics collection by Ubiquity.
`comment-element-pricing` defines how much is a part of the comment worth. For example `text: 0.1` means that any text in the comment will add 0.1

`incentive-mode` can be `true` or `false` that enables or disables comment incentives. These are comments in the issue by either the creator of the bounty or other users.
`incentives` defines incentive rewards:

`issue-creator-multiplier` is a number that defines a base multiplier for calculating incentive reward for the creator of the issue.
- `comment` defines comment rewards:
- `elements` defines reward value for HTML elements such as `p`, `img`, `a`.
- `totals`:
- `word` defines reward for each word in the comment

`comment-element-pricing` defines how much is a part of the comment worth. For example `text: 0.1` means that any text in the comment will be multiplied by 0.1
`max-concurrent-assigns` is the maximum number of bounties that can be assigned to a bounty hunter at once. This excludes bounties with delayed or approved pull request reviews.

`max-concurrent-bounties` is the maximum number of bounties that can be assigned to a bounty hunter at once. This excludes bounties with pending pull request reviews.
`register-wallet-with-verification` can be `true` or `false`. If enabled, it requires a signed message to set wallet address. This prevents users from setting wallet address from centralized exchanges, which would make payments impossible to claim.

`promotion-comment` is a message that is appended to the payment permit comment.

## How to run locally

Expand Down Expand Up @@ -108,7 +134,7 @@ DISQUALIFY_TIME="7 days" // 7 days

4. `yarn install`
5. Open 2 terminal instances:
- in one instance run `yarn tsc --watch` (compiles the Typescript code)
- in one instance run `yarn build --watch` (compiles the Typescript code)
- in another instance run `yarn start:watch` (runs the bot locally)
6. Open `localhost:3000` and follow instructions to add the bot to one of your repositories.

Expand All @@ -119,7 +145,8 @@ You can, for example:

1. Create a new issue
2. Add a time label, ex: `Time: <1 Day`
3. At this point the bot should add a price label, you should see event logs in one of your opened terminals
3. Add a priority label, ex: `Priority: 0 (Normal)`
4. At this point the bot should add a price label, you should see event logs in one of your opened terminals

## How it works

Expand All @@ -135,13 +162,31 @@ When using as a github app the flow is the following:
4. Event details are sent to your deployed bot instance (to a webhook URL that was set in github app's settings)
5. The bot handles the event

## Payments Permits in a local instance

For payment to work in your local instance, ubiquibot must be set up in a Github organization. It will not work for a ubiquibot instance set up in a personal account. Once, you have an ubiquibot instance working in an organization, follow the steps given below:

1. Create a new private repository in your Github organization with name `ubiquibot-config`
2. Add your ubiquibot app to `ubiquibot-config` repository.
3. Create a file `.github/ubiquibot-config.yml` in it. Fill the file with contents from [this file](https://github.com/ubiquity/ubiquibot/blob/development/.github/ubiquibot-config.yml).
4. Go to https://pay.ubq.fi/keygen and generate X25519 public/private key pair. Fill private key of your wallet's address in `PLAIN_TEXT` field and click `Encrypt`.
5. Copy the `CIPHER_TEXT` and append it to your repo `ubiquibot-config/.github/ubiquibot-config.yml` as

`private-key-encrypted: "PASTE_YOUR_CIPHER_TEXT_HERE"`

6. Copy the `X25519_PRIVATE_KEY` and append it in your local ubiquibot repository `.env` file as

`X25519_PRIVATE_KEY=PASTE_YOUR_X25519_PRIVATE_KEY_HERE`

## How to QA any additions to the bot

1. Fork the ubiquibot repo and install the [ubiquibot-qa app](https://github.com/apps/ubiquibot-qa) on the forked repository.
2. Enable github action running on the forked repo and allow `issues` on the settings tab.
3. Create a [QA issue](https://github.com/ubiquibot/staging/issues/21) similar to this where you show the feature working in the forked repo
4. Describe carefully the steps taken to get the feature working, this way our team can easily verify
5. Link that QA issue to the pull request as indicated on the template before requesting a review
Make sure you have your local instance of ubiquibot running.

1. Fork the ubiquibot repo and add your local instance of ubiquibot to the forked repository.
2. Enable Github action running on the forked repo and allow `issues` on the settings tab.
3. Create a [QA issue](https://github.com/ubiquibot/staging/issues/21) similar to this where you show the feature working in the forked repo.
4. Describe carefully the steps taken to get the feature working, this way our team can easily verify.
5. Link that QA issue to the pull request as indicated on the template before requesting a review.

## How to create a new release

Expand Down Expand Up @@ -179,7 +224,7 @@ Bounty bot is built using the [probot](https://probot.github.io/) framework so i
├── <a href="https://github.com/ubiquity/ubiquibot/tree/development/src/utils">utils</a> A set of utility functions
</pre>

## Default Config Notes (`ubiquibot-config-default.json`)
## Default Config Notes (`ubiquibot-config-default.ts`)

We can't use a `jsonc` file due to limitations with Netlify. Here is a snippet of some values with notes next to them.

Expand All @@ -191,7 +236,30 @@ We can't use a `jsonc` file due to limitations with Netlify. Here is a snippet o
/* https://github.com/syntax-tree/mdast#nodes */
"strong": 0 // Also includes italics, unfortunately https://github.com/syntax-tree/mdast#strong
/* https://github.com/syntax-tree/mdast#gfm */

}
}
```

## Supabase Cron Job (`logs-cleaner`)

##### Dashboard > Project > Database > Extensions

> Search `PG_CRON` and Enable it.

##### Dashboard > Project > SQL Editor

```sql
-- Runs everyday at 03:00 AM to cleanup logs that are older than a week
-- Use the cron time format to modify the trigger time if necessary
select
cron.schedule (
'logs-cleaner', -- Job name
'0 3 * * *', -- Everyday at 03:00 AM
$$DELETE FROM logs WHERE timestamp < now() - INTERVAL '1 week'$$
);


-- Cancel the cron job
select cron.unschedule('logs-cleaner');
```
2 changes: 2 additions & 0 deletions log-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore JavaScript files
*.js
9 changes: 9 additions & 0 deletions log-app/_worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Env } from "./types/global";

export default {
async fetch(request: Request, env: Env) {
// Otherwise, serve the static assets.
// Without this, the Worker will error and no assets will be served.
return env.ASSETS.fetch(request);
},
};
Loading

0 comments on commit 6475180

Please sign in to comment.