Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Feb 18, 2024
2 parents 56a30fd + cb08490 commit bed39fe
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 19,964 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,19 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Enable Corepack and Install Correct Yarn Version
run: |
corepack enable
yarn set version 4.0.2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20.10.0"

- name: Install
run: yarn install
run: npm install -g bun && bun install

- name: Local Build
run: yarn build
run: bun tsc

- name: Lint
run: yarn format
run: bun format

run-migration:
runs-on: ubuntu-latest
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:

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

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18.16.0"
node-version: "20.10.0"

- name: Install
run: yarn install
run: npm install bun -g && bun install

- name: Build
run: yarn build
run: bun tsc

- name: Test
env:
Expand Down Expand Up @@ -49,4 +49,4 @@ jobs:
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
X25519_PRIVATE_KEY: "QCDb30UHUkwJAGhLWC-R2N0PiEbd4vQY6qH2Wloybyo"

run: "yarn test"
run: "bun test"
30 changes: 30 additions & 0 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Knip

on:
pull_request:

permissions: write-all

jobs:
run-knip:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install toolchain
run: npm install -g bun && bun install

- name: Report knip results to pull request
uses: Codex-/knip-reporter@v2
with:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit "$1"
bun commitlint --edit "$1"
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname "$0")/_/husky.sh"

# Run lint-staged first
yarn lint-staged --verbose
bun lint-staged --verbose
7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

1 change: 0 additions & 1 deletion .yarnrc.yml

This file was deleted.

10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ We'd also love PRs. If you're thinking of a large PR, we advise opening up an is
## Submitting a pull request

1. Fork and clone the repository.
2. Configure and install the dependencies: `yarn install`.
3. Make sure the tests pass on your machine: `yarn test`. These tests also apply the linter, so there's no need to lint separately.
2. Configure and install the dependencies: `bun install`.
3. Make sure the tests pass on your machine: `bun test`. These tests also apply the linter, so there's no need to lint separately.
4. Create a new branch: `git checkout -b my-branch-name`.
5. Make your change, add tests, and make sure the tests still pass. You can find the tests in the `src/tests` directory.
6. Push to your fork and submit a pull request.
Expand All @@ -31,9 +31,9 @@ Work in Progress pull requests are also welcome to get feedback early on, or if
## Running the project locally

1. Fork and clone the repository.
2. Install dependencies: `yarn install`.
3. Build the project: `yarn build`.
4. Start the project: `yarn start:watch`.
2. Install dependencies: `bun install`.
3. Build the project: `bun tsc`.
4. Start the project: `bun start:watch`.

## Environment Setup

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Ubiquity DAO's GitHub Bot for Automating DevPool Management.

git clone https://github.com/ubiquity/ubiquibot.git
cd ubiquibot
yarn
yarn build (to compile your changes)
bun
bun tsc (to compile your changes)

yarn build --watch (to locally auto compile your changes)
bun tsc --watch (to locally auto compile your changes)

yarn start:watch
bun start:watch

## It's recommended to split terminals in your IDE while running above input
```
Expand Down Expand Up @@ -228,12 +228,12 @@ Supabase comes with a [readme](https://github.com/ubiquity/ubiquibot/blob/develo
### This options will require you to have a local Docker installation (under the hood it is required by Supabase) refer to [Supabase Docs](https://supabase.com/docs)

```
yarn supabase start
bun supabase start
```

## Check Supabase Status (locally)
```
yarn supabase status
bun supabase status
```

![supabase](https://github.com/ubiquity/ubiquibot/assets/41552663/e8709b8f-e7c3-49e0-876c-c15dde22c6d2)
Expand All @@ -252,16 +252,16 @@ DISQUALIFY_TIME="7 days" // 7 days
```

3. `Make sure you have Node => 20.10.0 && yarn`
3. `Make sure you have Node => 20.10.0 && bun`
4. Open 2 terminal instances:
- in one instance run `yarn build --watch` (compiles the Typescript code)
- in another instance run `yarn start:watch` (runs the bot locally)
- in one instance run `bun tsc --watch` (compiles the Typescript code)
- in another instance run `bun start:watch` (runs the bot locally)
5. Open `http://localhost:3000` and follow instructions to add the bot to one of your repositories.

At this point the `.env` files auto-fill the empty fields (`PRIVATE_KEY` and `APP_ID`) if it is not previously filled.
Now you can make changes to the repository on GitHub (e.g. add a task) and the bot should react.

6. After adding the bot (as a installed app) to your github you will need to restart the aforementioned `yarn start:watch`` so CTRL-C to stop the node daemon and `yarn start:watch` again
6. After adding the bot (as a installed app) to your github you will need to restart the aforementioned `bun start:watch`` so CTRL-C to stop the node daemon and `bun start:watch` again

You can, for example:

