Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into fix/config-p…
Browse files Browse the repository at this point in the history
…rops
  • Loading branch information
Keyrxng committed Nov 27, 2024
2 parents e0ca282 + ab45541 commit 8e621e5
Show file tree
Hide file tree
Showing 24 changed files with 229 additions and 7,071 deletions.
12 changes: 11 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "bun.lockb", "tests/http/**", "node_modules", "**/*.log", "./src/adapters/supabase/**/**.ts"],
"ignorePaths": [
"**/*.json",
"**/*.css",
"bun.lockb",
"tests/http/**",
"node_modules",
"**/*.log",
"./src/adapters/supabase/**/**.ts",
"dist/**",
"coverage/**"
],
"useGitignore": true,
"language": "en",
"words": [
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/cspell.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/formatting-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Formatting Check

on:
push:

jobs:
format-check:
name: Check for formatting errors
runs-on: ubuntu-latest

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

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install toolchain
run: bun install --frozen-lockfile

- name: Eslint
run: bun run eslint --fix-dry-run

- name: Cspell
run: bun run format:cspell

- name: Prettier
run: bun run prettier --check .
9 changes: 6 additions & 3 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ jobs:
with:
fetch-depth: 0

- name: Enable corepack
run: corepack enable
- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install toolchain
run: bun install --frozen-lockfile

- name: Jest With Coverage
run: yarn install && yarn test
run: bun run test

- name: Add Jest Report to Summary
if: always()
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:
with:
node-version: 20.10.0

- name: Enable corepack
run: corepack enable
- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install toolchain
run: yarn install
run: bun install --frozen-lockfile

- name: Store PR number
run: echo ${{ github.event.number }} > pr-number.txt

- name: Run Knip
run: yarn knip || yarn knip --reporter json > knip-results.json
run: bun run knip || bun run knip --reporter json > knip-results.json

- name: Upload knip result
if: failure()
Expand Down
56 changes: 8 additions & 48 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,21 @@
name: "Update Configuration"
name: Update Manifest and Commit Changes

on:
workflow_dispatch:
push:

jobs:
update:
name: "Update Configuration in manifest.json"
update-manifest:
name: "Update Manifest and Commit Changes"
runs-on: ubuntu-latest
permissions: write-all

steps:
- uses: actions/checkout@v4

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

- name: Enable corepack
run: corepack enable

- name: Install deps and run configuration update
run: |
yarn install
yarn tsc --noCheck --project tsconfig.json
- name: Update manifest configuration using GitHub Script
uses: actions/github-script@v7
- name: Update Manifest and Commit Changes
uses: ubiquity-os/action-deploy-plugin@main
with:
script: |
const fs = require('fs');
const path = require('path');
const { pluginSettingsSchema } = require('./src/types/plugin-input');
const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const configuration = JSON.stringify(pluginSettingsSchema);
manifest["configuration"] = JSON.parse(configuration);
const updatedManifest = JSON.stringify(manifest, null, 2);
console.log('Updated manifest:', updatedManifest);
fs.writeFileSync(manifestPath, updatedManifest);
- name: Commit and Push generated types
run: |
git config --global user.name 'ubiquity-os[bot]'
git config --global user.email 'ubiquity-os[bot]@users.noreply.github.com'
git add ./manifest.json
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then
git commit -m "chore: updated generated configuration" || echo "Lint-staged check failed"
git push origin HEAD:${{ github.ref_name }}
else
echo "No changes to commit"
fi
treatAsEsm: false
sourcemap: false
pluginEntry: ${{ github.workspace }}/src/index.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:

- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Update wrangler.toml Name Field
run: |
branch_name=$(echo '${{ github.event.ref }}' | sed 's#refs/heads/##' | sed 's#[^a-zA-Z0-9]#-#g')
Expand All @@ -32,21 +35,24 @@ jobs:
# Update the wrangler.toml file
sed -i "s/^name = .*/name = \"$new_name\"/" wrangler.toml
echo "Updated wrangler.toml name to: $new_name"
- name: Deploy with Wrangler
id: wrangler_deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.79.0"
wranglerVersion: "3.87.0"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
BOT_USER_ID
${{ secrets.KERNEL_PUBLIC_KEY && secrets.KERNEL_PUBLIC_KEY != '' && 'KERNEL_PUBLIC_KEY' || '' }}
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
BOT_USER_ID: ${{ secrets.BOT_USER_ID }}
KERNEL_PUBLIC_KEY: ${{ secrets.KERNEL_PUBLIC_KEY }}

- name: Write Deployment URL to Summary
run: |
Expand Down
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
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
bun lint-staged
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
coverage/
Binary file added bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default tsEslint.config({
"@typescript-eslint": tsEslint.plugin,
"check-file": checkFile,
},
ignores: [".github/knip.ts", ".github/cspell.ts", ".wrangler/**/*.ts", ".wrangler/**/*.js"],
ignores: [".github/knip.ts", ".github/cspell.ts", ".wrangler/**/*.ts", ".wrangler/**/*.js", "dist/**", "eslint.config.mjs"],
extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
parser: tsEslint.parser,
Expand Down
12 changes: 1 addition & 11 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@
"type": "string"
}
}
},
"required": [
"reviewDelayTolerance",
"taskStaleTimeoutDuration",
"startRequiresWallet",
"maxConcurrentTasks",
"assignedIssueScope",
"emptyWalletText",
"rolesWithReviewAuthority",
"requiredLabelsToStart"
]
}
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@ubiquity-os/command-start-stop",
"version": "1.0.0",
"description": "Enables the assignment and graceful unassignment of tasks to contributors.",
"main": "src/worker.ts",
"main": "src/index.ts",
"author": "Ubiquity DAO",
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -35,6 +35,7 @@
"@ubiquity-os/plugin-sdk": "^1.1.0",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"dotenv": "^16.4.4",
"hono": "^4.6.12",
"ms": "^2.1.3"
},
"devDependencies": {
Expand Down Expand Up @@ -84,6 +85,5 @@
"extends": [
"@commitlint/config-conventional"
]
},
"packageManager": "[email protected]"
}
}
4 changes: 2 additions & 2 deletions src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AssignedIssue, Context, ISSUE_TYPE, Label } from "../../types";
import { isUserCollaborator } from "../../utils/get-user-association";
import { addAssignees, addCommentToIssue, getAssignedIssues, getAvailableOpenedPullRequests, getTimeValue, isParentIssue } from "../../utils/issue";
import { addAssignees, addCommentToIssue, getAssignedIssues, getPendingOpenedPullRequests, getTimeValue, isParentIssue } from "../../utils/issue";
import { HttpStatusCode, Result } from "../result-types";
import { hasUserBeenUnassigned } from "./check-assignments";
import { checkTaskStale } from "./check-task-stale";
Expand Down Expand Up @@ -198,7 +198,7 @@ async function fetchUserIds(context: Context, username: string[]) {
}

