Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development into main #75

Merged
merged 215 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
5b17673
fix: add validation to check for duplicate roles
jordan-ae Aug 15, 2024
61424ec
chore: update readme to match changes
jordan-ae Aug 15, 2024
07734d4
fix: user t.record and loop by object.entries
jordan-ae Aug 15, 2024
359a9a9
fix: use role as key and limit as value
jordan-ae Aug 15, 2024
3c2b73d
fix: get rid of unnecesary operstions on the role
jordan-ae Aug 15, 2024
542b57c
chore: use correct cases
jordan-ae Aug 18, 2024
3fd93c1
Update src/types/plugin-input.ts
jordan-ae Aug 24, 2024
20fb503
Update src/types/plugin-input.ts
jordan-ae Aug 27, 2024
2d559ed
Update src/types/plugin-input.ts
jordan-ae Aug 27, 2024
3897833
chore: revert to staticDecode
jordan-ae Aug 28, 2024
5faa1a0
chore: cleanup
jordan-ae Aug 28, 2024
57d0089
chore: rebase to development
jordan-ae Aug 29, 2024
744b559
chore: refactor isTaskStale using ms
Keyrxng Aug 13, 2024
1b4d509
chore: eslint
Keyrxng Aug 13, 2024
b7fc11b
chore: fix default, refactor isTaskStale
Keyrxng Aug 13, 2024
e834a7f
chore: remove redundant check
Keyrxng Aug 19, 2024
874fa10
chore: teamate assignment
Keyrxng Jul 15, 2024
3e7a586
chore: unassign command user
Keyrxng Jul 15, 2024
7a34e68
chore: teams test
Keyrxng Jul 15, 2024
b6f2490
chore: correct comment
Keyrxng Jul 15, 2024
535b4f5
chore: max assigned check all users
Keyrxng Jul 16, 2024
cb28796
chore: fix eslint naming convention
Keyrxng Jul 16, 2024
3826f9c
chore: update logs and test
Keyrxng Jul 29, 2024
a9236a8
chore: remove redunant logic
Keyrxng Aug 5, 2024
402666c
chore: throw errors and paginate
Keyrxng Aug 6, 2024
829a134
feat: custom message for private issues without plan
Keyrxng Aug 6, 2024
9a00cd0
chore: use octokit.rest
Keyrxng Aug 8, 2024
53fa77b
chore: throw logReturn and catch-all error comment
Keyrxng Aug 12, 2024
792627a
chore: catch other errors
Keyrxng Aug 12, 2024
ebff871
chore: update tests
Keyrxng Aug 12, 2024
087f088
chore: fix test by throwing Error
Keyrxng Aug 13, 2024
0708d75
chore: sanitize metadata comment
Keyrxng Aug 14, 2024
6405b1a
chore: improve sanity checks
Keyrxng Aug 14, 2024
fc97c1d
chore: log message
Keyrxng Aug 19, 2024
059010c
chore: bump logger and fix bubble-up error comment
Keyrxng Aug 21, 2024
1ab9112
fix: hide deadline if no time label
Keyrxng Aug 21, 2024
84a6d26
chore: formatting
Keyrxng Aug 24, 2024
13e0b4c
feat: added worker deploy / delete capabilities
gentlementlegen Aug 28, 2024
8d5c56a
feat: max task assignment for collaborators
Jul 14, 2024
9b7bbdf
feat: make task limits configurable
Jul 15, 2024
32b0456
fix: get contributors from config
Jul 22, 2024
09c5337
fix: remove union type
Jul 22, 2024
b4696c8
fix: return lowest task limit if user role doesnt match any of those …
Jul 23, 2024
c251f5b
chore: code cleanups
Jul 23, 2024
dce8531
test: add test to cover functionality
Jul 23, 2024
4b9dbaa
test: cleanups
Jul 29, 2024
c10accd
test: made requested changes
Jul 30, 2024
2a35496
test: cleanpup test
Jul 30, 2024
f308aca
fix: assignee issue and open pr fetching
Keyrxng Jul 31, 2024
675ccf1
chore: tests
Keyrxng Jul 31, 2024
a13b2ea
chore: ci
Keyrxng Jul 31, 2024
d62cfe5
fix: add validation to check for duplicate roles
jordan-ae Aug 15, 2024
a5bd14d
fix: user t.record and loop by object.entries
jordan-ae Aug 15, 2024
61294ab
chore: revert to staticDecode
jordan-ae Aug 28, 2024
0cd8a49
chore: rebase to development
jordan-ae Aug 29, 2024
ea30c4e
chore: rebase to development
jordan-ae Aug 29, 2024
c0658ee
Merge branch 'development' into max-assignments
jordan-ae Aug 29, 2024
d318b3b
chore: cleanups
jordan-ae Aug 29, 2024
a927772
Merge branch 'development' into max-assignments
jordan-ae Aug 30, 2024
579e7b4
Merge branch 'development' into max-assignments
jordan-ae Sep 2, 2024
0097358
clean up merge
jordan-ae Sep 2, 2024
1837930
test: fixed test to reflect merge
jordan-ae Sep 2, 2024
38b1653
fix: remove individual limit comment
Keyrxng Sep 3, 2024
6151b52
fix: remove unneeded usage of no wallet string param
Keyrxng Sep 3, 2024
a9b21e0
fix: pass decoded env
Keyrxng Sep 3, 2024
4deb883
chore: use BOT_USER_ID not APP_ID
Keyrxng Sep 3, 2024
84c8465
fix: fix failling knip and double logging max limit error message
jordan-ae Sep 3, 2024
14f8e5f
fix: remove openedPullRequest checks for maxlimit
jordan-ae Sep 3, 2024
99ccab3
fix: remove duplicate maxTask checks
jordan-ae Sep 3, 2024
d0e17be
test: fix failing test
jordan-ae Sep 5, 2024
0a4ed48
Update src/types/plugin-input.ts
jordan-ae Sep 5, 2024
c2c924f
Update src/handlers/shared/start.ts
jordan-ae Sep 5, 2024
c36c956
chore: fix read me example indentation
jordan-ae Sep 5, 2024
0bfa5e0
fix: address duplicate logging on max limit
jordan-ae Sep 5, 2024
acb2388
chore: fix readme
jordan-ae Sep 5, 2024
3a80686
chore: cleanup code to avoid tenaries
jordan-ae Sep 6, 2024
4c29657
fix: add rolesWithReviewAuth to config
Keyrxng Sep 7, 2024
3406e99
chore(WIP): pull request link
gentlementlegen Sep 7, 2024
b109151
chore(WIP): pull request reopened
gentlementlegen Sep 7, 2024
3bccb6e
chore(WIP): pull request reopened
gentlementlegen Sep 7, 2024
caac1a4
chore(WIP): pull request reopened
gentlementlegen Sep 7, 2024
7fa4563
chore(WIP): added graphql
gentlementlegen Sep 7, 2024
c6b194f
chore(WIP): check linked pull-requests
gentlementlegen Sep 7, 2024
201153f
chore(WIP): check linked pull-requests
gentlementlegen Sep 7, 2024
c5b92dc
chore(WIP): check linked pull-requests
gentlementlegen Sep 7, 2024
b90a560
chore(WIP): check linked pull-requests
gentlementlegen Sep 7, 2024
6c0fd74
chore(WIP): check linked pull-requests
gentlementlegen Sep 7, 2024
b3f8c36
chore(WIP): check linked pull-requests
gentlementlegen Sep 7, 2024
944c7a4
chore(WIP): check linked pull-requests
gentlementlegen Sep 7, 2024
94b7723
Merge branch 'development' into max-assignments
jordan-ae Sep 7, 2024
9416b25
fix: check limit per role correctly
jordan-ae Sep 7, 2024
bd4d1cb
chore: revery change in package json
jordan-ae Sep 7, 2024
ba92dd7
chore: remove optional access to the LogReturn
jordan-ae Sep 7, 2024
14f3ceb
chore: validate org login
jordan-ae Sep 7, 2024
910b15e
chore: user is properly assigned on PR opened
gentlementlegen Sep 9, 2024
19743ea
chore: not trying to assign if already assigned
gentlementlegen Sep 9, 2024
cccad44
chore: not assigned if already assigned before
gentlementlegen Sep 9, 2024
c8a5180
chore: fixed compile issue
gentlementlegen Sep 9, 2024
f500886
chore: fixed compile issue
gentlementlegen Sep 9, 2024
41a8058
fix: added test for start with carriage returns
gentlementlegen Sep 9, 2024
b9bfbc8
chore: fixed test
gentlementlegen Sep 9, 2024
641ba7d
chore: fixed test
gentlementlegen Sep 9, 2024
d6c40e9
Merge pull request #44 from gentlementlegen/fix/trim-command
gentlementlegen Sep 9, 2024
243dc32
chore: removed reopened event
gentlementlegen Sep 9, 2024
6e43a1b
Merge pull request #39 from gentlementlegen/feat/assign-user-pr
0x4007 Sep 9, 2024
bdfc144
chore: remove unnecessary github comment, edit assigned table text
hhio618 Sep 9, 2024
7616bad
Merge pull request #45 from hhio618/development
0x4007 Sep 9, 2024
2f6703d
Update context.ts
gentlementlegen Sep 11, 2024
210d943
feat: closing user pull-requests when unassigned
gentlementlegen Sep 11, 2024
f426e1e
chore: call pre-made function to close PRs
gentlementlegen Sep 11, 2024
d7ad58a
chore: added test for user manual unassign
gentlementlegen Sep 11, 2024
b313fa8
chore: format with prettier
jordan-ae Sep 11, 2024
27156e1
Merge branch 'development' into max-assignments
jordan-ae Sep 11, 2024
c13327c
Merge pull request #35 from ubq-testing/development
ubiquity-os[bot] Sep 11, 2024
106a7e5
Merge branch 'development' into max-assignments
jordan-ae Sep 11, 2024
a4df1b9
fix: cleanup merge
jordan-ae Sep 11, 2024
7b4e031
chore: remove limits for admins
jordan-ae Sep 12, 2024
182998e
Merge pull request #9 from ubq-test-jordan/max-assignments
0x4007 Sep 12, 2024
2f97534
chore: changed check for issue payload
gentlementlegen Sep 13, 2024
bb91b11
Merge branch 'development' into feat/close-prs
gentlementlegen Sep 13, 2024
5305d79
chore: new assign design
0x4007 Sep 14, 2024
ed893b1
chore: bump ci
0x4007 Sep 14, 2024
49dc410
chore(ci): bump
0x4007 Sep 14, 2024
cc9e891
chore: removed linked PR closed comment
gentlementlegen Sep 14, 2024
e9b7bd6
Merge pull request #46 from gentlementlegen/feat/close-prs
gentlementlegen Sep 14, 2024
cc6ccfa
fix: change checks for invalid env to get more details
gentlementlegen Sep 16, 2024
d6ec3ae
chore: added error logs
gentlementlegen Sep 16, 2024
84d4641
feat: added admin infinity in decode
gentlementlegen Sep 16, 2024
944e879
chore: added related tests to configuration
gentlementlegen Sep 16, 2024
a2b30f5
chore: removed logs
gentlementlegen Sep 16, 2024
0820f92
Merge branch 'ubiquibot:development' into fix/approved-roles
Keyrxng Sep 16, 2024
06592fd
Merge pull request #52 from gentlementlegen/fix/schema-decode
0x4007 Sep 17, 2024
4194952
Merge branch 'development' into chore/new-assign-design
gentlementlegen Sep 19, 2024
32082db
fix: fixed tip display and removed bold
gentlementlegen Sep 19, 2024
77a2fba
chore: removed bold for warning
gentlementlegen Sep 19, 2024
7ccec7f
chore: fixed test
gentlementlegen Sep 19, 2024
c8de57e
Merge pull request #53 from gentlementlegen/chore/new-assign-design
0x4007 Sep 19, 2024
d0df976
Merge remote-tracking branch 'upstream/development' into fix/approved…
Keyrxng Sep 19, 2024
d9054ea
chore: fix setting default and tests
Keyrxng Sep 19, 2024
4543ca6
chore: normalize maxTask roles, add test
Keyrxng Sep 19, 2024
5a4c243
chore: change test role
Keyrxng Sep 19, 2024
a4f9ecb
Update tests/main.test.ts
Keyrxng Sep 19, 2024
44454b7
chore: format
Keyrxng Sep 19, 2024
9370bac
Update table.ts
Keyrxng Sep 19, 2024
b49ef68
Merge pull request #54 from ubiquibot/Keyrxng-patch-1
0x4007 Sep 19, 2024
58b457e
feat: added validator endpoint
gentlementlegen Sep 20, 2024
05bacd5
Merge pull request #37 from ubq-testing/fix/approved-roles
ubiquity-os[bot] Sep 23, 2024
30959ec
feat: pull edit handler
gentlementlegen Sep 23, 2024
818e747
chore: fixed errors
gentlementlegen Sep 23, 2024
56e061e
chore: fixed errors
gentlementlegen Sep 23, 2024
564a7e4
chore: fixed errors
gentlementlegen Sep 23, 2024
3349b9a
Merge pull request #57 from gentlementlegen/fix/pull-edit
0x4007 Sep 23, 2024
6024e9c
chore: fixed tests
gentlementlegen Sep 23, 2024
41d0023
Merge pull request #58 from gentlementlegen/development
0x4007 Sep 24, 2024
8dd8463
fix: register warning message change
gentlementlegen Sep 26, 2024
e3b3313
chore: register warning message change
gentlementlegen Sep 26, 2024
c9fc81c
Merge pull request #59 from gentlementlegen/fix/register-warning
0x4007 Sep 26, 2024
3f61f14
fix: removed duplicate error messages
gentlementlegen Sep 30, 2024
a48f8a7
chore: fix wrangler version
gentlementlegen Sep 30, 2024
3ece0fd
chore: fixed tests
gentlementlegen Sep 30, 2024
0b3a2bf
chore: enabled observability
gentlementlegen Oct 2, 2024
ea1b270
chore: bump wrangler
gentlementlegen Oct 2, 2024
b4a84fe
Merge branch 'development' into fix/duplicate-error-messages
gentlementlegen Oct 2, 2024
be81469
chore: fixed import
gentlementlegen Oct 2, 2024
886425d
Merge pull request #61 from gentlementlegen/fix/duplicate-error-messages
0x4007 Oct 2, 2024
9180717
fix: add rolesWithReviewAuth to config
Keyrxng Sep 7, 2024
04d081a
chore: fix setting default and tests
Keyrxng Sep 19, 2024
258b134
chore: normalize maxTask roles, add test
Keyrxng Sep 19, 2024
ea9c416
chore: change test role
Keyrxng Sep 19, 2024
2a3b42e
Update tests/main.test.ts
Keyrxng Sep 19, 2024
46cfcf4
chore: format
Keyrxng Sep 19, 2024
188d00e
feat: pull edit handler
gentlementlegen Sep 23, 2024
13bc655
chore: fixed tests
gentlementlegen Sep 23, 2024
8868146
fix: register warning message change
gentlementlegen Sep 26, 2024
3333aee
chore: register warning message change
gentlementlegen Sep 26, 2024
da03c15
fix: removed duplicate error messages
gentlementlegen Sep 30, 2024
a158660
chore: fix wrangler version
gentlementlegen Sep 30, 2024
1eea2ee
chore: fixed tests
gentlementlegen Sep 30, 2024
1e4f1ad
chore: enabled observability
gentlementlegen Oct 2, 2024
7162e23
chore: bump wrangler
gentlementlegen Oct 2, 2024
8fec87e
chore: fixed import
gentlementlegen Oct 2, 2024
5999073
feat: schema generation
gentlementlegen Oct 4, 2024
ed69ffa
chore: schema generation
gentlementlegen Oct 4, 2024
8548aad
Merge branch 'development' into feat/schema-validation
gentlementlegen Oct 4, 2024
7e8fcc1
chore: schema generation
gentlementlegen Oct 4, 2024
233b2b2
chore: schema generation
gentlementlegen Oct 4, 2024
f838618
chore: schema generation
gentlementlegen Oct 4, 2024
b000a54
chore: schema generation
gentlementlegen Oct 4, 2024
064a4b1
chore: schema generation
gentlementlegen Oct 4, 2024
0250520
chore: schema generation
gentlementlegen Oct 4, 2024
b0b21f7
chore: schema generation
gentlementlegen Oct 4, 2024
7685217
chore: updated generated configuration
ubiquity-os[bot] Oct 4, 2024
2f3f8b0
Merge pull request #63 from gentlementlegen/feat/schema-validation
gentlementlegen Oct 4, 2024
413c844
feat: enforce collaborator-only label restriction
gentlementlegen Oct 10, 2024
c5e58f5
feat(tests): add collaborator tests for issue assignment
gentlementlegen Oct 10, 2024
ef125f2
test: add database drop in beforeEach of User start/stop tests
gentlementlegen Oct 10, 2024
65248b1
Update src/handlers/shared/start.ts
0x4007 Oct 10, 2024
4a954be
fix(tests): update error message for collaborators assignment
gentlementlegen Oct 10, 2024
7445be1
Merge pull request #65 from gentlementlegen/feat/task-restriction
0x4007 Oct 10, 2024
1ceebb3
refactor: rename package and update references from @ubiquibot to @ub…
0x4007 Oct 10, 2024
32a4457
fix: collaborator check with try catch
gentlementlegen Oct 29, 2024
c49982b
fix: using graphql to fetch prs
gentlementlegen Oct 29, 2024
995e6be
chore: changed wrangler port
gentlementlegen Oct 29, 2024
91a375e
chore: http request for test
gentlementlegen Oct 29, 2024
fd65299
chore: prs fetch (WIP)
gentlementlegen Oct 29, 2024
3f535b2
refactor: remove prs.ts and update pull request fetching
gentlementlegen Oct 29, 2024
cf145f0
chore: add @octokit/types dependency
gentlementlegen Oct 29, 2024
742b3e4
refactor: update pull request fetching logic
gentlementlegen Oct 29, 2024
16ba3a8
fix: add fallback methods for fetching issues/PRs
gentlementlegen Oct 29, 2024
3d760e3
fix: update octokit method namespace
gentlementlegen Oct 29, 2024
f6232c0
test: add tests for `getAllPullRequestsWithRetry`
gentlementlegen Oct 29, 2024
5dd9641
test: removed comment
gentlementlegen Oct 29, 2024
b960b84
Merge pull request #71 from gentlementlegen/fix/gql
gentlementlegen Oct 30, 2024
82064c5
fix(issue): handle 404 status in fetch pull request reviews
gentlementlegen Nov 4, 2024
f496b20
build: set environment based on branch ref
gentlementlegen Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"supabase",
"SUPABASE",
"typebox",
"ubiquibot",
"ubiquity-os",
"signoff",
"sonarjs",
"mswjs",
Expand Down
1 change: 1 addition & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SUPABASE_URL=
SUPABASE_KEY=
BOT_USER_ID=
61 changes: 61 additions & 0 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "Update Configuration"

