Skip to content

Commit

Permalink
wip: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Jul 21, 2024
1 parent 33f9962 commit 8d471af
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 36 deletions.
2 changes: 1 addition & 1 deletion dev/tasks-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const tasks: Record<string, DenoTaskDefArgs> = {
"-f",
file,
])
} down --remove-orphans`;
} down --remove-orphans --volumes`;
}
},
},
Expand Down
110 changes: 110 additions & 0 deletions examples/deno.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/typegraphs/metagen/rs/mdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Router {
}

pub fn init(&self, args: InitArgs) -> Result<InitResponse, InitError> {
static MT_VERSION: &str = "0.4.4-0";
static MT_VERSION: &str = "0.4.6-0";
if args.metatype_version != MT_VERSION {
return Err(InitError::VersionMismatch(MT_VERSION.into()));
}
Expand Down
33 changes: 20 additions & 13 deletions typegate/tests/e2e/cli/dev_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ Meta.test(
stderr: "piped",
stdin: "piped",
}).spawn();

const stderr = new Lines(metadev.stderr);
const stdin = new LineWriter(metadev.stdin);

t.addCleanup(async () => {
await stderr.close();
await stdin.close();
await killProcess(metadev);
});

await stderr.readWhile((line) => {
// console.log("meta dev>", line);
return !$.stripAnsi(line).includes(
Expand Down Expand Up @@ -129,10 +134,6 @@ Meta.test(
})
.on(e);
});

await stderr.close();
await stdin.close();
await killProcess(metadev);
},
);

Expand Down Expand Up @@ -186,6 +187,12 @@ Meta.test(
const stderr = new Lines(metadev.stderr);
const stdin = new LineWriter(metadev.stdin);

t.addCleanup(async () => {
await stderr.close();
await stdin.close();
await killProcess(metadev);
});

await stderr.readWhile((line) => {
// console.log("line:", line);
return !$.stripAnsi(line).includes(
Expand Down Expand Up @@ -244,10 +251,6 @@ Meta.test(
await t.should("have removed latest migration", async () => {
assert((await listSubdirs(migrationsDir)).length === 1);
});

await stderr.close();
await stdin.close();
await killProcess(metadev);
},
);

Expand All @@ -264,7 +267,14 @@ Meta.test("meta dev with typegate", async (t) => {
}).spawn();
const stderr = new Lines(metadev.stderr);
const stdout = new Lines(metadev.stdout);

t.addCleanup(async () => {
await stderr.close();
await stdout.close();
// FIXME: it still leaks the child typegate process even
// though we the cli has a ctrl_c handler
metadev.kill("SIGTERM");
await metadev.status;
});
const deployed: [string, string][] = [];

console.log(new Date());
Expand Down Expand Up @@ -335,7 +345,4 @@ Meta.test("meta dev with typegate", async (t) => {
["triggers.ts", "triggers"],
]);
});

await stderr.close();
await killProcess(metadev);
});
5 changes: 2 additions & 3 deletions typegate/tests/e2e/published/published_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ Meta.test(
`meta deploy --target dev --threads=4 --allow-dirty --gate http://localhost:7899 -vvv`;
const res = await $`bash -c ${command}`
.cwd(examplesDir.join("typegraphs"))
.env("PATH", `${metaBinDir}:${Deno.env.get("PATH")}`)
.env("MCLI_LOADER_CMD", "npm x tsx");
.env("PATH", `${metaBinDir}:${Deno.env.get("PATH")}`);
console.log(res);
});

Expand Down Expand Up @@ -405,7 +404,7 @@ typegraphs:
pypaDir,
);
await $.co([
$.raw`poetry install`.cwd(pypaDir),
$`bash -c 'poetry env use python && poetry install'`.cwd(pypaDir),
$.path("examples/typegraphs/func.py").copy(pypaDir.join("tg.py")),
$.path("examples/typegraphs/scripts").copyToDir(pypaDir),
]);
Expand Down
30 changes: 15 additions & 15 deletions typegate/tests/metagen/typegraphs/identities/py/handlers_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CompositesArgs(Struct):
class Composites(Struct):
opt: Union[str, None]
either: Union["Branch2", "Primitives"]
union: Union[List[str], int, str]
union: Union[str, int, List[str]]
list: List[str]


