Skip to content

Commit

Permalink
Merge branch 'main' into dsilva_addSupportalNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldoglas committed Mar 4, 2024
2 parents 2931b5e + 780e2ac commit 9904a01
Show file tree
Hide file tree
Showing 116 changed files with 10,694 additions and 1,017 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 9904a01

Please sign in to comment.