on:
workflow_dispatch:
push:

jobs:
update:
name: "Update Configuration in manifest.json"
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
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/worker-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
delete:
runs-on: ubuntu-latest
name: Delete Deployment
environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }}
steps:
- name: Setup Node
uses: actions/setup-node@v4
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }}
steps:
- name: Setup Node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -35,17 +36,17 @@ jobs:
id: wrangler_deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.57.0"
wranglerVersion: "3.79.0"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
APP_ID
BOT_USER_ID
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
APP_ID: ${{ secrets.APP_ID }}
BOT_USER_ID: ${{ secrets.BOT_USER_ID }}

- name: Write Deployment URL to Summary
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ junit.xml
cypress/screenshots
script.ts
.wrangler
test-dashboard.md
test-dashboard.md
*.env.json
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `@ubiquibot/command-start-stop`
# `@ubiquity-os/command-start-stop`

This plugin allows a hunter to begin a task as well as gracefully stop a task without incurring a negative impact on the hunter's XP or karma.

Expand All @@ -24,9 +24,9 @@ To stop a task, a hunter should use the `/stop` command. This will unassign them

### [Configuration](./src/types/plugin-input.ts)

#### Note: The command name is `"start"` when configuring your `.ubiquibot-config.yml` file.
#### Note: The command name is `"start"` when configuring your `.ubiquity-os.config.yml` file.

