Skip to content

Commit 298aaae

Browse files
authored
fix: c# on windows, oracledb test connection, cli for C# and Oracle DB (#5090)
* Fix c# on windows * Fix test connection on oracledb * Add csharp and oracledb to CLI * Fix missing extensions * Build wasm for cli
1 parent 6f469ac commit 298aaae

File tree

12 files changed

+252
-138
lines changed

12 files changed

+252
-138
lines changed

backend/windmill-api/src/workspaces_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub(crate) async fn tarball_workspace(
354354
ScriptLang::Rust => "rs",
355355
ScriptLang::Ansible => "playbook.yml",
356356
ScriptLang::CSharp => "cs",
357-
ScriptLang::OracleDB => "oracle.sql",
357+
ScriptLang::OracleDB => "odb.sql",
358358
};
359359
archive
360360
.write_to_archive(&script.content, &format!("{}.{}", script.path, ext))

backend/windmill-worker/src/csharp_executor.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,15 @@ fn gen_cs_proj(
235235
let script_call = match (sig_meta.is_async, sig_meta.returns_void) {
236236
(true, true) => format!(
237237
r#"
238-
{class_name}.Main({spread}).Wait();"#
238+
{class_name}.Main({spread}).Wait();
239+
File.WriteAllText("result.json", "null");
240+
"#
239241
),
240242
(false, true) => format!(
241243
r#"
242-
{class_name}.Main({spread});"#
244+
{class_name}.Main({spread});
245+
File.WriteAllText("result.json", "null");
246+
"#
243247
),
244248

245249
(false, false) => format!(
@@ -282,9 +286,15 @@ namespace WindmillScriptCSharpInternal {{
282286
using FileStream fs = File.OpenRead("args.json");
283287
Args parsedArgs = JsonSerializer.Deserialize<Args>(fs);
284288
285-
File.WriteAllText("result.json", "null");
286-
287-
{script_call}
289+
try
290+
{{
291+
{script_call}
292+
}}
293+
catch (Exception ex)
294+
{{
295+
Console.Error.WriteLine("Unhandeled Exception: " + ex.ToString());
296+
Environment.Exit(1);
297+
}}
288298
}}
289299
}}
290300
}}
@@ -330,6 +340,7 @@ async fn build_cs_proj(
330340
job_dir,
331341
"--no-self-contained",
332342
"-p:PublishSingleFile=true",
343+
"-p:IncludeNativeLibrariesForSelfExtract=true",
333344
])
334345
.stdout(Stdio::piped())
335346
.stderr(Stdio::piped());

