Skip to content

Commit

Permalink
Merge pull request #28 from ubiquity-os-marketplace/development
Browse files Browse the repository at this point in the history
October Sync
  • Loading branch information
gentlementlegen authored Oct 10, 2024
2 parents 34520f1 + 54f0e06 commit fa65596
Show file tree
Hide file tree
Showing 61 changed files with 2,112 additions and 1,709 deletions.
17 changes: 16 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/*.http", "**/*.toml", "src/types/database.ts", "supabase/migrations/**", "tests/**"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "typebox", "supabase", "ubiquibot", "mswjs", "luxon", "millis"],
"words": [
"dataurl",
"devpool",
"outdir",
"servedir",
"typebox",
"supabase",
"ubiquibot",
"mswjs",
"luxon",
"millis",
"handl",
"sonarjs",
"mischeck",
"unassigns"
],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
Expand Down
2 changes: 0 additions & 2 deletions .dev.vars.example

This file was deleted.

2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '3.57.0'
wranglerVersion: "3.57.0"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
secrets: |
SUPABASE_URL
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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: Install deps and run configuration update
run: |
yarn install --immutable --immutable-cache --check-cache
yarn tsc --noCheck --project tsconfig.json
- name: Update manifest configuration using GitHub Script
uses: actions/github-script@v7
with:
script: |
(async () => {
const fs = await import('fs/promises');
const path = await import('path');
const { pluginSettingsSchema } = await import("${{ github.workspace }}/src/types/plugin-inputs.js");
const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json');
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
const configuration = JSON.stringify(pluginSettingsSchema);
manifest["configuration"] = JSON.parse(configuration);
const updatedManifest = JSON.stringify(manifest, null, 2);
console.log('Updated manifest:', updatedManifest);
await fs.writeFile(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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ cypress/screenshots
.dev.vars
/tests/http/http-client.private.env.json
.wrangler
test-dashboard.md
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

## 1.0.0 (2024-07-09)

### Features

- added testing ([c834de9](https://github.com/ubiquibot/user-activity-watcher/commit/c834de9edefce23c11dc4d91ecc48d7e16ed3e5f))
- changed the time parsing to be with ms package ([99fa8f7](https://github.com/ubiquibot/user-activity-watcher/commit/99fa8f74524552b8dd17ae0dd6a66da3782abab3))
- database generation script ([6f19d4d](https://github.com/ubiquibot/user-activity-watcher/commit/6f19d4d0722dbcfd4e3b59ce1dddb94a550a20ac))
- database generation script ([fb4be18](https://github.com/ubiquibot/user-activity-watcher/commit/fb4be189de5c07794d05099acc9b61991f9813bf))
- linked pull request activity is now taken into account ([790d1c1](https://github.com/ubiquibot/user-activity-watcher/commit/790d1c12e3b1d716e72756e486723c3fe018d252))
- threshold can be expressed as human-readable strings ([df167d0](https://github.com/ubiquibot/user-activity-watcher/commit/df167d0b29335c1143ff6e1e6c2f11f0529e59c5))
- user get reminded and unassigned ([797cd6e](https://github.com/ubiquibot/user-activity-watcher/commit/797cd6e27788e119de27722118fbcf766ce4e79a))

### Bug Fixes

- moved get env outside of main file ([cb55e61](https://github.com/ubiquibot/user-activity-watcher/commit/cb55e610d5ec2d7dd936f97155f2cc1814c1302d))
- updated Jest test comment ([d6d5e28](https://github.com/ubiquibot/user-activity-watcher/commit/d6d5e2881a106568f1b2eb6ba9710041dba75950))
40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
# @ubiquibot/user-activity-watcher

Watches user activity on issues, sends reminders on deadlines, and eventually unassigns inactive user to ensure that
Watches user activity on issues, sends reminders on deadlines, and eventually unassigns inactive user to ensure that
tasks don't stall, and subtracts XP.

## Setup

```shell
yarn install
```

Then copy `.dev.vars.example` to `.dev.vars` and fill the required values.

### Database

To start a local instance, run

```shell
supabase start
```

Afterward, you can generate types for full auto-completion with
```shell
yarn supabase:generate:local
```

### Worker
Start the Worker by running
```shell
yarn dev
```

### Make requests
To trigger the worker, `POST` requests should be made to http://localhost:4000 with a `Content-Type: application/json`
header and a body looking like
```json
{
"stateId": "",
"eventName": "",
"eventPayload": "",
"settings": "",
"ref": ""
}
yarn supabase:generate:local
```
For convenience, you can find an `.http` file with a valid request [here](/tests/http/request.http).

### Test

To start Jest testing, run

```shell
yarn test
```

## Valid configuration

```yaml
- plugin: ubiquibot/user-activity-watcher
type: github
with:
disqualification: "7 days"
warning: "3.5 days"
watch:
optOut:
- "repoName"
- "repoName2"
eventWhitelist: # these are the tail of the webhook event i.e pull_request.review_requested
- "review_requested"
- "ready_for_review"
- "commented"
- "committed"
```
File renamed without changes.
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/handlers/collect-linked-pulls.ts
projects: {}
56 changes: 56 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "User activity watcher",
"description": "Watches user activity on issues, sends reminders on deadlines, and unassign inactive users.",
"ubiquity:listeners": [
"pull_request_review_comment.created",
"issue_comment.created",
"push"
],
"configuration": {
"default": {},
"type": "object",
"properties": {
"warning": {
"default": "3.5 days",
"type": "string"
},
"watch": {
"type": "object",
"properties": {
"optOut": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"optOut"
]
},
"disqualification": {
"default": "7 days",
"type": "string"
},
"eventWhitelist": {
"default": [
"pull_request.review_requested",
"pull_request.ready_for_review",
"pull_request_review_comment.created",
"issue_comment.created",
"push"
],
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"warning",
"watch",
"disqualification",
"eventWhitelist"
]
}
}
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "user-activity-watcher",
"version": "1.0.0",
"description": "Watches user activity on issues, sends reminders on deadlines, and unassign inactive users.",
"main": "src/worker.ts",
"main": "src/index.ts",
"author": "Ubiquity DAO",
"license": "MIT",
"type": "module",
"engines": {
"node": ">=20.10.0"
},
"scripts": {
"dev": "wrangler dev --env dev --port 4000",
"start": "tsx src/index.ts",
"prebuild": "dotenv -- cross-env yarn supabase:generate:remote",
"format:lint": "eslint --fix .",
Expand All @@ -32,10 +32,11 @@
"dependencies": {
"@actions/core": "1.10.1",
"@actions/github": "6.0.0",
"@octokit/graphql-schema": "^15.25.0",
"@octokit/rest": "20.1.1",
"@octokit/webhooks": "13.2.7",
"@sinclair/typebox": "0.32.31",
"@supabase/supabase-js": "2.43.4",
"@ubiquity-dao/ubiquibot-logger": "^1.3.1",
"dotenv": "16.4.5",
"luxon": "3.4.4",
"ms": "2.1.3",
Expand All @@ -48,6 +49,7 @@
"@cspell/dict-node": "5.0.1",
"@cspell/dict-software-terms": "3.4.0",
"@cspell/dict-typescript": "3.1.5",
"@jest/globals": "^29.7.0",
"@mswjs/data": "0.16.1",
"@types/jest": "29.5.12",
"@types/luxon": "3.4.2",
Expand All @@ -71,8 +73,7 @@
"prettier": "3.3.0",
"supabase": "1.176.9",
"ts-jest": "29.1.4",
"typescript": "5.4.5",
"wrangler": "3.58.0"
"typescript": "5.6.2"
},
"lint-staged": {
"*.ts": [
Expand All @@ -87,5 +88,6 @@
"extends": [
"@commitlint/config-conventional"
]
}
},
"packageManager": "[email protected]"
}
67 changes: 0 additions & 67 deletions src/adapters/index.ts

This file was deleted.

Loading

0 comments on commit fa65596

Please sign in to comment.