feat: track pull requests #20

Merged
lambdajon merged 27 commits from feat/pr-tracking into main 2026-10-09 09:30:56 +00:00
Member

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. bots is required in config.toml now (bots = [] if none), seed.json needs bot role after the two existing ones, and users.role becomes 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.

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](https://git.oss.uzinfocom.uz/uzinfocom/forgejo/pulls/24). `bots` is required in `config.toml` now (`bots = []` if none), `seed.json` needs `bot` role after the two existing ones, and `users.role` becomes 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.
xfeusw self-assigned this 2026-10-03 01:32:44 +00:00
feat(seed): integrated bot role into seed and changed architecture of seed
Some checks failed
Test CI / Build Project (push) Failing after 14s
Test CI / Test flake (push) Failing after 34s
2b41d213e3
feat(types): initialized pr-tracking related types for database
Some checks failed
Test CI / Build Project (push) Failing after 10s
Test CI / Test flake (push) Failing after 29s
40ec1b9c40
refactor(types): using single unique records
Some checks failed
Test CI / Build Project (push) Failing after 9s
Test CI / Test flake (push) Failing after 22s
bda08e4208
refactor(database): reduced arg params
Some checks failed
Test CI / Build Project (push) Failing after 8s
Test CI / Test flake (push) Failing after 21s
b0b1d6d0a7
fix(backport types): returned old aio unique fields due to better filtering
Some checks failed
Test CI / Build Project (push) Failing after 9s
Test CI / Test flake (push) Failing after 22s
636c714406
fix(db): seed, pr and types
Some checks failed
Test CI / Build Project (push) Failing after 11s
Test CI / Test flake (push) Failing after 29s
Test CI / Build Project (pull_request) Failing after 10s
Test CI / Test flake (pull_request) Failing after 24s
c9c2ee9620
feat(pr tracking): basic implementation is working
Some checks failed
Test CI / Build Project (push) Failing after 12s
Test CI / Build Project (pull_request) Failing after 8s
Test CI / Test flake (push) Failing after 32s
Test CI / Test flake (pull_request) Failing after 36s
93b55f3af3
refactor(pr-tracking): file syncing and role mechanisms are improved
Some checks failed
Test CI / Build Project (push) Failing after 9m53s
Test CI / Build Project (pull_request) Failing after 8s
Test CI / Test flake (push) Failing after 19m36s
Test CI / Test flake (pull_request) Failing after 14m49s
d7d6bf8a6e
feat(seed): better error handling
Some checks failed
Test CI / Build Project (push) Failing after 9s
Test CI / Test flake (push) Failing after 27s
Test CI / Test flake (pull_request) Failing after 19s
Test CI / Build Project (pull_request) Failing after 8s
147f68a954
lambdajon requested changes 2026-10-05 11:28:09 +00:00
Dismissed
cabal.project Outdated
@ -5,3 +3,1 @@
type: git
location: https://github.com/uzinfocom-org/forgejo.git
tag: main
./../forgejo
Member

don't forget revert

don't forget revert
xfeusw marked this conversation as resolved
@ -0,0 +86,4 @@
, PullRequestFileRemovedAt ==. Nothing
]
[ PullRequestFileRemovedAt =. Just now ]
forM_ files $ \f ->
Member

use eta reduce

use eta reduce
lambdajon marked this conversation as resolved
@ -0,0 +96,4 @@
replaceCommits pr commits = do
let shas = (.pullRequestCommitSha) <$> commits
deleteWhere [PullRequestCommitPullRequest ==. pr, PullRequestCommitSha /<-. shas]
forM_ commits $ \c ->
Member

use eta reduce

forM_ commits $ upsertBy ...

use eta reduce `forM_ commits $ upsertBy ...`
Author
Member

How? c is used 6 times