cli/bootstrap/script_bootstrap.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ function main() {
8585
}
8686
`,
8787

88+
csharp: `class Script
89+
{
90+
public static void Main()
91+
{
92+
Console.WriteLine("Hello World");
93+
}
94+
}
95+
`,
96+
8897
rust: `fn main() -> Result<(), String> {
8998
println!("Hello World");
9099
Ok(())

cli/metadata.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import {
2626
parse_powershell,
2727
parse_python,
2828
parse_rust,
29+
parse_csharp,
2930
parse_snowflake,
3031
parse_sql,
32+
parse_oracledb,
3133
} from "./wasm/windmill_parser_wasm.generated.js";
3234
import { Workspace } from "./workspace.ts";
3335
import { SchemaProperty } from "./bootstrap/common.ts";
@@ -468,6 +470,12 @@ export function inferSchema(
468470
{ name: "database", typ: { resource: "bigquery" } },
469471
...inferedSchema.args,
470472
];
473+
} else if (language === "oracledb") {
474+
inferedSchema = JSON.parse(parse_oracledb(content));
475+
inferedSchema.args = [
476+
{ name: "database", typ: { resource: "oracledb" } },
477+
...inferedSchema.args,
478+
];
471479
} else if (language === "snowflake") {
472480
inferedSchema = JSON.parse(parse_snowflake(content));
473481
inferedSchema.args = [
@@ -500,6 +508,8 @@ export function inferSchema(
500508
inferedSchema = JSON.parse(parse_php(content));
501509
} else if (language === "rust") {
502510
inferedSchema = JSON.parse(parse_rust(content));
511+
} else if (language === "csharp") {
512+
inferedSchema = JSON.parse(parse_csharp(content));
503513
} else if (language === "ansible") {
504514
inferedSchema = JSON.parse(parse_ansible(content));
505515
} else {

cli/script.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ export function filePathExtensionFromContentType(
510510
return ".my.sql";
511511
} else if (language === "bigquery") {
512512
return ".bq.sql";
513+
} else if (language === "oracledb") {
514+
return ".odb.sql";
513515
} else if (language === "snowflake") {
514516
return ".sf.sql";
515517
} else if (language === "mssql") {
@@ -528,6 +530,8 @@ export function filePathExtensionFromContentType(
528530
return ".rs";
529531
} else if (language === "ansible") {
530532
return ".playbook.yml";
533+
} else if (language === "csharp") {
534+
return ".cs";
531535
} else {
532536
throw new Error("Invalid language: " + language);
533537
}
@@ -544,13 +548,15 @@ export const exts = [
544548
".pg.sql",
545549
".my.sql",
546550
".bq.sql",
551+
".odb.sql",
547552
".sf.sql",
548553
".ms.sql",
549554
".sql",
550555
".gql",
551556
".ps1",
552557
".php",
553558
".rs",
559+
".cs",
554560
".playbook.yml",
555561
];
556562

cli/script_common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ export type ScriptLanguage =
99
| "postgresql"
1010
| "mysql"
1111
| "bigquery"
12+
| "oracledb"
1213
| "snowflake"
1314
| "mssql"
1415
| "graphql"
1516
| "php"
1617
| "rust"
18+
| "csharp"
1719
| "ansible";
1820

1921
export function inferContentTypeFromFilePath(
@@ -36,6 +38,8 @@ export function inferContentTypeFromFilePath(
3638
return "mysql";
3739
} else if (contentPath.endsWith(".bq.sql")) {
3840
return "bigquery";
41+
} else if (contentPath.endsWith(".odb.sql")) {
42+
return "oracledb";
3943
} else if (contentPath.endsWith(".sf.sql")) {
4044
return "snowflake";
4145
} else if (contentPath.endsWith(".ms.sql")) {
@@ -52,6 +56,8 @@ export function inferContentTypeFromFilePath(
5256
return "php";
5357
} else if (contentPath.endsWith(".rs")) {
5458
return "rust";
59+
} else if (contentPath.endsWith(".cs")) {
60+
return "csharp";
5561
} else if (contentPath.endsWith(".playbook.yml")) {
5662
return "ansible";
5763
} else {

cli/sync.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,15 @@ export function newPathAssigner(defaultTs: "bun" | "deno"): PathAssigner {
320320
else if (language == "postgresql") ext = "pg.sql";
321321
else if (language == "mysql") ext = "my.sql";
322322
else if (language == "bigquery") ext = "bq.sql";
323+
else if (language == "oracledb") ext = "odb.sql";
323324
else if (language == "snowflake") ext = "sf.sql";
324325
else if (language == "mssql") ext = "ms.sql";
325326
else if (language == "graphql") ext = "gql";
326327
else if (language == "nativets") ext = "native.ts";
327328
else if (language == "frontend") ext = "frontend.js";
328329
else if (language == "php") ext = "php";
329330
else if (language == "rust") ext = "rs";
331+
else if (language == "csharp") ext = "cs";
330332
else if (language == "ansible") ext = "playbook.yml";
331333
else ext = "no_ext";
332334

@@ -647,6 +649,7 @@ export async function elementsToMap(
647649
"js",
648650
"lock",
649651
"rs",
652+
"cs",
650653
"yml",
651654
].includes(path.split(".").pop() ?? "") &&
652655
!isFileResource(path)

cli/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export function getTypeStrFromPath(
202202
parsed.ext == ".js" ||
203203
parsed.ext == ".php" ||
204204
parsed.ext == ".rs" ||
205+
parsed.ext == ".cs" ||
205206
(parsed.ext == ".yml" && parsed.name.split(".").pop() == "playbook")
206207
) {
207208
return "script";

cli/wasm/windmill_parser_wasm.generated.d.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ export interface InstantiateResult {
1313
parse_python: typeof parse_python;
1414
parse_sql: typeof parse_sql;
1515
parse_mysql: typeof parse_mysql;
16+
parse_oracledb: typeof parse_oracledb;
1617
parse_bigquery: typeof parse_bigquery;
1718
parse_snowflake: typeof parse_snowflake;
1819
parse_mssql: typeof parse_mssql;
1920
parse_db_resource: typeof parse_db_resource;
2021
parse_graphql: typeof parse_graphql;
2122
parse_php: typeof parse_php;
2223
parse_rust: typeof parse_rust;
23-
parse_ansible: typeof parse_ansible
24+
parse_ansible: typeof parse_ansible;
25+
parse_csharp: typeof parse_csharp
2426
};
2527
}
2628

@@ -96,6 +98,11 @@ export function parse_mysql(code: string): string;
9698
* @param {string} code
9799
* @returns {string}
98100
*/
101+
export function parse_oracledb(code: string): string;
102+
/**
103+
* @param {string} code
104+
* @returns {string}
105+
*/
99106
export function parse_bigquery(code: string): string;
100107
/**
101108
* @param {string} code
@@ -132,3 +139,8 @@ export function parse_rust(code: string): string;
132139
* @returns {string}
133140
*/
134141
export function parse_ansible(code: string): string;
142+
/**
143+
* @param {string} code
144+
* @returns {string}
145+
*/
146+
export function parse_csharp(code: string): string;

0 commit comments

Comments
 (0)