-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented githubactions to test firehose and substreams endpoints (#23
) * Implemented githubactions to test firehose and substreams endpoints * import fix * fix import * changed github action to pull request only
- Loading branch information
Showing
4 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Run grpcurl commands on pull request | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
run-grpcurl: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.18' | ||
|
||
- name: Install grpcurl | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y curl | ||
curl -sSL https://github.com/fullstorydev/grpcurl/releases/download/v1.8.7/grpcurl_1.8.7_linux_x86_64.tar.gz | sudo tar -xz -C /usr/local/bin | ||
- name: Run grpcurl for substreams services | ||
run: node scripts/run-grpcurl-substreams.js | ||
|
||
- name: Check for grpcurl errors | ||
if: failure() | ||
run: | | ||
echo "There were grpcurl errors, blocking the pull request." | ||
exit 1 | ||
- name: Run grpcurl for firehose services | ||
run: node scripts/run-grpcurl-firehose.js | ||
|
||
- name: Check for grpcurl errors | ||
if: failure() | ||
run: | | ||
echo "There were grpcurl errors, blocking the pull request." | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const affectedChains = [ | ||
{ | ||
id: 'cosmoshub', | ||
affected_services: ['firehose'], | ||
}, | ||
]; | ||
|
||
module.exports = { affectedChains }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { exec } = require('child_process'); | ||
const { affectedChains } = require('./known-issues-chains'); | ||
const filePath = path.resolve(__dirname, '../data/chains/V2/chains.json'); | ||
const chains = JSON.parse( | ||
fs.readFileSync(filePath, 'utf8'), | ||
); | ||
|
||
function runGrpcurl(chainId, serviceName) { | ||
return new Promise((resolve, reject) => { | ||
const command = `grpcurl ${chainId}.${serviceName}.pinax.network:443 sf.${serviceName}.v2.EndpointInfo/Info`; | ||
console.log(`Executing: ${command}`); | ||
|
||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`Error: ${error.message}`); | ||
reject(new Error(`Command failed: ${command}`)); | ||
return; | ||
} | ||
if (stderr) { | ||
console.error(`Stderr: ${stderr}`); | ||
} | ||
console.log(`Response: ${stdout}`); | ||
resolve(`Success: ${command}`); | ||
}); | ||
}); | ||
} | ||
|
||
async function run() { | ||
try { | ||
for (const chain of chains) { | ||
const firehoseService = chain.supported_services.firehose; | ||
|
||
if ( | ||
affectedChains.some( | ||
(affectedChain) => | ||
affectedChain.id === chain.id && | ||
affectedChain.affected_services.includes('firehose'), | ||
) | ||
) { | ||
console.log( | ||
`${chain.id} is affected by known issues. Endpoint: ${chain.id}.firehose.pinax.network`, | ||
); | ||
return; | ||
} | ||
if ( | ||
firehoseService && | ||
firehoseService.deprecated_at === null && | ||
(firehoseService.beta_released_at || firehoseService.full_released_at) | ||
) { | ||
console.log( | ||
`Running grpcurl for substreams service on chain ${chain.id}`, | ||
); | ||
await runGrpcurl(chain.id, 'firehose'); | ||
} | ||
} | ||
console.log('All grpcurl commands executed successfully.'); | ||
} catch (error) { | ||
console.error('Error during grpcurl execution:', error.message); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { exec } = require('child_process'); | ||
const { affectedChains } = require('./known-issues-chains'); | ||
const filePath = path.resolve(__dirname, '../data/chains/V2/chains.json'); | ||
const chains = JSON.parse( | ||
fs.readFileSync(filePath, 'utf8'), | ||
); | ||
function runGrpcurl(chainId, serviceName) { | ||
return new Promise((resolve, reject) => { | ||
const command = `grpcurl ${chainId}.${serviceName}.pinax.network:443 sf.${serviceName}.rpc.v2.EndpointInfo/Info`; | ||
console.log(`Executing: ${command}`); | ||
|
||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`Error: ${error.message}`); | ||
reject(new Error(`Command failed: ${command}`)); | ||
return; | ||
} | ||
if (stderr) { | ||
console.error(`Stderr: ${stderr}`); | ||
} | ||
console.log(`Response: ${stdout}`); | ||
resolve(`Success: ${command}`); | ||
}); | ||
}); | ||
} | ||
|
||
async function run() { | ||
try { | ||
for (const chain of chains) { | ||
const substreamsService = chain.supported_services.substreams; | ||
|
||
if ( | ||
affectedChains.some( | ||
(affectedChain) => | ||
affectedChain.id === chain.id && | ||
affectedChain.affected_services.includes('substreams'), | ||
) | ||
) { | ||
console.log( | ||
`${chain.id} is affected by known issues. Endpoint: ${chain.id}.substreams.pinax.network`, | ||
); | ||
return; | ||
} | ||
|
||
if ( | ||
substreamsService && | ||
substreamsService.deprecated_at === null && | ||
(substreamsService.beta_released_at || | ||
substreamsService.full_released_at) | ||
) { | ||
console.log( | ||
`Running grpcurl for substreams service on chain ${chain.id}`, | ||
); | ||
await runGrpcurl(chain.id, 'substreams'); | ||
} | ||
} | ||
console.log('All grpcurl commands executed successfully.'); | ||
} catch (error) { | ||
console.error('Error during grpcurl execution:', error.message); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
run(); |