diff --git a/.fluentci/src/dagger/index.ts b/.fluentci/src/dagger/index.ts index adb2f6b..59c9c3b 100644 --- a/.fluentci/src/dagger/index.ts +++ b/.fluentci/src/dagger/index.ts @@ -1,3 +1,9 @@ -import { clippy, build, test, llvmCov, e2e, jobDescriptions } from "./jobs.ts"; - -export { clippy, build, test, llvmCov, e2e, jobDescriptions }; +export { + clippy, + build, + test, + llvmCov, + e2e, + typescriptE2e, + jobDescriptions, +} from "./jobs.ts"; diff --git a/.fluentci/src/dagger/jobs.ts b/.fluentci/src/dagger/jobs.ts index de1e202..4fece55 100644 --- a/.fluentci/src/dagger/jobs.ts +++ b/.fluentci/src/dagger/jobs.ts @@ -11,6 +11,7 @@ export enum Job { build = "build", llvmCov = "llvm_cov", e2e = "e2e", + typescriptE2e = "typescript_e2e", } export const exclude = ["target", ".git", ".devbox", ".fluentci"]; @@ -310,6 +311,54 @@ export async function e2e( return stdout; } +/** + * Run e2e tests for typescript sdk + * + * @function + * @description Run e2e tests for typescript sdk + * @param {string | Directory | undefined} src + * @param {string[]} options + * @returns {string} + */ +export async function typescriptE2e( + src: string | Directory | undefined = ".", + options: string[] = [] +): Promise { + const context = await getDirectory(env.get("WORK_DIR") || src); + const engine = dag + .container() + .from("debian:bookworm") + .withExec(["apt-get", "update"]) + .withExec(["apt-get", "install", "-y", "curl", "ca-certificates", "git"]) + .withDirectory("/app", context, { exclude }) + .withWorkdir("/app") + .withFile( + "/fluentci-engine", + dag.host().file("./target/release/fluentci-engine") + ) + .withEnvVariable("FLUENTCI_ENGINE_HOST", "0.0.0.0") + .withExec(["/fluentci-engine"]) + .withExposedPort(6880) + .asService(); + + const ctr = await dag + .pipeline(Job.typescriptE2e) + .container() + .from("pkgxdev/pkgx:latest") + .withExec(["pkgx", "install", "deno"]) + .withExec(["deno", "--version"]) + .withDirectory("/app", context, { exclude }) + .withWorkdir("/app/demo") + .withServiceBinding("fluentci-engine", engine) + .sync(); + + const stdout = await ctr.withExec(["deno", "run", "-A", "main.ts"]).stdout(); + + console.log(stdout); + + return stdout; +} + export type JobExec = | ((src?: string | Directory | undefined) => Promise) | ((src?: string | Directory | undefined) => Promise) @@ -319,6 +368,7 @@ export const runnableJobs: Record = { [Job.clippy]: clippy, [Job.test]: test, [Job.e2e]: e2e, + [Job.typescriptE2e]: typescriptE2e, [Job.build]: build, [Job.llvmCov]: llvmCov, }; @@ -327,6 +377,7 @@ export const jobDescriptions: Record = { [Job.clippy]: "Run clippy", [Job.test]: "Run tests", [Job.e2e]: "Run e2e tests", + [Job.typescriptE2e]: "Run e2e tests for typescript sdk", [Job.build]: "Build the project", [Job.llvmCov]: "Generate llvm coverage report", }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e612b5..2ea1fda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup Fluent CI uses: fluentci-io/setup-fluentci@v4 - - name: Run Dagger Pipelines + - name: Run Build and e2e tests run: | fluentci run rust_pipeline build ls -ltr target @@ -21,3 +21,9 @@ jobs: FLUENTCI_ENGINE_HOST: 0.0.0.0 WORK_DIR: ./fixtures DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }} + - name: Run e2e tests (typescript sdk) + run: fluentci run . typesscipt_e2e + env: + FLUENTCI_ENGINE_HOST: 0.0.0.0 + WORK_DIR: ./sdk/typescript + DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }}