Repository navigation
Add release validator and regression tracking #590
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
Open
alisawavezen12
wants to merge
18
commits into
master
Choose a base branch
from
feat/release-validator-worker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8f58256
Add release validator worker
alisawavezen12 7d752cb
Track event regressions by release
alisawavezen12 8ac4dab
chore
alisawavezen12 d8164f7
Support repeated resolution and regression cycles
alisawavezen12 609adbc
Merge branch 'master' into feat/release-validator-worker
alisawavezen12 6455530
validate Events Batch
alisawavezen12 e77e4a3
Add release validator to Docker Compose
alisawavezen12 60df837
chore
alisawavezen12 1ee7b01
chore
alisawavezen12 aa79701
chore
alisawavezen12 ecca00d
chore
alisawavezen12 ef64cf1
Align release validation with retention policy
alisawavezen12 15817a5
Isolate release validation failures by project
alisawavezen12 e2760e8
Clear regression when resolving event again
alisawavezen12 a82acd3
Track latest event occurrence before validation
alisawavezen12 59ef3e4
tests fix
alisawavezen12 34e2cd7
Merge branch 'master' into feat/release-validator-worker
alisawavezen12 8b4e8d0
chore
alisawavezen12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Db } from 'mongodb'; | ||
| import type { ReleaseDBScheme } from '@hawk.so/types'; | ||
|
|
||
| type ReleaseRecordPart = Pick<ReleaseDBScheme, '_id' | 'projectId' | 'release'>; | ||
|
|
||
| /** | ||
| * Mark an event as regressed if it reoccurs in the resolved or a newer release. | ||
| * | ||
| * The update is atomic: only the first repetition after resolution sets the | ||
| * regression release, and later repetitions do not overwrite it. | ||
| * | ||
| * @param db - events database connection | ||
| * @param projectId - project identifier | ||
| * @param groupHash - original event group hash | ||
| * @param release - release in which the event occurred again | ||
| * @param resolvedInRelease - release in which the event was resolved | ||
| */ | ||
| export async function checkAndMarkRegression( | ||
| db: Db, | ||
| projectId: string, | ||
| groupHash: string, | ||
| release: string, | ||
| resolvedInRelease: string | ||
| ): Promise<void> { | ||
| const releases = await db.collection<ReleaseRecordPart>('releases').find({ | ||
| projectId, | ||
| release: { | ||
| $in: [resolvedInRelease, release], | ||
| }, | ||
| }) | ||
| .toArray(); | ||
| const resolvedRelease = releases.find(item => item.release === resolvedInRelease); | ||
| const repetitionRelease = releases.find(item => item.release === release); | ||
|
|
||
| if (!resolvedRelease || !repetitionRelease) { | ||
| return; | ||
| } | ||
|
|
||
| const resolvedReleaseId = resolvedRelease._id.toHexString(); | ||
| const isResolvedOrNewerRelease = repetitionRelease._id.toHexString() >= resolvedReleaseId; | ||
|
|
||
| if (!isResolvedOrNewerRelease) { | ||
| return; | ||
| } | ||
|
|
||
| await db.collection(`events:${projectId}`).updateOne({ | ||
| groupHash, | ||
| resolvedInRelease, | ||
| regressionInRelease: { $exists: false }, | ||
| }, { | ||
| $set: { | ||
| regressionInRelease: release, | ||
| }, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Release Validator Worker | ||
|
|
||
| Checks releases after a 24-hour observation period and marks original events that no longer occur as resolved. | ||
|
|
||
| The worker processes releases from oldest to newest, stores the first release without an event in `resolvedInRelease`, and marks successfully processed releases with `fixChecked: true`. | ||
|
|
||
| The worker only uses the fields required for matching releases and event groups. Records without these fields are ignored. Candidate releases must be older than 24 hours and no older than the `MAX_DAYS_NUMBER` retention period, while all available project releases are still used to compare event history. If an event's original release was archived, the original event timestamp is used as its chronological boundary. | ||
|
|
||
| Queue: `cron-tasks/release-validator` | ||
|
|
||
| Run locally: | ||
|
|
||
| ```sh | ||
| yarn run-release-validator | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| const baseConfig = require('../../jest.config'); | ||
|
|
||
| module.exports = { | ||
| ...baseConfig, | ||
| rootDir: '../..', | ||
| setupFiles: [ | ||
| '<rootDir>/jest.setup.js', | ||
| '<rootDir>/workers/release-validator/jest.setup.js', | ||
| ], | ||
| setupFilesAfterEnv: [ '<rootDir>/jest.setup.mongo-repl-set.js' ], | ||
| globalTeardown: '<rootDir>/jest.global-teardown.js', | ||
| roots: [ | ||
| '<rootDir>/workers/release-validator', | ||
| '<rootDir>/lib', | ||
| ], | ||
| testMatch: [ '<rootDir>/workers/release-validator/**/*.test.ts' ], | ||
| moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| process.env.MAX_DAYS_NUMBER = process.env.MAX_DAYS_NUMBER || '30'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "hawk-worker-release-validator", | ||
| "version": "0.0.1", | ||
| "description": "Detects events fixed by a release", | ||
| "main": "src/index.ts", | ||
| "author": "CodeX", | ||
| "license": "UNLICENSED", | ||
| "private": true, | ||
| "workerType": "cron-tasks/release-validator" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.