@@ -890,6 +890,7 @@ def full(ctx, config):
890890@click .pass_context
891891def dev (ctx , config ):
892892 """Build the wheels, images, and restart the services"""
893+ ctx .invoke (test )
893894 ctx .invoke (wheel )
894895 ctx .invoke (image )
895896 ctx .invoke (restart )
@@ -903,12 +904,51 @@ def dev(ctx, config):
903904@click .pass_context
904905def sync (ctx , config ):
905906 """Build the wheels, images, check the database, and restart the services"""
907+ ctx .invoke (test )
906908 ctx .invoke (wheel )
907909 ctx .invoke (image )
908910 ctx .invoke (checkdb )
909911 ctx .invoke (restart )
910912
911913
914+ @cli .command ()
915+ @pass_config
916+ def test (config ):
917+ """Run format checks and tests"""
918+ checks = [
919+ ["black" , "--check" , "--config" , "pyproject.toml" , "bases" ],
920+ ["black" , "--check" , "--config" , "pyproject.toml" , "components" ],
921+ ]
922+
923+ for command_list in checks :
924+ console .print (f"Running { ' ' .join (command_list )} ..." , style = "bold" )
925+ ret = subprocess .run (command_list , capture_output = True )
926+ if ret .returncode != 0 :
927+ console .print (
928+ f"Command failed: { ' ' .join (command_list )} " ,
929+ style = "bold red" ,
930+ )
931+ if ret .stdout :
932+ console .print (ret .stdout .decode (stdout_err_encoding ))
933+ if ret .stderr :
934+ console .print (ret .stderr .decode (stdout_err_encoding ))
935+ exit (1 )
936+
937+ console .print ("Running pytest in test with SERVER_CONFIG=test..." , style = "bold" )
938+ test_env = os .environ .copy ()
939+ test_env ["SERVER_CONFIG" ] = "test"
940+ ret = subprocess .run (["pytest" ], cwd = "test" , env = test_env , capture_output = True )
941+ if ret .returncode != 0 :
942+ console .print ("Pytest failed" , style = "bold red" )
943+ if ret .stdout :
944+ console .print (ret .stdout .decode (stdout_err_encoding ))
945+ if ret .stderr :
946+ console .print (ret .stderr .decode (stdout_err_encoding ))
947+ exit (1 )
948+
949+ console .print ("All checks passed" , style = "green" )
950+
951+
912952# Bake
913953# build multi-architecture images and push them to the registry
914954@cli .command ()
@@ -929,6 +969,8 @@ def bake(ctx, config, version):
929969 with open (".last_version" , "w" ) as f :
930970 f .write (version )
931971 # we need to build the wheels first
972+
973+ ctx .invoke (test )
932974 ctx .invoke (wheel )
933975 for service in config .ym ["services" ]:
934976 if service == "nginx_dstart_dev" :
0 commit comments