Skip to content

Commit

Permalink
Merge pull request #644 from pavlovcik/refactor/general
Browse files Browse the repository at this point in the history
Refactor/general
  • Loading branch information
0x4007 committed Feb 17, 2024
2 parents 8afd7cf + 0c3a364 commit cb08490
Show file tree
Hide file tree
Showing 214 changed files with 7,733 additions and 17,842 deletions.
4 changes: 4 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"micromark",
"milestoned",
"Numberish",
"OPENAI",
"orgname",
"pavlovcik",
"permisson",
"Postgrest",
"prereleased",
"probot",
"Probot",
Expand All @@ -42,13 +44,15 @@
"Supabase",
"SUPABASE",
"svgs",
"tiktoken",
"timelabel",
"TURL",
"typebox",
"Ubiqui",
"ubiquibot",
"unarchived",
"Unassigning",
"upserted",
"Upserting",
"URLSAFE",
"vitalik",
Expand Down
17 changes: 1 addition & 16 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,7 @@ WEBHOOK_SECRET=

SUPABASE_URL=
SUPABASE_KEY=
AUTO_PAY_MODE=
ANALYTICS_MODE=


# Use `trace` to get verbose logging or `info` to show less
# `fatal` `error` `info` `verbose` `debug`
LOG_LEVEL=debug
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

# Telegram Log Notification Envs
LOG_WEBHOOK_BOT_URL= # URL of cloudflare worker without trailing /
LOG_WEBHOOK_SECRET= # Random Secret, Shared between the telegram bot and the sender
LOG_WEBHOOK_GROUP_ID= # Group Id, ex: -100124234325
LOG_WEBHOOK_TOPIC_ID= # Topic Id (Optional), Only provide if group is a topic and you're not using General
46 changes: 45 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,50 @@
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/no-floating-promises": "error"
"arrow-body-style": ["error", "as-needed"], // Allow single-line arrow functions without braces
"prefer-arrow-callback": ["error", { "allowNamedFunctions": false }], // Allow arrow functions for callbacks
"func-style": ["error", "declaration", { "allowArrowFunctions": false }], // Enforce function declarations and named functions
// ... other rules ...

"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/naming-convention": [
"error",
{ "selector": "typeLike", "format": ["PascalCase"] },
{ "selector": "variableLike", "format": ["camelCase"] },
{ "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" },
{
"selector": "variable",
"types": ["boolean"],
"format": ["PascalCase"],
"prefix": ["is", "should", "has", "can", "did", "will", "does"]
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{ "selector": "typeParameter", "format": ["PascalCase"], "prefix": ["T"] },
{ "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } },
{ "selector": ["function", "variable"], "format": ["camelCase"] },
{ "selector": "variable", "modifiers": ["destructured"], "format": null },
{ "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },

{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow", // This allows the use of a leading underscore
"trailingUnderscore": "allow" // This allows the use of a trailing underscore
},
{
"selector": "parameter",
"format": null,
"filter": {
// This allows parameters to be named as just an underscore
"regex": "^_$",
"match": true
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: "Bounty Proposal"
name: "Task Proposal"
description: Have a suggestion for how to improve UbiquiBot? Let us know!
title: "Bounty Proposal: "
title: "Task Proposal: "

body:
- type: markdown
attributes:
value: |
## Feature Request Form
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!
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
Expand All @@ -17,14 +17,14 @@ body:
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

- type: textarea
attributes:
label: Describe the solution
description: A clear description of what you want to happen. Add any considered drawbacks.
validations:
required: true

- type: textarea
attributes:
label: Remarks
Expand Down
9 changes: 0 additions & 9 deletions .github/ubiquibot-config.yml

This file was deleted.

11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -16,13 +17,13 @@ jobs:
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 lint
run: bun format

run-migration:
runs-on: ubuntu-latest
Expand All @@ -31,7 +32,7 @@ jobs:
env:
SUPABASE_ACCESS_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_ACCESS_TOKEN || secrets.STAGING_SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_DB_PASSWORD || secrets.STAGING_SUPABASE_DB_PASSWORD }}
PROJECT_ID: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_PROJECT_ID || secrets.STAGING_SUPABASE_PROJECT_ID }}
SUPABASE_PROJECT_ID: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_PROJECT_ID || secrets.STAGING_SUPABASE_PROJECT_ID }}

