feat: track pull requests #20
No reviewers
Labels
No labels
bug
docs
duplicate
enhancement
help wanted
question
refactor
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
uzinfocom/kotiba!20
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pr-tracking"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every pull request delivery is saved as an event, together with the PR, its changed files and commit authors, so we can build monthly reports from Postgres. Webhook answers first and one worker does the rest, if a job fails the reason stays on the event.
Depends on the forgejo library PR - link.
botsis required inconfig.tomlnow (bots = []if none),seed.jsonneedsbotrole after the two existing ones, andusers.rolebecomes nullable.Need to implement assignees and labels, exporting reports through REST API, issues, and enhancing workers project-wide as separate PRs.
Additional: Fixed treefmt integration with git hooks.
@ -5,3 +3,1 @@type: gitlocation: https://github.com/uzinfocom-org/forgejo.gittag: main./../forgejodon't forget revert
@ -0,0 +86,4 @@, PullRequestFileRemovedAt ==. Nothing][ PullRequestFileRemovedAt =. Just now ]forM_ files $ \f ->use eta reduce
@ -0,0 +96,4 @@replaceCommits pr commits = dolet shas = (.pullRequestCommitSha) <$> commitsdeleteWhere [PullRequestCommitPullRequest ==. pr, PullRequestCommitSha /<-. shas]forM_ commits $ \c ->use eta reduce
forM_ commits $ upsertBy ...How? c is used 6 times
WIP: [FEATURE]: PR trackingto feat: track pull requests@ -0,0 +34,4 @@eventKind PullRequestPayload{..} = actionKind prpAction-- | This function maps action of PR into kind of event. Actions which we don't need become 'PROther'.actionKind :: HookPullRequestAction -> PREventKindLambdaCase@ -0,0 +68,4 @@-- | This function gives Forgejo id and login of user, they are the arguments of 'getOrCreateUser'.person :: User -> (FrId, Text)person User{..} = (frUser userId, userLogin)this function used only inside
resolveUserI think it's fine to keep it local.No
@ -0,0 +93,4 @@Nothing-- | This function maps status of file from Forgejo into our type. Unknown status becomes 'FileOther'.fileStatus :: Text -> PullRequestFileStatususe
LambdaCase@ -0,0 +53,4 @@worker :: (AppState) => IO ()worker = forever $ dojob <- atomically $ readTQueue ?st.trackQueuerunExceptT (runJob job) >>= either (lastResort job) pureIn my opinion, the handling of exceptions in the worker needs to be better thought out.
What do you suggest?
We need to consider what actions we can take if exceptions or invariant violations occur. If we had opened a new issue for this topic, the work wouldn't have stalled. Another point is that we used
monad-loggerinside thelastResortfunction. We already have a thread open for choosing a logger.My suggestion is to open a new issue on this topic.
BWT: The
ExceptTis a good start, but we have to do a lot of lifting and transforming.And you can see little boilerplate code here
So we gonna last enhancing loggers to separate PRs, right?
@ -0,0 +34,4 @@seedIfChanged st seedPath = dolet mtimePath = seedPath <> ".mtime"_exists <- liftIO $ doesFileExist seedPathif you see old code we print error about seed not exists and this code used debugging in production, because we must know if file not exists.