Expand All @@ -143,7 +143,7 @@ class Cycles1Args(Struct):
@dataclass
class Cycles1(Struct):
phantom1: Union[str, None]
to2: Union[Union[Union["Branch33B", "Branch33A"], "Cycles1"], None]
to2: Union[Union["Cycles1", Union["Branch33A", "Branch33B"]], None]
list3: Union[List[Union["Branch33B", "Branch33A"]], None]


Expand All @@ -162,7 +162,7 @@ class Branch33A(Struct):
@dataclass
class Branch33B(Struct):
phantom3b: Union[str, None]
to2: Union[Union[Union["Branch33A", "Branch33B"], "Cycles1"], None]
to2: Union[Union["Cycles1", Union["Branch33A", "Branch33B"]], None]


FORWARD_REFS["Branch33B"] = Branch33B
Expand Down Expand Up @@ -209,43 +209,43 @@ def __repr(value: Any):
return value


def typed_primitives(user_fn: Callable[[PrimitivesArgs], Primitives]):
def typed_simple_cycles(user_fn: Callable[[SimpleCycles1Args], SimpleCycles1]):
def exported_wrapper(raw_inp):
inp: PrimitivesArgs = Struct.new(PrimitivesArgs, raw_inp)
out: Primitives = user_fn(inp)
inp: SimpleCycles1Args = Struct.new(SimpleCycles1Args, raw_inp)
out: SimpleCycles1 = user_fn(inp)
if isinstance(out, list):
return [__repr(v) for v in out]
return __repr(out)

return exported_wrapper


def typed_composites(user_fn: Callable[[CompositesArgs], Composites]):
def typed_cycles(user_fn: Callable[[Cycles1Args], Cycles1]):
def exported_wrapper(raw_inp):
inp: CompositesArgs = Struct.new(CompositesArgs, raw_inp)
out: Composites = user_fn(inp)
inp: Cycles1Args = Struct.new(Cycles1Args, raw_inp)
out: Cycles1 = user_fn(inp)
if isinstance(out, list):
return [__repr(v) for v in out]
return __repr(out)

return exported_wrapper


def typed_cycles(user_fn: Callable[[Cycles1Args], Cycles1]):
def typed_primitives(user_fn: Callable[[PrimitivesArgs], Primitives]):
def exported_wrapper(raw_inp):
inp: Cycles1Args = Struct.new(Cycles1Args, raw_inp)
out: Cycles1 = user_fn(inp)
inp: PrimitivesArgs = Struct.new(PrimitivesArgs, raw_inp)
out: Primitives = user_fn(inp)
if isinstance(out, list):
return [__repr(v) for v in out]
return __repr(out)

return exported_wrapper


def typed_simple_cycles(user_fn: Callable[[SimpleCycles1Args], SimpleCycles1]):
def typed_composites(user_fn: Callable[[CompositesArgs], Composites]):
def exported_wrapper(raw_inp):
inp: SimpleCycles1Args = Struct.new(SimpleCycles1Args, raw_inp)
out: SimpleCycles1 = user_fn(inp)
inp: CompositesArgs = Struct.new(CompositesArgs, raw_inp)
out: Composites = user_fn(inp)
if isinstance(out, list):
return [__repr(v) for v in out]
return __repr(out)
Expand Down
2 changes: 1 addition & 1 deletion typegate/tests/metagen/typegraphs/identities/rs/mdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Router {
}

pub fn init(&self, args: InitArgs) -> Result<InitResponse, InitError> {
static MT_VERSION: &str = "0.4.4-0";
static MT_VERSION: &str = "0.4.6-0";
if args.metatype_version != MT_VERSION {
return Err(InitError::VersionMismatch(MT_VERSION.into()));
}
Expand Down
2 changes: 1 addition & 1 deletion typegate/tests/runtimes/wasm_reflected/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typegate/tests/runtimes/wasm_wire/rust/mdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Router {
}

pub fn init(&self, args: InitArgs) -> Result<InitResponse, InitError> {
static MT_VERSION: &str = "0.4.4-0";
static MT_VERSION: &str = "0.4.6-0";
if args.metatype_version != MT_VERSION {
return Err(InitError::VersionMismatch(MT_VERSION.into()));
}
Expand Down

0 comments on commit 8d471af

Please sign in to comment.