Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 18 additions & 16 deletions .circleci/build/manual-build-validate.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
const whitelist = {
'linux': {
'appimage': 1,
linux: {
appimage: 1,
'appimage:x64': 1,
'deb': 1,
deb: 1,
'deb:x64': 1,
'rpm': 1,
rpm: 1,
'rpm:x64': 1,
'snap': 1,
snap: 1,
'snap:x64': 1,
},
'mac': {
'dmg': 1,
mac: {
dmg: 1,
'dmg:x64': 1,
'dmg:arm64': 1,
},
'windows': {
'nsis': 1,
windows: {
nsis: 1,
'nsis:x64': 1,
},
'docker': {
'all': 1,
}
docker: {
all: 1,
},
};

(() => {
const os = process.argv[2];
const targets = process.argv[3]?.split(" ") || [];
const targets = process.argv[3]?.split(' ') || [];

if (targets.length) {
targets.forEach((target) => {
if (!whitelist[os]?.[target]) {
throw new Error(`Target ${target} for ${os} is not allowed. \nAllowed targets: ${Object.keys(whitelist[os] || {}).join(',')}`);
throw new Error(
`Target ${target} for ${os} is not allowed. \nAllowed targets: ${Object.keys(whitelist[os] || {}).join(',')}`,
);
}
})
});
}
})()
})();
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
steps:
- checkout


workflows:
# Placeholder workflow
placeholder:
Expand Down
36 changes: 20 additions & 16 deletions .circleci/deps-audit-report.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const fs = require('fs');
const { exec } = require("child_process");
const { exec } = require('child_process');

const FILENAME = process.env.FILENAME;
const DEPS = process.env.DEPS || '';
const file = `${FILENAME}`;
const outputFile = `slack.${FILENAME}`;

function generateSlackMessage (summary) {
function generateSlackMessage(summary) {
const message = {
text: `DEPS AUDIT: *${DEPS}* result (Branch: *${process.env.CIRCLE_BRANCH}*)` +
text:
`DEPS AUDIT: *${DEPS}* result (Branch: *${process.env.CIRCLE_BRANCH}*)` +
`\nScanned ${summary.totalDependencies} dependencies` +
`\n<https://app.circleci.com/pipelines/workflows/${process.env.CIRCLE_WORKFLOW_ID}|View on CircleCI>`,
attachments: [],
Expand Down Expand Up @@ -50,12 +51,10 @@ function generateSlackMessage (summary) {
});
}
} else {
message.attachments.push(
{
title: 'No vulnerabilities found',
color: 'good'
}
);
message.attachments.push({
title: 'No vulnerabilities found',
color: 'good',
});
}

return message;
Expand All @@ -68,16 +67,21 @@ async function main() {
return reject(error);
}
resolve(stdout);
})
})
});
});

const { data: summary } = JSON.parse(`${lastAuditLine}`);
const vulnerabilities = summary?.vulnerabilities || {};
summary.totalVulnerabilities = Object.values(vulnerabilities).reduce((totalVulnerabilities, val) => totalVulnerabilities + val)
fs.writeFileSync(outputFile, JSON.stringify({
channel: process.env.SLACK_AUDIT_REPORT_CHANNEL,
...generateSlackMessage(summary),
}));
summary.totalVulnerabilities = Object.values(vulnerabilities).reduce(
(totalVulnerabilities, val) => totalVulnerabilities + val,
);
fs.writeFileSync(
outputFile,
JSON.stringify({
channel: process.env.SLACK_AUDIT_REPORT_CHANNEL,
...generateSlackMessage(summary),
}),
);
}

main();
74 changes: 49 additions & 25 deletions .circleci/deps-licenses-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const summaryFilePath = `./${licenseFolderName}/summary.csv`;
const allData = [];
let csvFiles = [];


// Main function
async function main() {
const folderPath = './';
Expand All @@ -29,8 +28,8 @@ async function main() {
try {
await Promise.all(packageJsons.map(runLicenseCheck));
console.log('All csv files was generated');
await generateSummary()
await sendLicensesToGoogleSheet()
await generateSummary();
await sendLicensesToGoogleSheet();
} catch (error) {
console.error('An error occurred:', error);
process.exit(1);
Expand All @@ -43,7 +42,13 @@ main();
function findPackageJsonFiles(folderPath) {
const packageJsonPaths = [];
const packageJsonName = 'package.json';
const excludeFolders = ['dist', 'node_modules', 'static', 'electron', 'redisgraph'];
const excludeFolders = [
'dist',
'node_modules',
'static',
'electron',
'redisgraph',
];

// Recursive function to search for package.json files
function searchForPackageJson(currentPath) {
Expand All @@ -56,7 +61,9 @@ function findPackageJsonFiles(folderPath) {
if (stats.isDirectory() && !excludeFolders.includes(file)) {
searchForPackageJson(filePath);
} else if (file === packageJsonName) {
packageJsonPaths.push(`./${filePath.slice(0, -packageJsonName.length - 1)}`);
packageJsonPaths.push(
`./${filePath.slice(0, -packageJsonName.length - 1)}`,
);
}
}
}
Expand All @@ -72,31 +79,36 @@ async function runLicenseCheck(path) {
const COMMANDS = [
`license-checker --start ${path} --csv --out ./${licenseFolderName}/${name}_prod.csv --production`,
`license-checker --start ${path} --csv --out ./${licenseFolderName}/${name}_dev.csv --development`,
]

return await Promise.all(COMMANDS.map((command) =>
new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Failed command: ${command}, error:`, stderr);
reject(error);
}
resolve();
});
})
));
];

return await Promise.all(
COMMANDS.map(
(command) =>
new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Failed command: ${command}, error:`, stderr);
reject(error);
}
resolve();
});
}),
),
);
}

