Skip to content

Commit d9a3d7b

Browse files
committed
update prod
2 parents 40af674 + be2aedc commit d9a3d7b

File tree

13 files changed

+2015
-10
lines changed

13 files changed

+2015
-10
lines changed

.github/workflows/pr-assistant.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: PR Assistant
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
permissions:
8+
pull-requests: write
9+
issues: write
10+
contents: write
11+
12+
jobs:
13+
pr-assistant:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Generate GitHub App token
17+
id: app-token
18+
uses: actions/create-github-app-token@v2
19+
with:
20+
app-id: ${{ secrets.CODEX_ASSISTANT_APP_ID }}
21+
private-key: ${{ secrets.CODEX_ASSISTANT_PRIVATE_KEY }}
22+
23+
- uses: codex-team/action-pr-assistant@master
24+
with:
25+
check: description
26+
mode: draft
27+
token: ${{ steps.app-token.outputs.token }}

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "hawk.workers",
33
"private": true,
4-
"version": "0.0.1",
4+
"version": "0.1.0",
55
"description": "Hawk workers",
66
"repository": "git@github.com:codex-team/hawk.workers.git",
77
"license": "BUSL-1.1",
@@ -33,6 +33,7 @@
3333
"test:paymaster": "jest workers/paymaster",
3434
"test:notifier": "jest workers/notifier",
3535
"test:js": "jest workers/javascript",
36+
"test:task-manager": "jest workers/task-manager",
3637
"test:clear": "jest --clearCache",
3738
"run-default": "yarn worker hawk-worker-default",
3839
"run-sentry": "yarn worker hawk-worker-sentry",
@@ -47,7 +48,8 @@
4748
"run-release": "yarn worker hawk-worker-release",
4849
"run-email": "yarn worker hawk-worker-email",
4950
"run-telegram": "yarn worker hawk-worker-telegram",
50-
"run-limiter": "yarn worker hawk-worker-limiter"
51+
"run-limiter": "yarn worker hawk-worker-limiter",
52+
"run-task-manager": "yarn worker hawk-worker-task-manager"
5153
},
5254
"dependencies": {
5355
"@babel/parser": "^7.26.9",
@@ -61,7 +63,7 @@
6163
"amqplib": "^0.8.0",
6264
"codex-accounting-sdk": "codex-team/codex-accounting-sdk",
6365
"debug": "^4.1.1",
64-
"dotenv": "^8.2.0",
66+
"dotenv": "^17.2.3",
6567
"migrate-mongo": "^7.2.1",
6668
"mockdate": "^3.0.2",
6769
"mongodb": "^3.5.7",

workers/grouper/src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,10 @@ export default class GrouperWorker extends Worker {
132132
uniqueEventHash = similarEvent.groupHash;
133133

134134
existedEvent = similarEvent;
135-
}
136-
137-
/**
138-
* If we couldn't group by grouping pattern — try grouping bt hash (title)
139-
*/
140-
else {
135+
} else {
136+
/**
137+
* If we couldn't group by grouping pattern — try grouping by hash (title)
138+
*/
141139
/**
142140
* Find event by group hash.
143141
*/

workers/task-manager/.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Maximum number of auto-created tasks per project per day
2+
# Default: 10
3+
MAX_AUTO_TASKS_PER_DAY=10
4+
5+
# Number of tasks handling simultaneously
6+
# Default: 1
7+
SIMULTANEOUS_TASKS=1
8+
9+
# GitHub App configuration
10+
GITHUB_APP_ID=your_github_app_id
11+
GITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
12+
# Client ID of GitHub app
13+
GITHUB_APP_CLIENT_ID=Iv23li65HEIkWZXsm6qO
14+
# Generated in GitHub app settings
15+
GITHUB_APP_CLIENT_SECRET=0663e20d484234e17b0871c1f070581739c14e04

workers/task-manager/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Task Manager Worker
2+
3+
Worker for automatically creating GitHub issues for errors that meet the threshold.
4+
5+
## Description
6+
7+
This worker processes tasks to automatically create GitHub issues for events that:
8+
- Have `totalCount >= taskThresholdTotalCount`
9+
- Don't have a `taskManagerItem` (not yet processed)
10+
- Occurred after `taskManager.connectedAt`
11+
12+
## Rate Limiting
13+
14+
The worker implements daily rate limiting:
15+
- Maximum `MAX_AUTO_TASKS_PER_DAY` (default: 10) tasks per project per day
16+
- Uses atomic increment to prevent race conditions
17+
- Resets daily budget at the start of each UTC day
18+
19+
## Environment Variables
20+
21+
- `MAX_AUTO_TASKS_PER_DAY` - Maximum auto tasks per day (default: 10)
22+
- `GITHUB_APP_ID` - GitHub App ID
23+
- `GITHUB_PRIVATE_KEY` - GitHub App private key (PEM format)
24+
25+
## Usage
26+
27+
The worker is triggered by cron tasks with routing key `cron-tasks/task-manager` and payload:
28+
```json
29+
{
30+
"type": "auto-task-creation"
31+
}
32+
```

workers/task-manager/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "hawk-worker-task-manager",
3+
"version": "1.0.0",
4+
"main": "src/index.ts",
5+
"license": "MIT",
6+
"workerType": "cron-tasks/task-manager",
7+
"dependencies": {
8+
"@octokit/oauth-methods": "^4.0.0",
9+
"@octokit/rest": "^22.0.1",
10+
"@octokit/types": "^16.0.0",
11+
"jsonwebtoken": "^9.0.3"
12+
},
13+
"devDependencies": {
14+
"@types/jsonwebtoken": "^8.3.5"
15+
}
16+
}

0 commit comments

Comments
 (0)