async function handleTaskLimitChecks(username: string, context: Context, logger: Context["logger"], sender: string) {
const openedPullRequests = await getAvailableOpenedPullRequests(context, username);
const openedPullRequests = await getPendingOpenedPullRequests(context, username);
const assignedIssues = await getAssignedIssues(context, username);
const { limit } = await getUserRoleAndTaskLimit(context, username);

Expand Down
11 changes: 6 additions & 5 deletions src/worker.ts → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { createPlugin } from "@ubiquity-os/plugin-sdk";
import { Manifest } from "@ubiquity-os/plugin-sdk/manifest";
import { LogLevel } from "@ubiquity-os/ubiquity-os-logger";
import type { ExecutionContext } from "hono";
import manifest from "../manifest.json";
import { createAdapters } from "./adapters";
import { startStopTask } from "./plugin";
import { Command } from "./types/command";
import { SupportedEvents } from "./types/context";
import { Env, envSchema } from "./types/env";
import { PluginSettings, pluginSettingsSchema } from "./types/plugin-input";
import manifest from "../manifest.json";
import { Command } from "./types/command";
import { startStopTask } from "./plugin";
import { Manifest } from "@ubiquity-os/plugin-sdk/manifest";
import { LogLevel } from "@ubiquity-os/ubiquity-os-logger";

export default {
async fetch(request: Request, env: Env, executionCtx?: ExecutionContext) {
Expand All @@ -27,6 +27,7 @@ export default {
settingsSchema: pluginSettingsSchema,
logLevel: env.LOG_LEVEL as LogLevel,
kernelPublicKey: env.KERNEL_PUBLIC_KEY,
bypassSignatureVerification: process.env.NODE_ENV === "local",
}
).fetch(request, env, executionCtx);
},
Expand Down
9 changes: 4 additions & 5 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { createClient } from "@supabase/supabase-js";
import { createAdapters } from "./adapters";
import { HttpStatusCode } from "./handlers/result-types";
import { commandHandler, userPullRequest, userSelfAssign, userStartStop, userUnassigned } from "./handlers/user-start-stop";
import { Context } from "./types";
import { listOrganizations } from "./utils/list-organizations";
import { HttpStatusCode } from "./handlers/result-types";
import { createAdapters } from "./adapters";
import { createClient } from "@supabase/supabase-js";

export async function startStopTask(context: Context) {
context.adapters = createAdapters(createClient(context.env.SUPABASE_URL, context.env.SUPABASE_KEY), context as Context);
const organizations = await listOrganizations(context);
context.organizations = organizations;
context.organizations = await listOrganizations(context);

if (context.command) {
return await commandHandler(context);
Expand Down
Loading

0 comments on commit 8e621e5

Please sign in to comment.