Skip to content

Commit

Permalink
Add ganache to docker-compose file, use it in the run-tests.sh script (
Browse files Browse the repository at this point in the history
  • Loading branch information
mmv08 authored Nov 24, 2023
1 parent 244a389 commit f05a883
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ services:
- "5432:5432"
environment:
POSTGRES_PASSWORD: postgres
ganache:
image: trufflesuite/ganache:latest
ports:
- "8545:8545"
command: --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d
29 changes: 3 additions & 26 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
#!/bin/sh
# Postgresql and ganache-cli must be running for the tests

ps aux | grep ganache-cli | grep -v grep > /dev/null
if [ $? -eq 1 ]; then
echo 'Running Ganache-Cli'
ganache-cli --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d > /dev/null &
GANACHE_PID=$!
sleep 3
fi

docker ps | grep '\->5432' > /dev/null
if [ $? -eq 1 ]; then
docker-compose up -d db
sleep 3
DATABASE_UP=1
else
DATABASE_UP=0
fi

docker-compose up -d db ganache
sleep 3

# python manage.py test --settings=config.settings.test
DJANGO_SETTINGS_MODULE=config.settings.test pytest

if [ ${GANACHE_PID:-0} -gt 1 ]; then
echo 'Killing opened Ganache-Cli'
kill $GANACHE_PID
fi

if [ $DATABASE_UP -eq 1 ]; then
docker-compose down
fi
docker-compose down

0 comments on commit f05a883

Please sign in to comment.