mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
checks update
This commit is contained in:
parent
196673877d
commit
6715717ca8
|
@ -279,8 +279,8 @@ const checkName = async (connector) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkMain () {
|
async function checkMain () {
|
||||||
const errors = []
|
|
||||||
try {
|
try {
|
||||||
|
const errors = []
|
||||||
const warnings = []
|
const warnings = []
|
||||||
const connectors = await getConnectorsList()
|
const connectors = await getConnectorsList()
|
||||||
for (let index = 0; index < connectors.length; index++) {
|
for (let index = 0; index < connectors.length; index++) {
|
||||||
|
@ -299,19 +299,19 @@ async function checkMain () {
|
||||||
}
|
}
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
console.log('\x1b[31m%s\x1b[0m', `Total errors: ${errors.length}`)
|
console.log('\x1b[31m%s\x1b[0m', `Total errors: ${errors.length}`)
|
||||||
console.log('\x1b[31m%s\x1b[0m', errors.join('\n'))
|
errors.forEach(error => console.log('\x1b[31m%s\x1b[0m', error))
|
||||||
} else {
|
} else {
|
||||||
console.log('\x1b[32m%s\x1b[0m', 'No Errors Found')
|
console.log('\x1b[32m%s\x1b[0m', 'No Errors Found')
|
||||||
}
|
}
|
||||||
if (warnings.length) {
|
if (warnings.length) {
|
||||||
console.log('\x1b[33m%s\x1b[0m', `Total warnings: ${warnings.length}`)
|
console.log('\x1b[33m%s\x1b[0m', `Total warnings: ${warnings.length}`)
|
||||||
console.log('\x1b[33m%s\x1b[0m', warnings.join('\n'))
|
warnings.forEach(warning => console.log('\x1b[33m%s\x1b[0m', warning))
|
||||||
} else {
|
} else {
|
||||||
console.log('\x1b[32m%s\x1b[0m', 'No Warnings Found')
|
console.log('\x1b[32m%s\x1b[0m', 'No Warnings Found')
|
||||||
}
|
}
|
||||||
|
if (errors.length) return Promise.reject(errors.join('\n'))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('check execution error:', error)
|
console.error('check execution error:', error)
|
||||||
}
|
}
|
||||||
if (errors.length) throw new Error(errors.join('\n'))
|
|
||||||
}
|
}
|
||||||
module.exports = checkMain;
|
module.exports = checkMain
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
const checkMain = require('./check');
|
const checkMain = require('./check')
|
||||||
|
|
||||||
module.exports = [{
|
module.exports = [{
|
||||||
name: 'Solidity check',
|
name: 'Solidity check',
|
||||||
callback: checkMain,
|
callback: async () => {
|
||||||
}];
|
try {
|
||||||
|
await checkMain()
|
||||||
|
return 'Check passed!'
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error('Check failed!')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
const cp = require('child_process');
|
const cp = require('child_process')
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch')
|
||||||
|
|
||||||
const checks = require('./checks');
|
const checks = require('./checks')
|
||||||
|
|
||||||
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
|
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
|
||||||
|
|
||||||
function getCurrentCommitSha() {
|
function getCurrentCommitSha () {
|
||||||
return cp
|
return cp
|
||||||
.execSync(`git rev-parse HEAD`)
|
.execSync('git rev-parse HEAD')
|
||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim()
|
||||||
}
|
}
|
||||||
// The SHA provied by GITHUB_SHA is the merge (PR) commit.
|
// The SHA provied by GITHUB_SHA is the merge (PR) commit.
|
||||||
// We need to get the current commit sha ourself.
|
// We need to get the current commit sha ourself.
|
||||||
const sha = getCurrentCommitSha();
|
const sha = getCurrentCommitSha()
|
||||||
|
|
||||||
async function setStatus(context, state, description) {
|
async function setStatus (context, state, description) {
|
||||||
return fetch(`https://api.github.com/repos/${owner}/${repo}/statuses/${sha}`, {
|
return fetch(`https://api.github.com/repos/${owner}/${repo}/statuses/${sha}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
state,
|
state,
|
||||||
description,
|
description,
|
||||||
context,
|
context
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
|
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json'
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
console.log(`Starting status checks for commit ${sha}`);
|
console.log(`Starting status checks for commit ${sha}`)
|
||||||
|
|
||||||
// Run in parallel
|
// Run in parallel
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
checks.map(async check => {
|
checks.map(async check => {
|
||||||
const { name, callback } = check;
|
const { name, callback } = check
|
||||||
|
|
||||||
await setStatus(name, 'pending', 'Running check..');
|
await setStatus(name, 'pending', 'Running check..')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await callback();
|
const response = await callback()
|
||||||
await setStatus(name, 'success', response);
|
await setStatus(name, 'success', response)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const message = err ? err.message : 'Something went wrong';
|
const message = err ? err.message : 'Something went wrong'
|
||||||
await setStatus(name, 'failure', message);
|
await setStatus(name, 'failure', message)
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
console.log('Finished status checks');
|
console.log('Finished status checks')
|
||||||
})();
|
})()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user