steps:
- name: Checkout repository
Expand All @@ -42,7 +43,7 @@ jobs:
version: latest

- name: Link Supabase project
run: supabase link --project-ref $PROJECT_ID
run: supabase link --project-ref $SUPABASE_PROJECT_ID

- name: Run migrations
run: supabase db push
52 changes: 52 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Run E2E Tests

on:
- workflow_dispatch
- push

jobs:
e2e-test:
runs-on: ubuntu-latest

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

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

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

- name: Build
run: bun tsc

- name: Test
env:

APP_ID: ${{ secrets.APP_ID }}
# CHATGPT_USER_PROMPT_FOR_IMPORTANT_WORDS:
# CHATGPT_USER_PROMPT_FOR_MEASURE_SIMILARITY:
DISQUALIFY_TIME: "7 days"
FOLLOW_UP_TIME: "4 days"
# IMPORTANT_WORDS_AI_TEMPERATURE:
LOG_ENVIRONMENT: "production"
# LOG_LEVEL:
# MEASURE_SIMILARITY_AI_TEMPERATURE:
# OPENAI_API_HOST:
# OPENAI_API_KEY:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
# SIMILARITY_THRESHOLD:
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
TEST_ADMIN_PAT: ${{ secrets.TEST_ADMIN_PAT }}
TEST_ORGANIZATION_NAME: ${{ secrets.TEST_ORGANIZATION_NAME }}
TEST_OUTSIDE_COLLABORATOR_PAT: ${{ secrets.TEST_OUTSIDE_COLLABORATOR_PAT }}
TEST_REPOSITORY_NAME: ${{ secrets.TEST_REPOSITORY_NAME }}
WEBHOOK_PROXY_URL: ${{ secrets.WEBHOOK_PROXY_URL }}
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
X25519_PRIVATE_KEY: "QCDb30UHUkwJAGhLWC-R2N0PiEbd4vQY6qH2Wloybyo"

run: "bun test"
7 changes: 5 additions & 2 deletions .github/workflows/kebab-case.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ jobs:
"^\.\/vendor"
"^\.\/test"
"^\.\/\.next"
"^\.\/tests"
"\.sql$"
"\.md$"
"\.d.ts$"
"\.d\.ts$"
"\.gitignore$" # Ignore .gitignore files
"\.test\.ts$" # Ignore .test.ts files
)
while read -r file; do
basefile=$(basename "$file")
Expand All @@ -48,4 +51,4 @@ jobs:
echo " - $file"
done
exit 1
fi
fi
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
32 changes: 0 additions & 32 deletions .github/workflows/release.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/short-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check File Length

on:
push:
pull_request:

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Check file length
run: |
IGNORE=("src/adapters/supabase/types/database.ts" "src/generatedFile2.ts") # Add more files to ignore as needed
find src -name "*.ts" -type f -exec bash -c '
for ignore in "${IGNORE[@]}"; do
if [[ "$1" == "$ignore" ]]; then
echo "Ignoring $ignore"
exit 0
fi
done
if [[ $(wc -l < "$1") -gt 512 ]]; then
echo "File $1 line length is greater than 512. This should be broken up into smaller files."
exit 1
fi
' bash {} \;
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ supabase/temp
# Local Netlify folder
.netlify
bin
.yarn
.yarn
yarn-error.log
tsconfig.tsbuildinfo
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"
5 changes: 3 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged --verbose
# Run lint-staged first
bun lint-staged --verbose

0 comments on commit cb08490

Please sign in to comment.