mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Generate ER diagrams in :nom:generate_golden_file (#867)
Generate entity relationship diagrams during the same step in which we generate the golden schema.
This commit is contained in:
parent
1c630cf0a9
commit
c1745e4b01
2 changed files with 16 additions and 7 deletions
|
@ -300,9 +300,15 @@ def do_pseudo_task(task: str) -> None:
|
|||
f'{root}/db/src/main/resources/sql/schema/'
|
||||
'nomulus.golden.sql')
|
||||
|
||||
if subprocess.call([f'{root}/gradlew', ':db:test']):
|
||||
print('\033[31mERROR:\033[0m Golden file test failed after '
|
||||
'copying schema. Please check your flyway files.')
|
||||
# Rerun :db:test and regenerate the ER diagram (at "warning" log
|
||||
# level so it doesn't generate pages of messaging)
|
||||
if subprocess.call([f'{root}/gradlew', ':db:test', 'devTool',
|
||||
'--args=-e localhost --log_level=WARNING '
|
||||
'generate_sql_er_diagram -o '
|
||||
f'{root}/db/src/main/resources/sql/er_diagram']):
|
||||
print('\033[31mERROR:\033[0m Golden file test or ER diagram '
|
||||
'generation failed after copying schema. Please check your '
|
||||
'flyway files.')
|
||||
raise Abort()
|
||||
else:
|
||||
print(f'\033[31mERROR:\033[0m Unknown task {task}')
|
||||
|
@ -377,6 +383,7 @@ def main(args) -> int:
|
|||
|
||||
# See if there are any special ":nom:" pseudo-tasks specified.
|
||||
got_non_pseudo_tasks = False
|
||||
got_pseudo_tasks = False
|
||||
for arg in args.non_flag_args[1:]:
|
||||
if arg.startswith(':nom:'):
|
||||
if got_non_pseudo_tasks:
|
||||
|
@ -388,13 +395,14 @@ def main(args) -> int:
|
|||
'specified prior to all actual gradle tasks. Aborting.')
|
||||
return 1
|
||||
do_pseudo_task(arg)
|
||||
got_pseudo_tasks = True
|
||||
else:
|
||||
got_non_pseudo_tasks = True
|
||||
non_flag_args = [
|
||||
arg for arg in args.non_flag_args[1:] if not arg.startswith(':nom:')]
|
||||
|
||||
if not non_flag_args:
|
||||
if not got_non_pseudo_tasks:
|
||||
if not got_pseudo_tasks:
|
||||
print('\033[33mWARNING:\033[0m No tasks specified. Not '
|
||||
'doing anything')
|
||||
return 0
|
||||
|
|
|
@ -113,7 +113,10 @@ class MyTest(unittest.TestCase):
|
|||
nom_build.main(['nom_build', ':nom:generate_golden_file'])
|
||||
self.call_mock.assert_has_calls([
|
||||
mock.call([GRADLEW, ':db:test']),
|
||||
mock.call([GRADLEW, ':db:test'])
|
||||
mock.call([GRADLEW, ':db:test', 'devTool',
|
||||
'--args=-e localhost --log_level=WARNING '
|
||||
'generate_sql_er_diagram -o '
|
||||
'/tmp/rootdir/db/src/main/resources/sql/er_diagram'])
|
||||
])
|
||||
|
||||
def test_generate_golden_file_nofail(self):
|
||||
|
@ -122,5 +125,3 @@ class MyTest(unittest.TestCase):
|
|||
self.call_mock.assert_has_calls([mock.call([GRADLEW, ':db:test'])])
|
||||
|
||||
unittest.main()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue