config.define_string_list("test") config.define_bool("bats") cfg = config.parse() CORE_TEST_LABEL = "core" CONSENT_TEST_LABEL = "consent" DASHBOARD_TEST_LABEL = "dashboard" PAY_TEST_LABEL = "pay" TEST_RESOURCES = { CORE_TEST_LABEL: "api-test", CONSENT_TEST_LABEL: "consent-test", DASHBOARD_TEST_LABEL: "dashboard-test", PAY_TEST_LABEL: "pay-test", } is_ci=("ci" in sys.argv) or cfg.get("bats", False) run_apps=not cfg.get("bats", False) # From the Tilt docs: # # > By default, Tilt will not let you develop against a remote cluster. # # The implication appears to be that if Tilt finds a configured Kubernetes setup on your system # **and** it's a remote cluster, despite the fact that we are not using any Kubernetes features or # capabilities, it will still try to connect and fail. Instead, we're going to disable this check # and continue. # # - https://docs.tilt.dev/choosing_clusters.html#remote # - https://docs.tilt.dev/api.html#api.allow_k8s_contexts allow_k8s_contexts(k8s_context()) def _buck2_dep_inputs(target): cmd = [ "buck2", "uquery", "\"inputs(deps('{}'))\"".format(target), ] file_paths = str(local(" ".join(cmd))).splitlines() return file_paths dashboard_target = "//apps/dashboard:dev" if is_ci: dashboard_target = '//apps/dashboard:dashboard' local_resource( "dashboard", labels = ["apps"], cmd = "buck2 build {}".format(dashboard_target), serve_cmd = ". .envs/dashboard.env && buck2 run {}".format(dashboard_target), serve_env = { "NEXTAUTH_URL": "http://localhost:3001", "NEXTAUTH_SECRET": "secret", "PORT": "3001", }, deps = _buck2_dep_inputs(dashboard_target), allow_parallel = True, auto_init = run_apps, resource_deps = [ "hydra-dashboard", "api-keys", "svix", "svix-pg", "add-test-users-with-usernames", "fund-user", ], links = [ link("http://localhost:3001", "dashboard"), ], ) pay_target = "//apps/pay:dev" if is_ci: pay_target = '//apps/pay:pay' local_resource( "pay", labels = ["apps"], cmd = "buck2 build {}".format(pay_target), serve_cmd = "buck2 run {}".format(pay_target), serve_env = { "PORT": "3002", "CORE_GQL_URL_INTRANET": "http://localhost:4455/graphql", "NEXT_PUBLIC_CORE_GQL_URL": "http://localhost:4455/graphql", "NEXT_PUBLIC_CORE_GQL_WEB_SOCKET_URL": "wss://localhost:4455/graphql", "NEXT_PUBLIC_PAY_DOMAIN": "localhost:3002", }, deps = _buck2_dep_inputs(pay_target), allow_parallel = True, resource_deps = [ "api", ], links = [ link("http://localhost:3002", "pay"), ], ) local_resource( name='hydra-dashboard', labels = ['apps'], cmd=[ 'buck2', 'run', '//dev:setup-hydra-client', '--', 'dashboard', 'authorization_code,refresh_token', 'http://localhost:3001/api/auth/callback/blink', ], allow_parallel = True, auto_init = run_apps, resource_deps = [ "hydra", "api", ] ) consent_test_target = "//apps/consent:test-integration" local_resource( "consent-test", labels = ["test"], auto_init = is_ci and CONSENT_TEST_LABEL in cfg.get("test", []), cmd = "buck2 test {}".format(consent_test_target), allow_parallel = True, resource_deps = [ "consent", "init-test-user", ], ) dashboard_test_target = "//apps/dashboard:test-integration" local_resource( "dashboard-test", labels = ["test"], auto_init = is_ci and DASHBOARD_TEST_LABEL in cfg.get("test", []), cmd = "buck2 test {}".format(dashboard_test_target), resource_deps = [ "consent", "dashboard", "init-test-user", ], ) pay_test_target = "//apps/pay:test-integration" local_resource( "pay-test", labels = ["test"], auto_init = is_ci and DASHBOARD_TEST_LABEL in cfg.get("test", []), cmd = "buck2 test {}".format(pay_test_target), resource_deps = [ "api", "pay", ], ) local_resource( name='init-test-user', labels = ['test'], cmd='buck2 run //dev:init-user', allow_parallel = True, resource_deps = [ "oathkeeper", "kratos", "api", ] ) local_resource( name='add-test-users-with-usernames', labels = ['test'], cmd='buck2 run //dev:add-test-users-with-usernames', allow_parallel = True, resource_deps = [ "oathkeeper", "kratos", "api", ] ) local_resource( name='fund-user', labels = ['test'], cmd='buck2 run //dev:fund-user', allow_parallel = True, resource_deps = [ "oathkeeper", "kratos", "api", "init-onchain", "init-test-user", "api-trigger", "stablesats", "price", ] ) consent_target = "//apps/consent:dev" if is_ci: consent_target = '//apps/consent:consent' local_resource( "consent", labels = ["auth"], cmd = "buck2 build {}".format(consent_target), serve_cmd = "buck2 run {}".format(consent_target), deps = _buck2_dep_inputs(consent_target), allow_parallel = True, auto_init = run_apps, resource_deps = [ "hydra-consent", "apollo-router", "hydra", "api", ], links = [ link("http://localhost:3000", "consent"), ], ) local_resource( name='hydra-consent', labels = ['auth'], cmd=[ 'buck2', 'run', '//dev:setup-hydra-client', '--', 'consent', 'authorization_code,refresh_token', 'http://localhost:3000', ], allow_parallel = True, auto_init = run_apps, resource_deps = [ "hydra", "api", ] ) core_serve_env = { "HELMREVISION": "dev", "NETWORK": "regtest", "OATHKEEPER_DECISION_ENDPOINT": "http://localhost:4456", "TWILIO_ACCOUNT_SID": "AC_twilio_id", "TWILIO_AUTH_TOKEN": "AC_twilio_auth_token", "TWILIO_VERIFY_SERVICE_ID": "VA_twilio_service", "KRATOS_PG_CON": "postgres://dbuser:secret@localhost:5432/default?sslmode=disable", "KRATOS_PUBLIC_API": "http://localhost:4433", "KRATOS_ADMIN_API": "http://localhost:4434", "KRATOS_MASTER_USER_PASSWORD": "passwordHardtoFindWithNumber123", "KRATOS_CALLBACK_API_KEY": "The-Value-of-My-Key", "PRICE_HOST": "localhost", "PRICE_HISTORY_HOST": "localhost", "BRIA_HOST": "localhost", "BRIA_API_KEY": "bria_dev_000000000000000000000", "NOTIFICATIONS_HOST": "localhost", "MONGODB_CON": "mongodb://localhost:27017/galoy", "REDIS_MASTER_NAME": "mymaster", "REDIS_PASSWORD": "", "REDIS_0_DNS": "localhost", "REDIS_0_PORT": "6379", "REDIS_TYPE": "standalone", "UNSECURE_IP_FROM_REQUEST_OBJECT": "true", "UNSECURE_DEFAULT_LOGIN_CODE": "000000", "GEETEST_ID": "geetest_id", "GEETEST_KEY": "geetest_key", "LND1_TLS": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNZVENDQWdlZ0F3SUJBZ0lSQU9zZzdYWFR4cnVZYlhkeTY2d3RuN1F3Q2dZSUtvWkl6ajBFQXdJd09ERWYKTUIwR0ExVUVDaE1XYkc1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lr1HehfBpn2R5RPE2IuY9r/18QBeLZxYgRidpos4=", "LND2_PUBKEY": "039341ef13e776dc1611502cf510110d9ac5cdc252141f5997adcfd72cef34c3a7", "LND2_DNS": "localhost", "LND2_RPCPORT": "10010", "LND2_NAME": "lnd2", "LND2_TYPE": "offchain", "SVIX_SECRET": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2OTE2NzIwMTQsImV4cCI6MjAwNzAzMjAxNCwibmJmIjoxNjkxNjcyMDE0LCJpc3MiOiJzdml4LXNlcnZlciIsInN1YiI6Im9yZ18yM3JiOFlkR3FNVDBxSXpwZ0d3ZFhmSGlyTXUifQ.b9s0aWSisNdUNki4edabBEToLNSwjC9-AiJQr4J3y4E", "SVIX_ENDPOINT": "http://localhost:8071", "EXPORTER_PORT": "3003" } callback_target = "//bats/helpers/callback:run" local_resource( "callback", labels = ["test"], serve_cmd = "buck2 run {}".format(callback_target), allow_parallel = True, deps = _buck2_dep_inputs(callback_target), ) api_target = "//core/api:dev" if is_ci: api_target = "//core/api:api" local_resource( "api", labels = ["core"], cmd = "buck2 build {}".format(api_target), serve_cmd = "buck2 run {}".format(api_target), serve_env = core_serve_env, allow_parallel = True, readiness_probe = probe( period_secs = 5, http_get = http_get_action( path = "healthz", port = 4012, ), ), deps = _buck2_dep_inputs(api_target), resource_deps = [ "init-onchain", "init-lightning", "lnd1", "redis", "mongodb", "oathkeeper", "svix", ] ) api_trigger_target = "//core/api-trigger:dev" if is_ci: api_trigger_target = "//core/api-trigger:api-trigger" local_resource( "api-trigger", labels = ["core"], cmd = "buck2 build {}".format(api_trigger_target), serve_cmd = "buck2 run //dev:stoppable-trigger {}".format(api_trigger_target), serve_env = core_serve_env, allow_parallel = True, readiness_probe = probe( period_secs = 5, http_get = http_get_action( path = "healthz", port = 4012, ), ), deps = _buck2_dep_inputs(api_trigger_target), resource_deps = [ "init-onchain", "lnd1", "redis", "mongodb", "oathkeeper", ] ) api_exporter_target = "//core/api-exporter:dev" if is_ci: api_exporter_target = "//core/api-exporter:api-exporter" local_resource( "api-exporter", labels = ["core"], cmd = "buck2 build {}".format(api_exporter_target), serve_cmd = "buck2 run {}".format(api_exporter_target), serve_env = core_serve_env, allow_parallel = True, readiness_probe = probe( period_secs = 5, http_get = http_get_action( path = "healthz", port = 4012, ), ), deps = _buck2_dep_inputs(api_exporter_target), resource_deps = [ "init-onchain", "lnd1", "redis", "mongodb", "oathkeeper", ] ) api_ws_server_target = "//core/api-ws-server:dev" if is_ci: api_ws_server_target = "//core/api-ws-server:api-ws-server" local_resource( "api-ws-server", labels = ["core"], cmd = "buck2 build {}".format(api_ws_server_target), serve_cmd = "buck2 run {}".format(api_ws_server_target), serve_env = core_serve_env, allow_parallel = True, readiness_probe = probe( period_secs = 5, http_get = http_get_action( path = "healthz", port = 4012, ), ), deps = _buck2_dep_inputs(api_ws_server_target), resource_deps = [ "init-onchain", "lnd1", "redis", "mongodb", "oathkeeper", ] ) notifications_target = "//core/notifications:notifications" local_resource( "notifications", labels = ["core"], cmd = "buck2 build {}".format(notifications_target), serve_cmd = "buck2 run {}".format(notifications_target), serve_env = { "PG_CON": "postgres://user:password@localhost:5433/pg", "NOTIFICATIONS_CONFIG": "../core/notifications/notifications.yml", "OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317", }, deps = _buck2_dep_inputs(notifications_target), allow_parallel = True, resource_deps = [ "api", "notifications-pg" ] ) local_resource( name='init-onchain', labels = ['bitcoin'], cmd='buck2 run //dev:init-onchain', allow_parallel = True, resource_deps = [ "bitcoind", "bria", ] ) local_resource( name='init-lightning', labels = ['bitcoin'], cmd='buck2 run //dev:init-lightning', allow_parallel = True, resource_deps = [ "init-onchain", "lnd1", "lnd-outside-1", "lnd-outside-2", ] ) api_keys_target = "//core/api-keys:api-keys" local_resource( "api-keys", labels = ["auth"], cmd = "buck2 build {}".format(api_keys_target), serve_cmd = "buck2 run {}".format(api_keys_target), serve_env = { "PG_CON": "postgres://user:password@localhost:5431/pg", "API_KEYS_CONFIG": "../core/api-keys/api-keys.yml", "OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317", }, deps = _buck2_dep_inputs(api_keys_target), allow_parallel = True, resource_deps = [ "api", "api-keys-pg" ] ) docker_groups = { "auth": [ "api-keys-pg", "oathkeeper", "hydra", "hydra-migrate", "hydra-pg", "kratos", "kratos-pg", ], "core": [ "apollo-router", "mongodb", "notifications-pg", "oathkeeper", "redis", "stablesats", "svix-pg", "svix", ], "bitcoin": [ "lnd1", "lnd2", "bria", "bria-pg", "bitcoind", ], "integration": [ "lnd-outside-1", "lnd-outside-2", ], "price": [ "price", "price-history", "price-history-migrate", "price-history-pg" ], "tracing": [ "otel-agent", ], } to_run = cfg.get("to-run", []) if to_run != []: enabled_resources = [] for svc in to_run: enabled_resources.append(svc) config.set_enabled_resources(enabled_resources) to_test = cfg.get("test", []) if to_test != []: enabled_resources = [] for label in to_test: svc = TEST_RESOURCES.get(label) if svc: enabled_resources.append(svc) config.set_enabled_resources(enabled_resources) docker_compose("./docker-compose.deps.yml", project_name = "galoy-dev") for service in docker_groups["bitcoin"]: dc_resource(service, labels = ["bitcoin"]) for service in docker_groups["tracing"]: dc_resource(service, labels = ["tracing"]) for service in docker_groups["core"]: dc_resource(service, labels = ["core"]) for service in docker_groups["auth"]: dc_resource(service, labels = ["auth"]) for service in docker_groups["price"]: dc_resource(service, labels = ["price"]) for service in docker_groups["integration"]: dc_resource(service, labels = ["integration"]) api_test_target = "//core/api:test-integration" local_resource( "api-test", labels = ["test"], auto_init = is_ci and CORE_TEST_LABEL in cfg.get("test", []), cmd = "buck2 test {}".format(api_test_target), resource_deps = [res for sublist in docker_groups.values() for res in sublist], )