To configure your Ubiquibot to run this plugin, add the following to the `.ubiquibot-config.yml` file in your organization configuration repository.
To configure your Ubiquibot to run this plugin, add the following to the `.ubiquity-os.config.yml` file in your organization configuration repository.

```yml
- plugin: http://localhost:4000 # or the URL where the plugin is hosted
Expand All @@ -38,9 +38,12 @@ To configure your Ubiquibot to run this plugin, add the following to the `.ubiqu
with:
reviewDelayTolerance: "3 Days"
taskStaleTimeoutDuration: "30 Days"
maxConcurrentTasks: 3
maxConcurrentTasks: # Default concurrent task limits per role.
member: 5
contributor: 3
startRequiresWallet: true # default is true
emptyWalletText: "Please set your wallet address with the /wallet command first and try again."
rolesWithReviewAuthority: ["MEMBER", "OWNER"]
```

# Testing
Expand Down
6 changes: 6 additions & 0 deletions graphql.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
schema:
- https://api.github.com/graphql:
headers:
Authorization: Bearer ${GITHUB_TOKEN}
documents: src/**.ts
projects: {}
64 changes: 62 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"name": "Start | Stop",
"description": "Assign or un-assign yourself from an issue.",
"ubiquity:listeners": ["issue_comment.created", "issues.assigned"],
"ubiquity:listeners": [
"issue_comment.created",
"issues.assigned",
"issues.unassigned",
"pull_request.opened",
"pull_request.edited"
],
"commands": {
"start": {
"ubiquity:example": "/start",
Expand All @@ -11,5 +17,59 @@
"ubiquity:example": "/stop",
"description": "Unassign yourself from the issue."
}
},
"configuration": {
"default": {},
"type": "object",
"properties": {
"reviewDelayTolerance": {
"default": "1 Day",
"type": "string"
},
"taskStaleTimeoutDuration": {
"default": "30 Days",
"type": "string"
},
"startRequiresWallet": {
"default": true,
"type": "boolean"
},
"maxConcurrentTasks": {
"default": {
"member": 10,
"contributor": 2
},
"type": "object",
"patternProperties": {
"^(.*)$": {
"type": "integer"
}
}
},
"emptyWalletText": {
"default": "Please set your wallet address with the /wallet command first and try again.",
"type": "string"
},
"rolesWithReviewAuthority": {
"default": [
"COLLABORATOR",
"OWNER",
"MEMBER",
"ADMIN"
],
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"reviewDelayTolerance",
"taskStaleTimeoutDuration",
"startRequiresWallet",
"maxConcurrentTasks",
"emptyWalletText",
"rolesWithReviewAuthority"
]
}
}
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ubiquibot/command-start-stop",
"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",
Expand All @@ -9,8 +9,6 @@
"node": ">=20.10.0"
},
"scripts": {
"start": "tsx build/esbuild-server.ts",
"build": "tsx build/esbuild-build.ts",
"format": "run-s format:lint format:prettier format:cspell",
"format:lint": "eslint --fix .",
"format:prettier": "prettier --write .",
Expand All @@ -29,11 +27,14 @@
"open-source"
],
"dependencies": {
"@octokit/graphql-schema": "15.25.0",
"@octokit/plugin-paginate-graphql": "5.2.2",
"@octokit/rest": "20.1.1",
"@octokit/types": "^13.6.1",
"@octokit/webhooks": "13.2.7",
"@sinclair/typebox": "^0.32.5",
"@supabase/supabase-js": "2.42.0",
"@ubiquity-dao/ubiquibot-logger": "^1.3.1",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"dotenv": "^16.4.4",
"ms": "^2.1.3",
"typebox-validators": "^0.3.5"
Expand Down Expand Up @@ -66,9 +67,9 @@
"prettier": "3.3.2",
"ts-jest": "29.1.5",
"tsx": "4.15.6",
"typescript": "5.4.5",
"typescript": "5.6.2",
"typescript-eslint": "7.13.1",
"wrangler": "3.60.3"
"wrangler": "^3.79.0"
},
"lint-staged": {
"*.ts": [
Expand Down
4 changes: 1 addition & 3 deletions src/adapters/supabase/helpers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ 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.config.emptyWalletText);
await addCommentToIssue(this.context, this.context.logger.error(this.context.config.emptyWalletText, { userId, issueNumber }).logMessage.diff);
throw new Error("No wallet address found");
} else {
await addCommentToIssue(this.context, this.context.config.emptyWalletText);
}
} else {
this.context.logger.info("Successfully fetched wallet", { userId, address: data.wallets?.address });
Expand Down
12 changes: 9 additions & 3 deletions src/handlers/shared/check-assignments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Context } from "../../types";
import { getOwnerRepoFromHtmlUrl } from "../../utils/issue";

async function getUserStopComments(context: Context, username: string): Promise<number> {
if (!("issue" in context.payload)) {
throw new Error("The context does not contain an issue.");
}
const { payload, octokit, logger } = context;
const { number, html_url } = payload.issue;
const { owner, repo } = getOwnerRepoFromHtmlUrl(html_url);
Expand All @@ -21,7 +24,7 @@ async function getUserStopComments(context: Context, username: string): Promise<

export async function hasUserBeenUnassigned(context: Context, username: string): Promise<boolean> {
const {
env: { APP_ID },
env: { BOT_USER_ID },
} = context;
const events = await getAssignmentEvents(context);
const userAssignments = events.filter((event) => event.assignee === username);
Expand All @@ -33,9 +36,9 @@ export async function hasUserBeenUnassigned(context: Context, username: string):
const unassignedEvents = userAssignments.filter((event) => event.event === "unassigned");
// all bot unassignments (/stop, disqualification, etc)
// TODO: task-xp-guard: will also prevent future assignments so we need to add a comment tracker we can use here
const botUnassigned = unassignedEvents.filter((event) => event.actorId === APP_ID);
const botUnassigned = unassignedEvents.filter((event) => event.actorId === BOT_USER_ID);
// UI assignment
const adminUnassigned = unassignedEvents.filter((event) => event.actor !== username && event.actorId !== APP_ID);
const adminUnassigned = unassignedEvents.filter((event) => event.actor !== username && event.actorId !== BOT_USER_ID);
// UI assignment
const userUnassigned = unassignedEvents.filter((event) => event.actor === username);
const userStopComments = await getUserStopComments(context, username);
Expand All @@ -52,6 +55,9 @@ export async function hasUserBeenUnassigned(context: Context, username: string):
}

async function getAssignmentEvents(context: Context) {
if (!("issue" in context.payload)) {
throw new Error("The context does not contain an issue.");
}
const { repository, issue } = context.payload;
try {
const data = await context.octokit.paginate(context.octokit.issues.listEventsForTimeline, {
Expand Down
24 changes: 14 additions & 10 deletions src/handlers/shared/generate-assignment-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const options: Intl.DateTimeFormatOptions = {
timeZoneName: "short",
};

export function getDeadline(issue: Context["payload"]["issue"]): string | null {
if (!issue?.labels) {
export function getDeadline(labels: Context<"issue_comment.created">["payload"]["issue"]["labels"] | undefined | null): string | null {
if (!labels?.length) {
throw new Error("No labels are set.");
}
const startTime = new Date().getTime();
const duration: number = calculateDurations(issue.labels).shift() ?? 0;
const duration: number = calculateDurations(labels).shift() ?? 0;
if (!duration) return null;
const endTime = new Date(startTime + duration * 1000);
return endTime.toLocaleString("en-US", options);
Expand All @@ -30,12 +30,16 @@ export async function generateAssignmentComment(context: Context, issueCreatedAt
deadline: deadline ?? null,
registeredWallet:
(await context.adapters.supabase.user.getWalletByUserId(senderId, issueNumber)) ||
"Register your wallet address using the following slash command: `/wallet 0x0000...0000`",
tips: `<h6>Tips:</h6>
<ul>
<li>Use <code>/wallet 0x0000...0000</code> if you want to update your registered payment wallet address.</li>
<li>Be sure to open a draft pull request as soon as possible to communicate updates on your progress.</li>
<li>Be sure to provide timely updates to us when requested, or you will be automatically unassigned from the task.</li>
<ul>`,
`

> [!WARNING]
> Register your wallet to be eligible for rewards.

`,
tips: `
> [!TIP]
> - Use <code>/wallet 0x0000...0000</code> if you want to update your registered payment wallet address.
> - Be sure to open a draft pull request as soon as possible to communicate updates on your progress.
> - Be sure to provide timely updates to us when requested, or you will be automatically unassigned from the task.`,
};
}
Loading
Loading