Skip to content

Commit

Permalink
Merge pull request #43 from overlookerjs/cache-reworking
Browse files Browse the repository at this point in the history
Cache reworking
  • Loading branch information
pyatyispyatil authored May 31, 2021
2 parents fd7394f + 71d7af7 commit 49e9d97
Show file tree
Hide file tree
Showing 30 changed files with 1,609 additions and 701 deletions.
17 changes: 17 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
],
"jest"
],
"plugins": [
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining"
]
}
98 changes: 98 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"devDependencies": {
"@babel/cli": "^7.6.3",
"@babel/core": "^7.6.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
"@babel/plugin-proposal-optional-chaining": "^7.14.2",
"@babel/polyfill": "^7.6.0",
"@babel/preset-env": "^7.6.3",
"@babel/preset-react": "^7.6.3",
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/config.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
cpu: 1,
network: 'WiFi'
},
threads: 2,
logger: (msg) => console.log(msg),
buildData: {
url: '/build.json',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/index.int.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const thresholds = {
}
};

jest.setTimeout(150000);
jest.setTimeout(300000);

const hasProfile = (profile) => {
expect(profile).toBeTruthy();
Expand Down
18 changes: 15 additions & 3 deletions src/aggregation/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { concatNetworks, aggregateNetwork } = require('./aggregation-network.js');
const { expandNetwork } = require('./../chunks-meta');
const { deepConcat } = require('./../objects-utils.js');
const { deepConcat, map } = require('./../objects-utils.js');
const { objDeepAggregation } = require('./aggregation-utils.js');
const { concatActions, aggregateActions } = require('./aggregation-actions.js');
const { aggregateWeighted } = require('./aggregation-weighted.js');
const { concatWithWeight } = require('./aggregation-utils.js');

const aggregateProfiles = (profiles,
const aggregateProfilesSeries = (profiles,
buildData,
mergeRequests,
aggregation = objDeepAggregation) => {
Expand Down Expand Up @@ -43,6 +43,18 @@ const aggregateProfiles = (profiles,
};
};

const aggregateProfiles = async (result, config, buildData) => (
map(
result,
(stats) => aggregateProfilesSeries(
stats,
buildData,
config.requests ? config.requests.merge : null
)
)
);

module.exports = {
aggregateProfiles
aggregateProfiles,
aggregateProfilesSeries
};
2 changes: 1 addition & 1 deletion src/checker/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const checkValue = (value, threshold) => {
const check = (comparison, thresholds) => {
const comparisonsArray = toArray(comparison);

return flat(Object.entries(thresholds) // ToDo: it should be more simple
return flat(Object.entries(thresholds)
.map(([thresholdPath, threshold]) => {
const regExp = pathPatternToRegExp(thresholdPath);
const matchedPaths = comparisonsArray.filter(([path]) => regExp.test(path));
Expand Down
4 changes: 2 additions & 2 deletions src/merge/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { aggregateProfiles } = require('./../aggregation');
const { aggregateProfilesSeries } = require('./../aggregation');
const { deepMapUntilArray } = require('./../objects-utils');
const jStat = require('jstat');

Expand All @@ -10,7 +10,7 @@ const strategies = {
const getAggregateMerger = (mergeStrategy) => (stats) => deepMapUntilArray(stats, mergeStrategy);

const merge = (data, pages, mergeStrategyName = 'mean') => (
aggregateProfiles(
aggregateProfilesSeries(
Object.entries(data)
.filter(([pageName]) => !pages || pages.includes(pageName))
.map(([, pageData]) => ({ ...pageData, screenshots: null })),
Expand Down
Loading

0 comments on commit 49e9d97

Please sign in to comment.