diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..45106fc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + directories: # Job that list subdirectories + runs-on: ubuntu-latest + outputs: + dir: ${{ steps.set-dirs.outputs.dir }} # generate output name dir by using inner step output + steps: + - uses: actions/checkout@v2 + - id: set-dirs # Give it an id to handle to get step outputs in the outputs key above + run: echo "::set-output name=dir::$(ls -d */ | jq -R -s -c 'split("\n")[:-1]')" + # Define step output named dir base on ls command transformed to JSON thanks to jq + loop: + runs-on: ubuntu-latest + needs: [directories] # Depends on previous job + strategy: + matrix: + dir: ${{fromJson(needs.directories.outputs.dir)}} # List matrix strategy from directories dynamically + steps: + - uses: actions/checkout@v2 + # only install and run tests if they exist on folder + - name: Build and run Jest tests + run: cd ${{matrix.dir}} && if ls ./src/*spec* &>/dev/null ; then npm i && npm run test; else echo "No Jest tests found. Skipping..." ; fi + # TODO: Make python tests work, for now they break because is not possible to mock Web3 + - name: Build and run PyTest tests + run: cd ${{matrix.dir}} && if ls ./src/*test* &>/dev/null ; then echo "Tests without secret not supported yet, run locally -> npm i && npm run test"; else echo "No PyTest tests found. Skipping..." ; fi diff --git a/README.md b/README.md index efaec74..cca28fc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Forta Agent Examples +[![build](https://github.com/forta-protocol/forta-agent-examples/actions/workflows/build.yml/badge.svg)](https://github.com/forta-protocol/forta-agent-examples/actions/workflows/build.yml) + These examples demonstrate the possible use cases of Forta Agents with little to no configuration. To run these examples, you'll need to: diff --git a/minimum-balance-py/src/agent.py b/minimum-balance-py/src/agent.py index 59b7708..c1db405 100644 --- a/minimum-balance-py/src/agent.py +++ b/minimum-balance-py/src/agent.py @@ -33,6 +33,5 @@ def handle_block(block_event): w3 = get_web3_provider() real_handle_block = provide_handle_block(w3) - def handle_block(block_event): - return real_handle_block(block_event) + return real_handle_block(block_event) \ No newline at end of file