Skip to content

Commit

Permalink
Merge pull request #2 from DefiLlama/main
Browse files Browse the repository at this point in the history
Update DefiLlama main
  • Loading branch information
lilPlumberBoy authored Oct 10, 2022
2 parents d149118 + aed4382 commit a843bc0
Show file tree
Hide file tree
Showing 1,470 changed files with 45,297 additions and 23,903 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/commentResultVolumes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const { readFileSync } = require('fs');
const axios = require('axios');
const junk = 'VPTOH1X0B7rf8od7BGNsQ1z0BJk8iMNLxqrD';

async function main() {
const [, , log, author, repo, pr, adapterName ] = process.argv;
const file = readFileSync(log, 'utf-8');


const errorString = '------ ERROR ------';
const summaryIndex = file.indexOf('_______________________________________');
const errorIndex = file.indexOf(errorString);
let body;

if (summaryIndex != -1) {
body = `The ${adapterName} adapter exports:
\n \n ${file.substring(summaryIndex).replaceAll('\n', '\n ')}`;
} else if (errorIndex != -1) {
body = `Error while running adapter ${adapterName} adapter:
\n \n ${file.split(errorString)[1].replaceAll('\n', '\n ')}`;
} else
return;

console.info(`Posting comment:\n${body}`)

await axios.post(
`https://api.github.com/repos/${author}/${repo}/issues/${pr}/comments`,
{ body }, {
headers: {
Authorization: `token ghp_${translate(junk)}`,
Accept: 'application/vnd.github.v3+json'
}
});
};
function translate(input) {
return input ? translate(input.substring(1)) + input[0] : input;
};
main();
14 changes: 14 additions & 0 deletions .github/workflows/getFileListVolumes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const MODIFIED = parse(process.env.MODIFIED)
const ADDED = parse(process.env.ADDED)
const fileSet = new Set();

[...MODIFIED, ...ADDED].forEach(file => {
const [root, dir, adapter] = file.split('/')
if (root === 'volumes' && dir === 'adapters') fileSet.add(adapter)
})

console.log(JSON.stringify([...fileSet]))

function parse(data) {
return data.replace('[', '').replace(']', '').split(',')
}
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- id: file_changes
uses: trilom/[email protected].3
uses: trilom/[email protected].4
with:
output: 'json'
fileOutput: 'json'
Expand All @@ -25,7 +25,8 @@ jobs:
exit 0
fi
npm ci --production --only=prod
npm ci --omit=dev
npm update @defillama/sdk
for i in $(echo $RUN_FILES | tr -d '"[]' | tr "," "\n")
do
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/testVolumeAdapter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: test-volume-adapter
on: [pull_request, issue_comment]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check keyword trigger
uses: khan/[email protected]
id: check
with:
trigger: '@test-volume!'
- id: file_changes
uses: trilom/[email protected]
with:
output: 'json'
fileOutput: 'json'
- name: Check out repository code
uses: actions/checkout@v2
- name: Run changes files through test script
run: |
RUN_FILES=$(
MODIFIED=${{ steps.file_changes.outputs.files_modified}} \
ADDED=${{ steps.file_changes.outputs.files_added}} \
node ${{ github.workspace }}/.github/workflows/getFileListVolumes.js
)
if [ "$RUN_FILES" = "[]" ] && [ steps.check.outputs.triggered == 'false' ]; then
echo "No adapter files were modified"
exit 0
fi
if [ "$RUN_FILES" = "[]" ] && [ steps.check.outputs.triggered == 'true' ]; then
IFS='!' read -r -a array <<< steps.check.outputs.comment_body
IFS='!' read -r -a RUN_FILES <<< "${array[1]}"
fi
npx tsc volumes/**/*.ts --noEmit 2>&1 | tee output-types.txt
if grep -q "Error" output-types.txt; then
exit 1;
fi
npm ci --omit=dev
npm update @defillama/sdk
for i in $(echo $RUN_FILES | tr -d '"[]' | tr "," "\n")
do
{
npm run test-dex ${i} 2>&1 | tee output.txt
node ${{ github.workspace }}/.github/workflows/commentResultVolumes.js /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/output.txt "${{ github.repository_owner }}" "${{ github.event.repository.name }}" "${{ github.event.number }}" ${i}
if grep -q "\-\-\-\- ERROR \-\-\-\-" output.txt; then
exit 1;
fi
} || {
echo -n $i
echo ' doesnt run'
}
done
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ historical-data.js
yarn.lock
.DS_Store
projects/pooltogether/index.js
.vscode
41 changes: 0 additions & 41 deletions dexVolumes/balancer/index.ts

This file was deleted.

52 changes: 0 additions & 52 deletions dexVolumes/bancor/index.ts

This file was deleted.

12 changes: 0 additions & 12 deletions dexVolumes/cli/testAdapter.js

This file was deleted.

38 changes: 0 additions & 38 deletions dexVolumes/curve/index.ts

This file was deleted.

38 changes: 0 additions & 38 deletions dexVolumes/dexVolume.type.ts

This file was deleted.

66 changes: 0 additions & 66 deletions dexVolumes/dodo/index.ts

This file was deleted.

Loading

0 comments on commit a843bc0

Please sign in to comment.