Skip to content

Commit

Permalink
Fix conflicts and update branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjaHorbach committed Apr 10, 2024
2 parents ff00cb2 + 468ee2f commit ea43c08
Show file tree
Hide file tree
Showing 244 changed files with 22,384 additions and 11,045 deletions.
2 changes: 1 addition & 1 deletion .github/actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
self-hosted-runner:
labels:
- ubuntu-latest-xl
- macos-12-xl
- macos-13-large
- macos-13-xlarge
- ubuntu-latest-reassure-tests
8 changes: 6 additions & 2 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12754,9 +12754,13 @@ function promiseDoWhile(condition, action) {
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
if (!actionResult) {
resolve();
return;
}
actionResult
?.then(() => promiseWhile(condition, action))
.then(() => resolve())
.then(() => promiseWhile(condition, action))
.then(resolve)
.catch(reject);
});
}
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/javascript/getGraphiteString/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: 'Get and Save graphite string'
description: 'Parse reassure output.json file and create string which can be sent to the graphite server'

inputs:
PR_NUMBER:
description: Number of merged PR
required: true
outputs:
GRAPHITE_STRING:
description: String with reassure data which can be directly sent to the graphite server
Expand Down
64 changes: 32 additions & 32 deletions .github/actions/javascript/getGraphiteString/getGraphiteString.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import fs from 'fs';

const run = () => {
// Prefix path to the graphite metric
const GRAPHITE_PATH = 'reassure';
const PR_NUMBER = core.getInput('PR_NUMBER', {required: true});

let regressionOutput;
try {
regressionOutput = JSON.parse(fs.readFileSync('.reassure/output.json', 'utf8'));
} catch (err) {
// Handle errors that occur during file reading or parsing
if (err instanceof Error) {
console.error('Error while parsing output.json:', err.message);
core.setFailed(err);
}
}
// Read the contents of the file, the file is in the JSONL format
const regressionFile = fs.readFileSync('.reassure/baseline.perf', 'utf8');

// Split file contents by newline to get individual JSON entries
const regressionEntries = regressionFile.split('\n');

const creationDate = regressionOutput.metadata.current.creationDate;
const timestampInMili = new Date(creationDate).getTime();
// Initialize string to store Graphite metrics
let graphiteString = '';

// Graphite accepts timestamp in seconds
const timestamp = Math.floor(timestampInMili / 1000);
// Iterate over each entry
regressionEntries.forEach((entry) => {
// Skip empty lines
if (entry.trim() === '') {
return;
}

// Get PR number from the github context
const prNumber = github.context.payload.pull_request?.number;
try {
const current = JSON.parse(entry);

// We need to combine all tests from the 4 buckets
const reassureTests = [...regressionOutput.meaningless, ...regressionOutput.significant, ...regressionOutput.countChanged, ...regressionOutput.added];
// Extract timestamp, Graphite accepts timestamp in seconds
const timestamp = current.metadata?.creationDate ? Math.floor(new Date(current.metadata.creationDate).getTime() / 1000) : '';

// 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('-');
if (current.name && current.meanDuration && current.meanCount && timestamp) {
const formattedName = current.name.split(' ').join('-');

const renderDurationString = `${GRAPHITE_PATH}.${formattedName}.renderDuration ${current.meanDuration} ${timestamp}`;
const renderCountString = `${GRAPHITE_PATH}.${formattedName}.renderCount ${current.meanCount} ${timestamp}`;
const renderPRNumberString = `${GRAPHITE_PATH}.${formattedName}.prNumber ${prNumber} ${timestamp}`;
const renderDurationString = `${GRAPHITE_PATH}.${formattedName}.renderDuration ${current.meanDuration} ${timestamp}`;
const renderCountString = `${GRAPHITE_PATH}.${formattedName}.renderCount ${current.meanCount} ${timestamp}`;
const renderPRNumberString = `${GRAPHITE_PATH}.${formattedName}.prNumber ${PR_NUMBER} ${timestamp}`;

return `${renderDurationString}\n${renderCountString}\n${renderPRNumberString}`;
})
.join('\n');
// Concatenate Graphite strings
graphiteString += `${renderDurationString}\n${renderCountString}\n${renderPRNumberString}\n`;
}
} catch (e) {
const error = new Error('Error parsing baseline.perf JSON file');
console.error(error.message);
core.setFailed(error);
}
});

// Set generated graphite string to the github variable
core.setOutput('GRAPHITE_STRING', graphiteString);
Expand Down
Loading

0 comments on commit ea43c08

Please sign in to comment.