Skip to content

Commit

Permalink
Merge pull request #120 from ubiquity-os-marketplace/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
gentlementlegen authored Jan 13, 2025
2 parents 183406e + 72600ea commit ecb726f
Show file tree
Hide file tree
Showing 27 changed files with 504 additions and 390 deletions.
13 changes: 7 additions & 6 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
"useGitignore": true,
"language": "en",
"words": [
"knip",
"mischeck",
"dataurl",
"devpool",
"knip",
"mischeck",
"mswjs",
"outdir",
"servedir",
"Supabase",
"signoff",
"sonarjs",
"supabase",
"Supabase",
"SUPABASE",
"timespans",
"typebox",
"ubiquity-os",
"signoff",
"sonarjs",
"mswjs",
"unassignment",
"unassignments"
],
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Update Manifest and Commit Changes
name: "Update Configuration and Build"

on:
workflow_dispatch:
push:

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

Expand All @@ -18,4 +18,5 @@ jobs:
sourcemap: false
pluginEntry: ${{ github.workspace }}/src/index.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
57 changes: 52 additions & 5 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
name: Deploy Worker

on:
push:
workflow_dispatch:
workflow_run:
workflows: ["Update Configuration and Build"]
types:
- completed

env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }}
permissions:
contents: write

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

- name: Enable corepack
run: corepack enable

- 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')
branch_name=$(echo '${{ github.ref }}' | sed 's#refs/heads/##' | sed 's#[^a-zA-Z0-9]#-#g')
# Extract base name from wrangler.toml
base_name=$(grep '^name = ' wrangler.toml | sed 's/^name = "\(.*\)"$/\1/')
# Concatenate branch name with base name
Expand Down Expand Up @@ -54,6 +61,46 @@ jobs:
BOT_USER_ID: ${{ secrets.BOT_USER_ID }}
KERNEL_PUBLIC_KEY: ${{ secrets.KERNEL_PUBLIC_KEY }}

- name: Update manifest.json worker url
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
manifest["homepage_url"] = "${{ steps.wrangler_deploy.outputs.deployment-url }}";
const updatedManifest = JSON.stringify(manifest, null, 2);
fs.writeFileSync(manifestPath, updatedManifest);
console.log('Updated manifest:', updatedManifest);
- name: Get GitHub App token
if: env.APP_ID != '' && env.APP_PRIVATE_KEY != ''
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ env.APP_ID }}
private-key: ${{ env.APP_PRIVATE_KEY }}

- name: Format manifest.json using Prettier
shell: bash
run: |
bun add -DE prettier
bun prettier --write .
- name: Commit file
uses: swinton/[email protected]
env:
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
with:
files: |
manifest.json
commit-message: "chore: [skip ci] update manifest.json url"
ref: ${{ github.ref }}

- name: Write Deployment URL to Summary
run: |
echo "### Deployment URL" >> $GITHUB_STEP_SUMMARY
Expand Down
148 changes: 68 additions & 80 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ To configure your Ubiquity Kernel to run this plugin, add the following to the `
reviewDelayTolerance: "3 Days"
taskStaleTimeoutDuration: "30 Days"
maxConcurrentTasks: # Default concurrent task limits per role.
member: 5
collaborator: 5
contributor: 3
startRequiresWallet: true # default is true
assignedIssueScope: "org" # or "org" or "network". Default is org
emptyWalletText: "Please set your wallet address with the /wallet command first and try again."
rolesWithReviewAuthority: ["MEMBER", "OWNER"]
requiredLabelsToStart:
- name: "Priority: 5 (Emergency)"
roles: ["admin", "collaborator"]
allowedRoles: ["contributor", "collaborator"]
```
# Testing
Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