How? c is used 6 times
lambdajon marked this conversation as resolved
refactor: clearing
Some checks failed
Test CI / Build Project (push) Failing after 10s
Test CI / Test flake (pull_request) Has been cancelled
Test CI / Test flake (push) Has been cancelled
Test CI / Build Project (pull_request) Has been cancelled
e9d5967b89
refactor: reformat
Some checks failed
Test CI / Build Project (push) Failing after 9s
Test CI / Build Project (pull_request) Failing after 8s
Test CI / Test flake (push) Failing after 27s
Test CI / Test flake (pull_request) Failing after 30s
95d6499e3b
fix: treefmt
Some checks failed
Test CI / Build Project (push) Failing after 8s
Test CI / Test flake (push) Failing after 23s
Test CI / Build Project (pull_request) Failing after 7s
Test CI / Test flake (pull_request) Failing after 25s
9234d950f7
fix(worker): written missing argument
Some checks failed
Test CI / Test flake (push) Failing after 31s
Test CI / Build Project (push) Failing after 8s
Test CI / Test flake (pull_request) Failing after 21s
Test CI / Build Project (pull_request) Failing after 8s
7a0f447d3b
refactor(database pr): comments and redundant functions removed
Some checks failed
Test CI / Build Project (push) Failing after 13s
Test CI / Test flake (push) Failing after 33s
Test CI / Test flake (pull_request) Failing after 23s
Test CI / Build Project (pull_request) Failing after 8s
e097f059bb
xfeusw changed title from WIP: [FEATURE]: PR tracking to feat: track pull requests 2026-10-08 05:37:11 +00:00
refactor(cabal): revert forgejo lib
Some checks failed
Test CI / Test flake (pull_request) Has been cancelled
Test CI / Build Project (pull_request) Has been cancelled
Test CI / Build Project (push) Has been cancelled
Test CI / Test flake (push) Has been cancelled
271f1fb573
refactor(seed): remove external role
Some checks failed
Test CI / Build Project (push) Failing after 10m46s
Test CI / Test flake (push) Failing after 21m50s
Test CI / Test flake (pull_request) Failing after 33m8s
Test CI / Build Project (pull_request) Failing after 33m26s
da9f7bdd55
lambdajon requested changes 2026-10-08 07:20:21 +00:00
Dismissed
@ -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 -> PREventKind
Member

LambdaCase

`LambdaCase`
xfeusw marked this conversation as resolved
@ -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)
Member

this function used only inside resolveUser I think it's fine to keep it local.

resolveUser :: (AppState, MonadIO m) => User -> m DB.UserId
resolveUser = uncurry getOrCreateUser . person
	where
	  person User{..} = (frUser userId, userLogin)
this function used only inside `resolveUser` I think it's fine to keep it local. ```hs resolveUser :: (AppState, MonadIO m) => User -> m DB.UserId resolveUser = uncurry getOrCreateUser . person where person User{..} = (frUser userId, userLogin) ```
Author
Member

image

No

![image](/attachments/8abd6a1c-d9fd-4d4c-ad96-83fa24f39fda) No
lambdajon marked this conversation as resolved
@ -0,0 +93,4 @@
Nothing
-- | This function maps status of file from Forgejo into our type. Unknown status becomes 'FileOther'.
fileStatus :: Text -> PullRequestFileStatus
Member

use LambdaCase

use `LambdaCase`
xfeusw marked this conversation as resolved
@ -0,0 +53,4 @@
worker :: (AppState) => IO ()
worker = forever $ do
job <- atomically $ readTQueue ?st.trackQueue
runExceptT (runJob job) >>= either (lastResort job) pure
Member

In my opinion, the handling of exceptions in the worker needs to be better thought out.

In my opinion, the handling of exceptions in the worker needs to be better thought out.
Author
Member

What do you suggest?

What do you suggest?
Member

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-logger inside the lastResort function. We already have a thread open for choosing a logger.

My suggestion is to open a new issue on this topic.

