Skip to content

Commit

Permalink
Merge pull request #36480 from callstack-internal/feature/29274/dashb…
Browse files Browse the repository at this point in the history
…oard-feed-data

[Dashboard] - github action to feed graphite with reassure data
  • Loading branch information
mountiny authored Mar 4, 2024
2 parents af8ef4c + 158effd commit afb4a51
Show file tree
Hide file tree
Showing 6 changed files with 9,830 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ self-hosted-runner:
- ubuntu-latest-xl
- macos-12-xl
- macos-13-xlarge
- ubuntu-latest-reassure-tests
8 changes: 8 additions & 0 deletions .github/actions/javascript/getGraphiteString/action.yml
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 .github/actions/javascript/getGraphiteString/getGraphiteString.js
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 "-"
const formattedName = current.name.split(' ').join('-');

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;
Loading

0 comments on commit afb4a51

Please sign in to comment.