44 changes: 16 additions & 28 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@
"type": "boolean"
},
"maxConcurrentTasks": {
"default": {
"member": 10,
"contributor": 2
},
"description": "The maximum number of tasks a user can have assigned to them at once, based on their role.",
"examples": [
{
"member": 5,
"contributor": 1
"collaborator": 10,
"contributor": 2
}
],
"default": {},
"type": "object",
"patternProperties": {
"^(.*)$": {
"type": "integer"
"properties": {
"collaborator": {
"default": 10,
"type": "number"
},
"contributor": {
"default": 2,
"type": "number"
}
}
},
Expand Down Expand Up @@ -135,36 +137,21 @@
"description": "The name of the required labels to start the task.",
"type": "string"
},
"roles": {
"allowedRoles": {
"description": "The list of allowed roles to start the task with the given label.",
"uniqueItems": true,
"default": ["admin", "member", "collaborator", "contributor", "owner", "billing_manager"],
"default": [],
"examples": [["collaborator", "contributor"]],
"type": "array",
"items": {
"anyOf": [
{
"const": "admin",
"type": "string"
},
{
"const": "member",
"type": "string"
},
{
"const": "collaborator",
"type": "string"
},
{
"const": "contributor",
"type": "string"
},
{
"const": "owner",
"type": "string"
},
{
"const": "billing_manager",
"type": "string"
}
]
}
Expand All @@ -174,5 +161,6 @@
}
}
}
}
},
"homepage_url": "https://ubiquity-os-command-start-stop-development.ubiquity.workers.dev"
}
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"knip": "knip --config .github/knip.ts",
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"prepare": "husky install",
"test": "jest --setupFiles dotenv/config --coverage",
"test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 4000"
},
"keywords": [
Expand All @@ -29,28 +29,29 @@
"dependencies": {
"@octokit/graphql-schema": "15.25.0",
"@octokit/plugin-rest-endpoint-methods": "^13.2.6",
"@octokit/types": "^13.6.1",
"@octokit/types": "^13.6.2",
"@sinclair/typebox": "0.34.3",
"@supabase/supabase-js": "2.42.0",
"@ubiquity-os/plugin-sdk": "^1.1.0",
"@ubiquity-os/plugin-sdk": "^2.0.1",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"dotenv": "^16.4.4",
"hono": "^4.6.12",
"dotenv": "^16.4.7",
"hono": "^4.6.14",
"ms": "^2.1.3"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@cspell/dict-node": "^5.0.5",
"@cspell/dict-software-terms": "^4.1.15",
"@cspell/dict-typescript": "^3.1.2",
"@cspell/dict-software-terms": "^4.1.20",
"@cspell/dict-typescript": "^3.1.11",
"@eslint/js": "9.14.0",
"@jest/globals": "29.7.0",
"@mswjs/data": "0.16.1",
"@octokit/rest": "20.1.1",
"@types/jest": "29.5.12",
"@types/ms": "^0.7.34",
"@types/node": "20.14.5",
"cross-env": "^7.0.3",
"cspell": "8.9.0",
"eslint": "9.14.0",
"eslint-config-prettier": "9.1.0",
Expand All @@ -68,9 +69,9 @@
"ts-jest": "29.1.5",
"ts-node": "^10.9.2",
"tsx": "4.15.6",
"typescript": "5.6.2",
"typescript-eslint": "8.14.0",
"wrangler": "^3.87.0"
"typescript": "5.5.4",
"typescript-eslint": "^8.18.1",
"wrangler": "^3.97.0"
},
"lint-staged": {
"*.ts": [
Expand Down
6 changes: 2 additions & 4 deletions src/adapters/supabase/helpers/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Super } from "./supabase";
import { Context } from "../../../types/context";
import { addCommentToIssue } from "../../../utils/issue";
import { Super } from "./supabase";

type Wallet = {
address: string;
Expand All @@ -17,8 +16,7 @@ export class User extends Super {
if ((error && !data) || !data.wallets?.address) {
this.context.logger.error("No wallet address found", { userId, issueNumber });
if (this.context.config.startRequiresWallet) {
await addCommentToIssue(this.context, this.context.logger.error(this.context.config.emptyWalletText, { userId, issueNumber }).logMessage.diff);
throw new Error("No wallet address found");
throw this.context.logger.error(this.context.config.emptyWalletText, { userId, issueNumber });
}
} else {
this.context.logger.info("Successfully fetched wallet", { userId, address: data.wallets?.address });
Expand Down
Loading

0 comments on commit ecb726f

Please sign in to comment.