async function sendLicensesToGoogleSheet() {
try {
const serviceAccountKey = JSON.parse(fs.readFileSync('./gasKey.json', 'utf-8'));
const serviceAccountKey = JSON.parse(
fs.readFileSync('./gasKey.json', 'utf-8'),
);

// Set up JWT client
const jwtClient = new google.auth.JWT(
serviceAccountKey.client_email,
null,
serviceAccountKey.private_key,
['https://www.googleapis.com/auth/spreadsheets']
['https://www.googleapis.com/auth/spreadsheets'],
);

const sheets = google.sheets('v4');
Expand All @@ -121,7 +133,9 @@ async function sendLicensesToGoogleSheet() {
spreadsheetId,
});

const sheet = response.data.sheets.find((sheet) => sheet.properties.title === sheetName);
const sheet = response.data.sheets.find(
(sheet) => sheet.properties.title === sheetName,
);
if (sheet) {
// Clear contents of the sheet starting from cell A2
await sheets.spreadsheets.values.clear({
Expand All @@ -134,11 +148,18 @@ async function sendLicensesToGoogleSheet() {
await sheets.spreadsheets.batchUpdate({
auth: jwtClient,
spreadsheetId,
resource: set({}, 'requests[0].addSheet.properties.title', sheetName),
resource: set(
{},
'requests[0].addSheet.properties.title',
sheetName,
),
});
}
} catch (error) {
console.error(`Error checking/creating sheet for ${sheetName}:`, error);
console.error(
`Error checking/creating sheet for ${sheetName}:`,
error,
);
}

try {
Expand All @@ -162,7 +183,7 @@ async function sendLicensesToGoogleSheet() {
console.error(`Error inserting data for ${sheetName}:`, err);
}
});
});
});
} catch (error) {
console.error('Error loading service account key:', error);
}
Expand Down Expand Up @@ -235,7 +256,10 @@ const stringifyPromise = (data) => {
};

async function generateSummary() {
csvFiles = fs.readdirSync(licenseFolderName).filter(file => file.endsWith('.csv')).sort();
csvFiles = fs
.readdirSync(licenseFolderName)
.filter((file) => file.endsWith('.csv'))
.sort();

for (const file of csvFiles) {
try {
Expand Down
22 changes: 13 additions & 9 deletions .circleci/e2e-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ const fs = require('fs');
let parallelNodeInfo = '';
const totalNodes = parseInt(process.env.CIRCLE_NODE_TOTAL, 10);
if (totalNodes > 1) {
parallelNodeInfo = ` (node: ${parseInt(process.env.CIRCLE_NODE_INDEX, 10) + 1}/${totalNodes})`
parallelNodeInfo = ` (node: ${parseInt(process.env.CIRCLE_NODE_INDEX, 10) + 1}/${totalNodes})`;
}

const file = 'tests/e2e/results/e2e.results.json'
const appBuildType = process.env.APP_BUILD_TYPE || 'Web'
const file = 'tests/e2e/results/e2e.results.json';
const appBuildType = process.env.APP_BUILD_TYPE || 'Web';
const results = {
message: {
text: `*E2ETest - ${appBuildType}${parallelNodeInfo}* (Branch: *${process.env.CIRCLE_BRANCH}*)` +
text:
`*E2ETest - ${appBuildType}${parallelNodeInfo}* (Branch: *${process.env.CIRCLE_BRANCH}*)` +
`\n<https://app.circleci.com/pipelines/workflows/${process.env.CIRCLE_WORKFLOW_ID}|View on CircleCI>`,
attachments: [],
},
};

const result = JSON.parse(fs.readFileSync(file, 'utf-8'))
const result = JSON.parse(fs.readFileSync(file, 'utf-8'));
const testRunResult = {
color: '#36a64f',
title: `Started at: *${result.startTime}`,
Expand Down Expand Up @@ -51,7 +52,10 @@ if (results.passed === false) {
results.message.text = '<!here> ' + results.message.text;
}

fs.writeFileSync('e2e.report.json', JSON.stringify({
channel: process.env.SLACK_TEST_REPORT_CHANNEL,
...results.message,
}));
fs.writeFileSync(
'e2e.report.json',
JSON.stringify({
channel: process.env.SLACK_TEST_REPORT_CHANNEL,
...results.message,
}),
);
18 changes: 11 additions & 7 deletions .circleci/itest-results.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const fs = require('fs');

const file = 'redisinsight/api/test/test-runs/coverage/test-run-result.json'
const file = 'redisinsight/api/test/test-runs/coverage/test-run-result.json';

const results = {
message: {
text: `*ITest - ${process.env.ITEST_NAME}* (Branch: *${process.env.CIRCLE_BRANCH}*)` +
text:
`*ITest - ${process.env.ITEST_NAME}* (Branch: *${process.env.CIRCLE_BRANCH}*)` +
`\n<https://app.circleci.com/pipelines/workflows/${process.env.CIRCLE_WORKFLOW_ID}|View on CircleCI>`,
attachments: [],
},
};

const result = JSON.parse(fs.readFileSync(file, 'utf-8'))
const result = JSON.parse(fs.readFileSync(file, 'utf-8'));
const testRunResult = {
color: '#36a64f',
title: `Started at: ${result.stats.start}`,
Expand Down Expand Up @@ -45,7 +46,10 @@ if (results.passed === false) {
results.message.text = '<!here> ' + results.message.text;
}

fs.writeFileSync('itests.report.json', JSON.stringify({
channel: process.env.SLACK_TEST_REPORT_CHANNEL,
...results.message,
}));
fs.writeFileSync(
'itests.report.json',
JSON.stringify({
channel: process.env.SLACK_TEST_REPORT_CHANNEL,
...results.message,
}),
);
Loading