Skip to content

Commit

Permalink
temporal (#551)
Browse files Browse the repository at this point in the history
* temporal workers

* simple e2e workers example

* bump node version

* Add WorkflowA test and update dependencies and tsconfig

Adds a new test file for WorkflowA, updates the `jest`,
`ts-node`, and `typescript` dependencies to specific versions, and
makes changes to the `tsconfig.json` file in the `packages/workflows`
directory.

* cleanup tiltfiles

* add workers to tilt

* add missing workers:test
  • Loading branch information
0xBigBoss authored Jul 6, 2024
1 parent e3eb0b8 commit 7053289
Show file tree
Hide file tree
Showing 46 changed files with 2,786 additions and 392 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.1
v20.15.0
13 changes: 13 additions & 0 deletions .yarn/patches/istanbul-lib-coverage-npm-3.2.2-5c0526e059.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/file-coverage.js b/lib/file-coverage.js
index 4ed4c096185addd9960d023c5982bc36c98c58b5..08e272ceb980a8d91d530a2fd8c58fec0ba0bc51 100644
--- a/lib/file-coverage.js
+++ b/lib/file-coverage.js
@@ -206,6 +206,8 @@ class FileCoverage {
this.data = emptyCoverage(pathOrObj, reportLogic);
} else if (pathOrObj instanceof FileCoverage) {
this.data = pathOrObj.data;
+ } else if (typeof pathOrObj === 'object' && pathOrObj.data) {
+ this.data = pathOrObj.data;
} else if (typeof pathOrObj === 'object') {
this.data = pathOrObj;
} else {
5 changes: 3 additions & 2 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ brew "jq" unless system "jq --version"
brew "yj" unless system "yj -v"
brew "tilt" unless system "tilt version"
brew "caddy" unless system "caddy version"
brew "nss" unless system "type nss-policy-check"
brew "nss" unless system "nss-config --version"
brew "sqlfluff" unless CI or system "sqlfluff --version"
brew "postgresql@15" unless system "type pg_dump"
brew "postgresql@15" unless system "psql --version"
brew "gnu-sed" unless system "gsed --version"
brew "direnv" unless system "direnv --version"
brew "temporal" unless system "temporal --version"
312 changes: 4 additions & 308 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
load("ext://color", "color")
load("ext://dotenv", "dotenv")
load("ext://uibutton", "cmd_button", "location")
load("./tilt/common.tiltfile", "CFG", "CI", "DEBUG", "contract_files")
load("./tilt/utils.tiltfile", "files_matching", "require_env", "require_tools")
load("./tilt/common.tiltfile", "CFG", "CI", "DEBUG")
load("./tilt/utils.tiltfile", "require_env", "require_tools")

print(color.green("███████╗███████╗███╗ ██╗██████╗ ██╗████████╗"))

Expand Down Expand Up @@ -84,312 +83,9 @@ include("tilt/infra.tiltfile")

include("tilt/deps.tiltfile")

# APPS
labels = ["apps"]
include("./tilt/apps.tiltfile")

next_app_resource_deps = [
"yarn:install",
"supabase",
"supabase:generate",
"wagmi:generate",
"ui:build",
"ui:generate-theme",
"daimo-expo-passkeys:build",
"anvil:fixtures",
"shovel",
] + ([
"aa_bundler:base",
] if not CI else [])

# Next
if CFG.dockerize:
GIT_BRANCH = str(local("git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD")).strip()
GIT_HASH = str(local("git rev-parse --short=10 HEAD")).strip()

# FIXME: when we support dev mode and dockerize.
# docker_build(
# "0xsend/sendapp/next-app",
# ".",
# dockerfile = "apps/next/Dockerfile",
# extra_tag = ["latest", GIT_HASH],
# platform = "linux/amd64",
# secret = [
# "id=SUPABASE_DB_URL,src=./var/SUPABASE_DB_URL.txt",
# "id=SUPABASE_SERVICE_ROLE,src=./var/SUPABASE_SERVICE_ROLE.txt",
# ],
# build_args=[

# ]
# )
docker_compose("./docker-compose.yml")
dc_resource(
"next-app",
labels = ["apps"],
new_name = "next:web",
resource_deps = [
"yarn:install",
"supabase",
"anvil:fixtures",
"aa_bundler:base",
"shovel",
],
)
else:
local_resource(
"next:web",
"yarn workspace next-app next:build" if CI else "", # In CI, only build the web app
labels = labels,
links = ["http://localhost:3000"],
readiness_probe = None if CI else probe(
http_get = http_get_action(
path = "/api/healthz",
port = 3000,
),
period_secs = 15,
),
resource_deps = next_app_resource_deps,
serve_cmd =
"" if CI else "yarn next-app dev", # In CI, playwright tests start the web server
)

local_resource(
"distributor:web",
allow_parallel = True,
labels = labels,
links = ["http://localhost:3050"],
readiness_probe = probe(
http_get = http_get_action(
path = "/",
port = 3050,
),
period_secs = 15,
),
resource_deps = [
"yarn:install",
"anvil:mainnet",
"supabase",
"supabase:generate",
"wagmi:generate",
],
serve_cmd =
"yarn run distributor start" if CI else "yarn run distributor dev",
)

local_resource(
"caddy:web",
auto_init = not CI,
labels = labels,
serve_cmd = "caddy run --watch --config dev.Caddyfile",
trigger_mode = TRIGGER_MODE_MANUAL,
)

# TESTS
labels = ["test"]

local_resource(
"app:test",
"yarn workspace app test",
allow_parallel = True,
labels = labels,
resource_deps = [
"yarn:install",
"contracts:build",
"wagmi:generate",
"supabase:generate",
"snaplet:generate",
"ui:build",
"ui:generate-theme",
"daimo-expo-passkeys:build",
"webauthn-authenticator:build",
"shovel:generate-config",
],
deps =
files_matching(
os.path.join("packages", "app"),
lambda f: f.endswith(".ts") or f.endswith(".tsx"),
),
)

cmd_button(
"app:test:update-snapshots",
argv = [
"yarn",
"workspace",
"app",
"test",
"-u",
],
icon_name = "update",
location = location.RESOURCE,
resource = "app:test",
text = "update snapshots",
)

local_resource(
"webauthn-authenticator:test",
"yarn workspace @0xsend/webauthn-authenticator test:coverage --run",
allow_parallel = True,
labels = labels,
resource_deps = ["yarn:install"],
deps =
files_matching(
os.path.join("packages", "webauthn-authenticator"),
lambda f: f.endswith(".ts"),
),
)

local_resource(
"playwright:deps",
"echo 🥳",
labels = labels,
resource_deps = [
"anvil:mainnet",
"anvil:base",
"anvil:fixtures",
"aa_bundler:base",
"snaplet:generate",
"next:web",
"supabase",
"shovel",
],
)

local_resource(
"playwright:test",
"yarn playwright test",
allow_parallel = True,
auto_init = CI,
labels = labels,
resource_deps = [
"next:web",
"playwright:deps",
],
trigger_mode = CI and TRIGGER_MODE_AUTO or TRIGGER_MODE_MANUAL,
deps = files_matching(
os.path.join("packages", "playwright"),
lambda f: f.endswith(".ts"),
),
)

cmd_button(
"playwright:show-report",
argv = [
"yarn",
"playwright",
"playwright",
"show-report",
],
icon_name = "info",
location = location.RESOURCE,
resource = "playwright:test",
text = "playwright report",
)

cmd_button(
"playwright:test:ui",
argv = [
"yarn",
"playwright",
"test",
"--ui",
],
icon_name = "bug_report",
location = location.RESOURCE,
resource = "playwright:test",
text = "playwright test --ui",
)

local_resource(
"distributor:test",
"yarn workspace distributor test --run",
allow_parallel = True,
labels = labels,
resource_deps = [
"yarn:install",
"anvil:mainnet",
"supabase",
"supabase:generate",
"wagmi:generate",
],
deps =
files_matching(
os.path.join("apps", "distributor", "test"),
lambda f: f.endswith(".ts"),
),
)

local_resource(
"supabase:test",
"yarn supabase test",
allow_parallel = True,
labels = labels,
resource_deps = [
"supabase",
"snaplet:generate", # hack to ensure snaplet doesn't include test pg_tap schema
],
deps = files_matching(
os.path.join("supabase", "tests"),
lambda f: f.endswith(".sql"),
),
)

local_resource(
"contracts:test",
"yarn contracts test",
allow_parallel = True,
labels = labels,
resource_deps = [
"yarn:install",
"contracts:build",
],
deps = contract_files,
)

local_resource(
"contracts:cov",
"yarn contracts test:cov -vvv",
allow_parallel = True,
auto_init = False,
labels = labels,
resource_deps = [
"yarn:install",
"contracts:build",
"contracts:test",
],
deps = contract_files,
)

local_resource(
name = "shovel:test",
allow_parallel = True,
auto_init = not CI,
cmd = "yarn workspace @my/shovel test",
labels = labels,
resource_deps = [
"yarn:install",
"shovel:generate-config",
],
trigger_mode = CI and TRIGGER_MODE_MANUAL or TRIGGER_MODE_AUTO,
deps = files_matching(
os.path.join("packages", "shovel", "etc"),
lambda f: f.endswith(".json"),
),
)

local_resource(
name = "unit-tests",
allow_parallel = True,
cmd = "echo 🥳",
labels = labels,
resource_deps = [
# messy but create a single resource that runs all the tests
"app:test",
"webauthn-authenticator:test",
"supabase:test",
"contracts:test",
"distributor:test",
],
)
include("./tilt/tests.tiltfile")

if config.tilt_subcommand == "down":
include("./tilt/cleanup.tiltfile")
Expand Down
2 changes: 1 addition & 1 deletion apps/distributor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"debug": "^4.3.4",
"dotenv-cli": "^7.3.0",
"supertest": "^6.3.3",
"typescript": "^5.3.3"
"typescript": "^5.5.3"
}
}
2 changes: 1 addition & 1 deletion apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
"cross-env": "^7.0.3",
"metro-minify-terser": "^0.74.1",
"react-native-clean-project": "^4.0.3",
"typescript": "^5.3.3"
"typescript": "^5.5.3"
}
}
4 changes: 3 additions & 1 deletion apps/next/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ FROM base AS installer
COPY yarn.lock yarn.lock
COPY .yarnrc.yml .yarnrc.yml
COPY .yarn .yarn
# git ls-files | grep 'package\.json$' | sort | sed 's#\(.*\)#COPY \1 \1#'
# git ls-files | grep 'package\.json$' | sort | sed 's#\(.*\)#COPY \1 \1#'
COPY apps/distributor/package.json apps/distributor/package.json
COPY apps/expo/package.json apps/expo/package.json
COPY apps/next/package.json apps/next/package.json
COPY apps/workers/package.json apps/workers/package.json
COPY package.json package.json
COPY packages/api/package.json packages/api/package.json
COPY packages/app/package.json packages/app/package.json
Expand All @@ -34,6 +35,7 @@ COPY packages/snaplet/package.json packages/snaplet/package.json
COPY packages/ui/package.json packages/ui/package.json
COPY packages/wagmi/package.json packages/wagmi/package.json
COPY packages/webauthn-authenticator/package.json packages/webauthn-authenticator/package.json
COPY packages/workflows/package.json packages/workflows/package.json
COPY supabase/package.json supabase/package.json

RUN --mount=type=cache,target=/root/.yarn/berry \
Expand Down
Loading

0 comments on commit 7053289

Please sign in to comment.