From f5901900cb4e310b107d25023b57022b0d2f2eaa Mon Sep 17 00:00:00 2001 From: Quentin VIGNAUD Date: Mon, 8 Dec 2025 17:37:29 +0100 Subject: [PATCH] WIP --- .melodium-ci/build_test_aya.mel | 90 +++++++++++++++++++++++++++++++++ .melodium-ci/prepare.mel | 77 ++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 .melodium-ci/build_test_aya.mel create mode 100644 .melodium-ci/prepare.mel diff --git a/.melodium-ci/build_test_aya.mel b/.melodium-ci/build_test_aya.mel new file mode 100644 index 00000000..dce3c9d5 --- /dev/null +++ b/.melodium-ci/build_test_aya.mel @@ -0,0 +1,90 @@ +use root/prepare::checkout +use root/prepare::setupToolchain +use root/prepare::prepareRust + +treatment buildTestAyaForArch[logger: Logger, github_contexts: JavaScriptEngine, finish_concentrator: Concentrator](rust_target: string, repository_clone_url: string, repository_clone_ref: string) + input trigger: Block + output finished: Block +{ + concentrateFinish: concentrateBlock[concentrator=finish_concentrator]() + run.finished -> concentrateFinish.data + + checkout[logger=logger]( + label=|format("checkout ({rust_target})", |entry("rust_target", rust_target)), + repository_clone_url=repository_clone_url, + repository_clone_ref=repository_clone_ref, + clone_directory=|format("/tmp/work_{rust_target}", |entry("rust_target", rust_target)) + ) + setupToolchain[logger=logger](rust_target=rust_target) + prepareRust[logger=logger](rust_target=rust_target) + + rustReady: waitBlock() + projectReady: waitBlock() + Self.trigger -> prepareRust.trigger,success ----> rustReady.a + Self.trigger -> setupToolchain.trigger,success -> rustReady.b,awaited -> projectReady.a + Self.trigger -> checkout.trigger,success ------------------------------> projectReady.b,awaited -> run.trigger + + run: localStep[logger=logger]( + name = |format("run ({rust_target})", |entry("rust_target", rust_target)), + variables = |wrap( + |map([ + |entry("RUST_BACKTRACE", "full"), + |entry("CARGO_BUILD_TARGET", rust_target) + ]) + ), + commands = [ + // Build + |command("bash", ["-c", " + set -o allexport && source /tmp/${CARGO_BUILD_TARGET}/github.env && set +o allexport + cargo hack build --all-targets --feature-powerset \\ + --exclude aya-ebpf \\ + --exclude aya-ebpf-bindings \\ + --exclude aya-log-ebpf \\ + --exclude integration-ebpf \\ + --exclude xtask \\ + --workspace + "]), + // Test + |command("bash", ["-c", " + set -o allexport && source /tmp/${CARGO_BUILD_TARGET}/github.env && set +o allexport + cargo hack test --all-targets --feature-powerset \\ + --exclude aya-ebpf \\ + --exclude aya-ebpf-bindings \\ + --exclude aya-log-ebpf \\ + --exclude integration-ebpf \\ + --exclude integration-test \\ + --exclude xtask \\ + --workspace + "]), + // Doc + |command("bash", ["-c", " + set -o allexport && source /tmp/${CARGO_BUILD_TARGET}/github.env && set +o allexport + cargo hack test --doc --feature-powerset \\ + --exclude aya-ebpf \\ + --exclude aya-ebpf-bindings \\ + --exclude aya-log-ebpf \\ + --exclude integration-ebpf \\ + --exclude integration-test \\ + --exclude xtask \\ + --workspace + "]) + ], + + ) + + prepare.awaited -> build.trigger,finished -> Self.finished + + pendingState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |pending(), name = rust_target, description = "Build and Test Aya on arch", log_response = true) + successState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |success(), name = rust_target, description = "Build and Test Aya on arch", log_response = true) + errorState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |error(), name = rust_target, description = "Build and Test Aya on arch", log_response = true) + failureState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |failure(), name = rust_target, description = "Build and Test Aya on arch", log_response = true) + + Self.trigger --> pendingState.trigger + run.success ---> successState.trigger + run.error -----> errorState.trigger + + uncheckSuccess: uncheck() + oneFailure: one() + run.success -> uncheckSuccess.value,uncheck -> oneFailure.a + run.failed ----------------------------------> oneFailure.b,value -> failureState.trigger +} diff --git a/.melodium-ci/prepare.mel b/.melodium-ci/prepare.mel new file mode 100644 index 00000000..da47b926 --- /dev/null +++ b/.melodium-ci/prepare.mel @@ -0,0 +1,77 @@ +use cicd/naive::localStep +use log/logger::Logger +use process/command::|raw_commands +use std/data/string_map::StringMap +use std/data/string_map::|entry +use std/data/string_map::|map +use std/text/compose::|format + +treatment checkout[logger: Logger](label: string, repository_clone_url: string, repository_clone_ref: string, clone_directory: string) + input trigger: Block + output success: Block + output finished: Block + output error: Block +{ + localStep[logger=logger]( + name = label, + commands = |raw_commands([ + "git config --global url.https://.insteadOf git://", + |format("git clone --branch {repository_clone_ref} --depth 1 {repository_clone_url} {clone_directory}", + |map([ + |entry("repository_clone_ref", repository_clone_ref), + |entry("repository_clone_url", repository_clone_url), + |entry("clone_directory", clone_directory) + ]) + ) + ]) + ) + Self.trigger -> localStep.trigger,success -> Self.success + localStep.finished --------> Self.finished + localStep.error -----------> Self.error +} + +treatment setupToolchain[logger: Logger](rust_target: string) + input trigger: Block + output success: Block + output finished: Block + output error: Block +{ + prepareSystem: localStep[logger=logger]( + name = |format("setupToolchain ({rust_target})", |entry("rust_target", rust_target)), + commands = |raw_commands([ + |format("mkdir /tmp/{rust_target}", |entry("rust_target", rust_target)), + |format("touch /tmp/{rust_target}/github.env", |entry("rust_target", rust_target)), + ${bash -c "curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/taiki-e/setup-cross-toolchain-action/refs/tags/v1/main.sh | bash -"}/*, + |format("cat /tmp/{rust_target}/github.env", |entry("rust_target", rust_target)) + ]), + variables = |wrap( + |map([ + |entry("INPUT_TARGET", rust_target), + |entry("GITHUB_ENV", |format("cat /tmp/{rust_target}/github.env", |entry("rust_target", short_rust_arch))) + ]) + ) + ) + Self.trigger -> prepareSystem.trigger,success -> Self.success + prepareSystem.finished --------> Self.finished + prepareSystem.error -----------> Self.error +} + +treatment prepareRust[logger: Logger](rust_target: string) + input trigger: Block + output success: Block + output finished: Block + output error: Block +{ + + localStep[logger=logger]( + name = |format("prepareRust ({arch})", |entry("arch", rust_target)), + commands = |raw_commands([ + |format("rustup target add {arch}", |entry("arch", rust_target)), + ${bash -c "curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash -"}, + "cargo binstall cargo-hack" + ]) + ) + Self.trigger -> localStep.trigger,success -> Self.success + localStep.finished --------> Self.finished + localStep.error -----------> Self.error +} \ No newline at end of file