impact-graph
impact-graph copied to clipboard
Remove clearing the database in the Tests
We have a limitation in our tests that will only run on a clean set of data. We want to remove this limitation, in order to make use of testing on real data dumps from our environments instead of completely new databases.
@mohammadranjbarz Have more information about this.
@mhmdksh See this part of code https://github.com/Giveth/impact-graph/blob/b67ed85e3345dee7d7b21ea5bc12796b773aa8c4/src/server/bootstrap.ts#L97-L110
It seems you just need to set DROP_DATABASE to false in configs when running on CI so it would not drop database ( no need to change the code)
Thanks @mohammadranjbarz
I see it's hard-coded in the code of bootstrap.ts
. Do you think we should give it the flexibility to be in process.env
maybe that we can decide on when to use it on clean DB or not
So I think the only thing we should do to integrate this with the test step in the CI is this:
- name: Run tests
run: npm run test
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
XDAI_NODE_HTTP_URL: ${{ secrets.XDAI_NODE_HTTP_URL }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
INFURA_ID: ${{ secrets.INFURA_ID }}
POLYGON_SCAN_API_KEY: ${{ secrets.POLYGON_SCAN_API_KEY }}
OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
DROP_DATABASE: ${{ secrets.DROP_DATABASE }}
And add the github secret DROP_DATABASE=false
Right? Can you confirm @mohammadranjbarz ?
So I think the only thing we should do to integrate this with the test step in the CI is this:
- name: Run tests run: npm run test env: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} XDAI_NODE_HTTP_URL: ${{ secrets.XDAI_NODE_HTTP_URL }} INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} INFURA_ID: ${{ secrets.INFURA_ID }} POLYGON_SCAN_API_KEY: ${{ secrets.POLYGON_SCAN_API_KEY }} OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }} CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }} CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }} DROP_DATABASE: ${{ secrets.DROP_DATABASE }}
And add the github secret
DROP_DATABASE=false
Right? Can you confirm @mohammadranjbarz ?
Yeah exactly
Thanks @mohammadranjbarz
I've added the above steps, it seems that when testing on real database data, the tests fail from the start. Please check this:
https://github.com/Giveth/impact-graph/actions/runs/6145025837/job/16671618590
Want to bring this back to attention. Would be great to have this after moving the production deployment to impact-graph. @mhmdksh will add more details to explain the issue better.