Skip to content

Commit

Permalink
ci: add e2e tests for typescript sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Mar 18, 2024
1 parent d489338 commit b4219f3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .fluentci/src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum Job {
build = "build",
llvmCov = "llvm_cov",
e2e = "e2e",
typescriptE2e = "typescript_e2e",
}

export const exclude = ["target", ".git", ".devbox", ".fluentci"];
Expand Down Expand Up @@ -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<string> {
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<Directory | string>)
| ((src?: string | Directory | undefined) => Promise<File | string>)
Expand All @@ -319,6 +368,7 @@ export const runnableJobs: Record<Job, JobExec> = {
[Job.clippy]: clippy,
[Job.test]: test,
[Job.e2e]: e2e,
[Job.typescriptE2e]: typescriptE2e,
[Job.build]: build,
[Job.llvmCov]: llvmCov,
};
Expand All @@ -327,6 +377,7 @@ export const jobDescriptions: Record<Job, string> = {
[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",
};
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 . ts-e2e
env:
FLUENTCI_ENGINE_HOST: 0.0.0.0
WORK_DIR: ./sdk/typescript
DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }}

0 comments on commit b4219f3

Please sign in to comment.