2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-12 10:05:39 +00:00

Development improvements (#3413)

* rename .env to make sure it is not loaded by default

* make sure migrations are run before import

* Add more messaget to setup_test

* add comments to setup-dev

* Add flag to setup-dev for setting up test data

* add flag to setup-test to also run development setup

* extend contributing with the flags

* change flag to tests

* Add option helptexts

* A nicer starter

* add 3 liner

* Revert "rename .env to make sure it is not loaded by default"

This reverts commit 95fa0bbc53.
This commit is contained in:
Matthias Mair
2022-07-29 06:58:54 +02:00
committed by GitHub
parent 4d5e267753
commit e461a2c1ef
2 changed files with 44 additions and 5 deletions

View File

@ -110,8 +110,8 @@ def install(c):
c.run('pip3 install --no-cache-dir --disable-pip-version-check -U -r requirements.txt')
@task
def setup_dev(c):
@task(help={'tests': 'Set up test dataset at the end'})
def setup_dev(c, tests=False):
"""Sets up everything needed for the dev enviroment."""
print("Installing required python packages from 'requirements-dev.txt'")
@ -119,10 +119,16 @@ def setup_dev(c):
c.run('pip3 install -U -r requirements-dev.txt')
# Install pre-commit hook
print("Installing pre-commit for checks before git commits...")
c.run('pre-commit install')
# Update all the hooks
c.run('pre-commit autoupdate')
print("pre-commit set up is done...")
# Set up test-data if flag is set
if tests:
setup_test(c)
# Setup / maintenance tasks
@ -512,17 +518,31 @@ def test(c, database=None):
manage(c, 'test', pty=True)
@task(pre=[update])
def setup_test(c):
@task(pre=[update], help={'dev': 'Set up development enviroment at the end'})
def setup_test(c, dev=False):
"""Setup a testing enviroment."""
# Remove old data directory
print("Removing old data ...")
c.run('rm inventree-data -r')
# Get test data
print("Starting to clone demo dataset ...")
c.run('git clone https://github.com/inventree/demo-dataset inventree-data')
print("========================================")
# Make sure migrations are done - might have just deleted sqlite database
print("Running migrations ...")
migrate(c)
# Load data
print("Loading data ...")
import_records(c, filename='inventree-data/inventree_data.json', clear=True)
print("Done setting up test enviroment...")
print("========================================")
# Set up development setup if flag is set
if dev:
setup_dev(c)
@task