BWT: The ExceptT is a good start, but we have to do a lot of lifting and transforming.

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-logger` inside the `lastResort` function. We already have a [thread](https://git.oss.uzinfocom.uz/uzinfocom/kotiba/issues/21) open for choosing a logger. My suggestion is to open a new issue on this topic. BWT: The `ExceptT` is a good start, but we have to do a lot of lifting and transforming.
Member

And you can see little boilerplate code here

And you can see little boilerplate code [here](https://git.oss.uzinfocom.uz/xinux/relago-support/src/branch/main/server/src/API/Report.hs#L163)
Author
Member

So we gonna last enhancing loggers to separate PRs, right?

So we gonna last enhancing loggers to separate PRs, right?
xfeusw marked this conversation as resolved
chore(comments): resolved comments using LambdaCase
Some checks failed
Test CI / Build Project (push) Failing after 11s
Test CI / Build Project (pull_request) Failing after 9s
Test CI / Test flake (push) Failing after 32s
Test CI / Test flake (pull_request) Failing after 22s
82e30e51fc
fix(tracking): small fixes with typo
Some checks failed
Test CI / Test flake (push) Has been cancelled
Test CI / Build Project (push) Has been cancelled
Test CI / Test flake (pull_request) Has been cancelled
Test CI / Build Project (pull_request) Has been cancelled
62df122660
refactor(cabal): return forgejo
Some checks failed
Test CI / Build Project (pull_request) Has been cancelled
Test CI / Build Project (push) Has been cancelled
Test CI / Test flake (push) Has been cancelled
Test CI / Test flake (pull_request) Has been cancelled
be0350a0d0
refactor(tracking.worker): moved isMergeCommit into lib
Some checks failed
Test CI / Test flake (pull_request) Has been cancelled
Test CI / Build Project (pull_request) Has been cancelled
Test CI / Build Project (push) Has been cancelled
Test CI / Test flake (push) Has been cancelled
a96055aac1
Merge branch 'main' into feat/pr-tracking
Some checks failed
Test CI / Test flake (push) Failing after 12m19s
Test CI / Build Project (push) Failing after 19m46s
Test CI / Build Project (pull_request) Failing after 23m8s
Test CI / Test flake (pull_request) Failing after 41m48s
38a42e4de7
lambdajon requested changes 2026-10-09 07:13:46 +00:00
Dismissed
@ -0,0 +34,4 @@
seedIfChanged st seedPath = do
let mtimePath = seedPath <> ".mtime"
_exists <- liftIO $ doesFileExist seedPath
Member

if 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.

  exists <- doesFileExist seedPath
	  unless exists
	    $ hPutStrLn stderr
	    $ "Seed: file not found: " <> seedPath
if 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. ```hs exists <- doesFileExist seedPath unless exists $ hPutStrLn stderr $ "Seed: file not found: " <> seedPath ```
xfeusw marked this conversation as resolved
refactor(seed): sugars
Some checks failed
Test CI / Build Project (pull_request) Has been cancelled
Test CI / Build Project (push) Has been cancelled
Test CI / Test flake (push) Has been cancelled
Test CI / Test flake (pull_request) Has been cancelled
46f38570a1
refactor(cabal): forgejo source from github to gitoss
Some checks failed
Test CI / Build Project (pull_request) Has been cancelled
Test CI / Test flake (push) Has been cancelled
Test CI / Build Project (push) Has been cancelled
Test CI / Test flake (pull_request) Has been cancelled
641905eabf
refactor(cabal): revert to github
Some checks failed
Test CI / Build Project (push) Failing after 10m27s
Test CI / Test flake (push) Failing after 21m17s
Test CI / Test flake (pull_request) Failing after 33m24s
Test CI / Build Project (pull_request) Failing after 33m57s
b50b407afa
update revisions
Some checks failed
Test CI / Build Project (push) Successful in 12m3s
Test CI / Build Project (pull_request) Successful in 5s
Test CI / Test flake (push) Failing after 13m8s
Test CI / Test flake (pull_request) Failing after 10m57s
468c7664f2
lambdajon approved these changes 2026-10-09 09:30:20 +00:00
lambdajon deleted branch feat/pr-tracking 2026-10-09 09:30:56 +00:00
lambdajon referenced this pull request from a commit 2026-10-09 09:30:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
uzinfocom/kotiba!20
No description provided.