Repository navigation
[NoQA] [Dashboard] - github action to feed graphite with reassure data #36480
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
Merged
mountiny
merged 19 commits into
Expensify:main
from
callstack-internal:feature/29274/dashboard-feed-data
Mar 4, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
af6920a
feat: add gh action to send graphite reassure data
rinej 292eedc
feat: add reassure output parser to graphite string
rinej 81b252a
format: fix lint and prettier
rinej 810d3ab
chore: rebuild gh actions
rinej 32ed6d6
chore: build gh actions
rinej 738defb
fix: add typing for outputs
rinej 14de88f
fix: fix spelling
rinej c831a60
feat: add error handling for parsing json
rinej afc2e58
chore: rebuild actions
rinej e1d5297
chore: fix some comments
rinej a7985c7
Merge branch 'main' into feature/29274/dashboard-feed-data
rinej 45827da
Merge branch 'main' into feature/29274/dashboard-feed-data
rinej 438594d
chore: rebuild gh actions, run prettier
rinej 2ebcd6b
chore: change the action runs-on
rinej 8de9aab
chore: add ubuntu-latest-reassure-tests to the action lint
rinej 7e26633
feat: add env variables, adjust graphite path
rinej 7c17b52
Merge branch 'main' into feature/29274/dashboard-feed-data
rinej e59673b
Merge branch 'main' into feature/29274/dashboard-feed-data
rinej 158effd
chore: rebuild gh actions
rinej 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ self-hosted-runner: | |
| - ubuntu-latest-xl | ||
| - macos-12-xl | ||
| - macos-13-xlarge | ||
| - ubuntu-latest-reassure-tests | ||
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,8 @@ | ||
| name: 'Get and Save graphite string' | ||
| description: 'Parse reassure output.json file and create string which can be sent to the graphite server' | ||
| outputs: | ||
| GRAPHITE_STRING: | ||
| description: String with reassure data which can be directly sent to the graphite server | ||
| runs: | ||
| using: 'node20' | ||
| main: './index.js' |
53 changes: 53 additions & 0 deletions
53
.github/actions/javascript/getGraphiteString/getGraphiteString.js
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,53 @@ | ||||||||
| const core = require('@actions/core'); | ||||||||
| const github = require('@actions/github'); | ||||||||
| const fs = require('fs'); | ||||||||
|
|
||||||||
| const run = () => { | ||||||||
| // Prefix path to the graphite metric | ||||||||
| const GRAPHITE_PATH = 'reassure'; | ||||||||
|
|
||||||||
| let regressionOutput; | ||||||||
| try { | ||||||||
| regressionOutput = JSON.parse(fs.readFileSync('.reassure/output.json', 'utf8')); | ||||||||
| } catch (err) { | ||||||||
| // Handle errors that occur during file reading or parsing | ||||||||
| console.error('Error while parsing output.json:', err.message); | ||||||||
| core.setFailed(err); | ||||||||
| } | ||||||||
|
|
||||||||
| const creationDate = regressionOutput.metadata.current.creationDate; | ||||||||
| const timestampInMili = new Date(creationDate).getTime(); | ||||||||
|
|
||||||||
| // Graphite accepts timestamp in seconds | ||||||||
| const timestamp = Math.floor(timestampInMili / 1000); | ||||||||
|
|
||||||||
| // Get PR number from the github context | ||||||||
| const prNumber = github.context.payload.pull_request.number; | ||||||||
|
|
||||||||
| // We need to combine all tests from the 4 buckets | ||||||||
| const reassureTests = [...regressionOutput.meaningless, ...regressionOutput.significant, ...regressionOutput.countChanged, ...regressionOutput.added]; | ||||||||
|
|
||||||||
| // Map through every test and create string for meanDuration and meanCount | ||||||||
| // eslint-disable-next-line rulesdir/prefer-underscore-method | ||||||||
| const graphiteString = reassureTests | ||||||||
| .map((test) => { | ||||||||
| const current = test.current; | ||||||||
| // Graphite doesn't accept metrics name with space, we replace spaces with "-" | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| const formattedName = current.name.split(' ').join('-'); | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| const renderDurationString = `${GRAPHITE_PATH}.PR-${prNumber}.${formattedName}.renderDuration ${current.meanDuration} ${timestamp}`; | ||||||||
| const renderCountString = `${GRAPHITE_PATH}.PR-${prNumber}.${formattedName}.renderCount ${current.meanCount} ${timestamp}`; | ||||||||
|
|
||||||||
| return `${renderDurationString}\n${renderCountString}`; | ||||||||
| }) | ||||||||
| .join('\n'); | ||||||||
|
|
||||||||
| // Set generated graphite string to the github variable | ||||||||
| core.setOutput('GRAPHITE_STRING', graphiteString); | ||||||||
| }; | ||||||||
|
|
||||||||
| if (require.main === module) { | ||||||||
| run(); | ||||||||
| } | ||||||||
|
|
||||||||
| module.exports = run; | ||||||||
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.