Expand Down Expand Up @@ -312,7 +312,7 @@ Make sure you have your local instance of [ubiquibot running](#quickstart).

## How to create a new release

1. Update the version in package.json: `yarn version --new-version x.x.x`
1. Update the version in package.json: `bun version --new-version x.x.x`
2. Commit and create a new tag: `git commit -am x.x.x && git tag -am x.x.x`
3. Push tags: `git push origin v"x.x.x"`
4. The Github action will create a release by recognizing the version tag
Expand Down
Binary file added bun.lockb
Binary file not shown.
4 changes: 0 additions & 4 deletions knip.json

This file was deleted.

11 changes: 11 additions & 0 deletions knip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["src/index.ts"],
project: ["src/**/*.ts"],
ignore: ["src/types/config.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: [],
};

export default config;
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ID = "d2668848-c2a6-411f-b884-004faee1942f"

[build]
command = "echo \"export const COMMIT_HASH = '$COMMIT_REF';\" > src/commit-hash.ts && yarn build"
command = "echo \"export const COMMIT_HASH = '$COMMIT_REF';\" > src/commit-hash.ts && bun tsc"
functions = "./.netlify/functions"
publish = "dist"

Expand Down
31 changes: 14 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
],
"scripts": {
"inspect": "node --inspect node_modules/.bin/probot run ./dist/main.js",
"build:gh-actions": "ncc build src/adapters/github/github-actions.ts -o ./",
"build": "tsc",
"build:watch": "tsc --watch",
"clean": "rimraf ./dist ./node_modules",
"preformat": "yarn format:prettier",
"format": "yarn format:eslint",
"postformat": "yarn format:cspell",
"format": "run-s format:prettier format:eslint format:cspell",
"format:prettier": "prettier --write src",
"format:eslint": "eslint --fix --ext .ts ./src",
"format:cspell": "cspell --config .cspell.json 'src/**/*.{js,ts,json,md,yml}'",
"start:gh-actions": "tsx src/adapters/github/github-actions.ts",
"start:watch": "nodemon --exec 'yarn start'",
"start:watch": "nodemon --exec 'bun start'",
"start": "probot run ./dist/main.js",
"format:knip": "knip",
"format:knip-ci": "knip --no-exit-code --reporter json",
"prepare": "husky install",
"test": "jest",
"logs:netlify": "yarn netlify logs:function webhooks"
"logs:netlify": "bun netlify logs:function webhooks"
},
"dependencies": {
"@commitlint/cli": "^17.4.3",
Expand All @@ -41,6 +37,7 @@
"@types/ms": "^0.7.31",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"@typescript-eslint/typescript-estree": "^7.0.1",
"@uniswap/permit2-sdk": "^1.2.0",
"@vercel/ncc": "^0.34.0",
"ajv": "^8.12.0",
Expand All @@ -59,6 +56,7 @@
"ms": "^2.1.3",
"node-html-parser": "^6.1.5",
"nodemon": "^2.0.19",
"npm-run-all": "^4.1.5",
"openai": "^4.2.0",
"prettier": "^2.7.1",
"probot": "^12.2.4",
Expand All @@ -76,17 +74,16 @@
"@types/libsodium-wrappers": "^0.7.10",
"@types/lodash": "^4.14.202",
"@types/markdown-it": "^13.0.4",
"@types/node": "^14.18.37",
"@types/node": "^18.0.0",
"@types/source-map-support": "^0.5.6",
"eslint": "^8.43.0",
"jest": "^29.7.0",
"knip": "^2.33.4",
"netlify-cli": "^17.10.1",
"jest": "^29.6.2",
"knip": "^3.7.1",
"octokit": "^3.1.2",
"rimraf": "3.0.2",
"source-map-support": "^0.5.21",
"ts-jest": "^29.1.1",
"typescript": "^4.9.5"
"typescript": "^5.0.4"
},
"engines": {
"node": ">=20.10.0"
Expand All @@ -110,7 +107,7 @@
},
"verbose": true,
"ext": "ts",
"exec": "yarn start"
"exec": "bun start"
},
"packageManager": "yarn@4.0.2"
}
"packageManager": "bun@1.0.23"
}
30 changes: 3 additions & 27 deletions src/adapters/supabase/helpers/tables/locations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Super } from "./super";
// import { Database } from "../../types/database";
import { Database } from "../../types/database";

// currently trying to save all of the location metadata of the event.
// seems that focusing on the IssueComments will provide the most value

// type LocationsRow = Database["public"]["Tables"]["logs"]["Row"];
type LocationsRow = Database["public"]["Tables"]["logs"]["Row"];
export class Locations extends Super {
locationResponse: LocationResponse | undefined;
locationResponse: LocationsRow | undefined;

user_id: string | undefined;
comment_id: string | undefined;
Expand All @@ -30,27 +30,3 @@ export class Locations extends Super {
return locationData;
}
}

interface LocationResponse {
data: {
node: {
id: "IC_kwDOH92Z-c5oA5cs";
author: {
login: "molecula451";
id: "MDQ6VXNlcjQxNTUyNjYz";
};
issue: {
id: "I_kwDOH92Z-c5yRpyq";
number: 846;
repository: {
id: "R_kgDOH92Z-Q";
name: "ubiquibot";
owner: {
id: "MDEyOk9yZ2FuaXphdGlvbjc2NDEyNzE3";
login: "ubiquity";
};
};
};
};
};
}
8 changes: 1 addition & 7 deletions src/bindings/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
MainActionHandler,
PostActionHandler,
PreActionHandler,
WildCardHandler
WildCardHandler,
} from "../types/handlers";
import { GitHubEvent, GitHubPayload, payloadSchema } from "../types/payload";
import { ajv } from "../utils/ajv";
Expand Down Expand Up @@ -246,12 +246,6 @@ function createRenderCatchAll(context: Context, handlerType: AllHandlersWithType
);
} else {
// could be supabase error
// interface SupabaseError {
// code: "PGRST116";
// details: "The result contains 0 rows";
// hint: null;
// message: "JSON object requested, multiple (or no) rows returned";
// }

// report as SupabaseError

Expand Down
Loading

0 comments on commit bed39fe

Please sign in to comment.