diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63dbc309..4172fd9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,10 +23,21 @@ jobs: # secrets: # token: ${{ secrets.GITHUB_TOKEN }} buildTestAya: - uses: melodium-tech/github-actions/.github/workflows/melodium.yml@v0.9.1 + strategy: + fail-fast: false + matrix: + arch: + - aarch64-unknown-linux-gnu + - armv7-unknown-linux-gnueabi + - loongarch64-unknown-linux-gnu + - powerpc64le-unknown-linux-gnu + - riscv64gc-unknown-linux-gnu + - s390x-unknown-linux-gnu + - x86_64-unknown-linux-gnu + uses: melodium-tech/github-actions/.github/workflows/melodium-ubuntu.yml@v0.9.1 with: command: | - run .melodium-ci/Compo.toml buildTestAya --api_token='"${{ vars.CADENCE_TOKEN }}"' --repository_clone_url='"${{ github.repositoryUrl }}"' --repository_clone_ref='"${{ github.ref_name }}"' --github_contexts='$''{{{{ { "github": { "api_url": ${{ toJSON(github.api_url) }}, "repository": ${{ toJSON(github.repository) }}, "sha": ${{ toJSON(github.sha) }} }, "secrets": { "GITHUB_TOKEN": "'"$GITHUB_TOKEN"'" } } }}}}' + run .melodium-ci/Compo.toml buildTestAya --targets='[${{ toJSON( matrix.arch ) }}]' --repository_clone_url='"${{ github.repositoryUrl }}"' --repository_clone_ref='"${{ github.ref_name }}"' --github_contexts='$''{{{{ { "github": { "api_url": ${{ toJSON(github.api_url) }}, "repository": ${{ toJSON(github.repository) }}, "sha": ${{ toJSON(github.sha) }} }, "secrets": { "GITHUB_TOKEN": "'"$GITHUB_TOKEN"'" } } }}}}' artifact-path: 'logs/' artifact-name: 'mel_buildTestAya' secrets: diff --git a/.melodium-ci/Compo.toml b/.melodium-ci/Compo.toml index b2f46667..c8203d24 100644 --- a/.melodium-ci/Compo.toml +++ b/.melodium-ci/Compo.toml @@ -2,20 +2,19 @@ name = "ci" version = "0.1.0" [dependencies] -cicd = "^0.9.0" -distrib = "^0.9.0" -fs = "^0.9.0" -http = "^0.9.0" -javascript = "^0.9.0" -json = "^0.9.0" -log = "^0.9.0" -net = "^0.9.0" -process = "^0.9.0" -std = "^0.9.0" -work = "^0.9.0" +cicd = "^0.9.1" +distrib = "^0.9.1" +fs = "^0.9.1" +http = "^0.9.1" +javascript = "^0.9.1" +json = "^0.9.1" +log = "^0.9.1" +net = "^0.9.1" +process = "^0.9.1" +std = "^0.9.1" +work = "^0.9.1" [entrypoints] -buildTestAya = "ci::buildTestAya" -buildTestAyaDirect = "ci/on_image::buildTestAya" +buildTestAya = "ci/build_test_aya::buildTestAya" buildTestAyaEbpf = "ci::buildTestAyaEbpfEntrypoint" diff --git a/.melodium-ci/build_test_aya.mel b/.melodium-ci/build_test_aya.mel index dce3c9d5..a49e0429 100644 --- a/.melodium-ci/build_test_aya.mel +++ b/.melodium-ci/build_test_aya.mel @@ -1,8 +1,34 @@ +use cicd/logging::manageLogs +use cicd/naive::localStep +use cicd/services/github::prepareContexts +use cicd/services/github::postGithubStateContext +use cicd/services/github::|pending +use cicd/services/github::|success +use cicd/services/github::|error +use cicd/services/github::|failure +use javascript::JavaScriptEngine +use log/logger::Logger +use process/command::|command use root/prepare::checkout use root/prepare::setupToolchain use root/prepare::prepareRust +use std/data/string_map::StringMap +use std/data/string_map::|entry +use std/data/string_map::|map +use std/engine/util::startup +use std/flow::one +use std/flow::passBlock +use std/flow::uncheck +use std/flow::waitBlock +use std/flow::trigger +use std/flow/concentrate::Concentrator +use std/flow/concentrate::concentrateBlock +use std/flow/concentrate::concentrated +use std/ops/option::|wrap +use std/ops/vec::|contains +use std/text/compose::|format -treatment buildTestAyaForArch[logger: Logger, github_contexts: JavaScriptEngine, finish_concentrator: Concentrator](rust_target: string, repository_clone_url: string, repository_clone_ref: string) +treatment buildTestAyaForArch[logger: Logger, github_contexts: JavaScriptEngine, finish_concentrator: Concentrator](rust_target: string, repository_clone_url: string, repository_clone_ref: string, targets: Vec) input trigger: Block output finished: Block { @@ -18,11 +44,12 @@ treatment buildTestAyaForArch[logger: Logger, github_contexts: JavaScriptEngine, setupToolchain[logger=logger](rust_target=rust_target) prepareRust[logger=logger](rust_target=rust_target) + doRun: passBlock(cond=|contains(targets, 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 + Self.trigger -> doRun.block,passed -> prepareRust.trigger,success ----> rustReady.a + doRun.passed -------> setupToolchain.trigger,success -> rustReady.b,awaited -> projectReady.a + doRun.passed -------> checkout.trigger,success ------------------------------> projectReady.b,awaited -> run.trigger run: localStep[logger=logger]( name = |format("run ({rust_target})", |entry("rust_target", rust_target)), @@ -68,18 +95,17 @@ treatment buildTestAyaForArch[logger: Logger, github_contexts: JavaScriptEngine, --exclude xtask \\ --workspace "]) - ], - + ] ) - prepare.awaited -> build.trigger,finished -> Self.finished + run.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 + doRun.passed --> pendingState.trigger run.success ---> successState.trigger run.error -----> errorState.trigger @@ -88,3 +114,60 @@ treatment buildTestAyaForArch[logger: Logger, github_contexts: JavaScriptEngine, run.success -> uncheckSuccess.value,uncheck -> oneFailure.a run.failed ----------------------------------> oneFailure.b,value -> failureState.trigger } + +treatment buildTestAya(const github_contexts: string = "{}", targets: Vec, repository_clone_url: string, repository_clone_ref: string) + model logger: Logger() + model finish_concentrator: Concentrator() + model github_contexts: JavaScriptEngine() +{ + startup() + prepareContexts[contexts=github_contexts](github_contexts=github_contexts) + manageLogs[logger=logger](output_directory="logs/") + concentratedFinish: concentrated[concentrator=finish_concentrator]() + triggerFinish: trigger() + startup.trigger -> prepareContexts.trigger,ready -> concentratedFinish.trigger,data -> triggerFinish.stream,end -> manageLogs.stop + + build_aarch64: buildTestAyaForArch[logger=logger, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( + targets=targets, + rust_target="aarch64-unknown-linux-gnu", + repository_clone_ref=repository_clone_ref, + repository_clone_url=repository_clone_url + ) + build_armv7: buildTestAyaForArch[logger=logger, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( + targets=targets, + rust_target="armv7-unknown-linux-gnueabi", + repository_clone_ref=repository_clone_ref, + repository_clone_url=repository_clone_url + ) + build_powerpc64le: buildTestAyaForArch[logger=logger, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( + targets=targets, + rust_target="powerpc64le-unknown-linux-gnu", + repository_clone_ref=repository_clone_ref, + repository_clone_url=repository_clone_url + ) + build_riscv64gc: buildTestAyaForArch[logger=logger, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( + targets=targets, + rust_target="riscv64gc-unknown-linux-gnu", + repository_clone_ref=repository_clone_ref, + repository_clone_url=repository_clone_url + ) + build_s390x: buildTestAyaForArch[logger=logger, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( + targets=targets, + rust_target="s390x-unknown-linux-gnu", + repository_clone_ref=repository_clone_ref, + repository_clone_url=repository_clone_url + ) + build_x86_64: buildTestAyaForArch[logger=logger, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( + targets=targets, + rust_target="x86_64-unknown-linux-gnu", + repository_clone_ref=repository_clone_ref, + repository_clone_url=repository_clone_url + ) + + prepareContexts.ready -> build_aarch64.trigger + prepareContexts.ready -> build_armv7.trigger + prepareContexts.ready -> build_powerpc64le.trigger + prepareContexts.ready -> build_riscv64gc.trigger + prepareContexts.ready -> build_s390x.trigger + prepareContexts.ready -> build_x86_64.trigger +} diff --git a/.melodium-ci/on_image.mel b/.melodium-ci/on_image.mel deleted file mode 100644 index 3824efcf..00000000 --- a/.melodium-ci/on_image.mel +++ /dev/null @@ -1,156 +0,0 @@ -use cicd/logging::manageLogs -use cicd/services/github::prepareContexts -use cicd/services/github::postGithubStateContext -use cicd/services/github::|pending -use cicd/services/github::|success -use cicd/services/github::|error -use cicd/services/github::|failure -use cicd/naive::localStep -use log/logger::Logger -use javascript::JavaScriptEngine -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/engine/util::startup -use std/flow::waitBlock -use std/flow::trigger -use std/flow/concentrate::Concentrator -use std/flow/concentrate::concentrateBlock -use std/flow/concentrate::concentrated -use std/ops/option::|wrap -use std/text/compose::|format - -treatment buildTestAya(const github_contexts: string = "{}") - model logger: Logger() - model finish_concentrator: Concentrator() - model github_contexts: JavaScriptEngine() -{ - startup() - prepareContexts[contexts=github_contexts](github_contexts=github_contexts) - manageLogs[logger=logger](output_directory="logs/") - concentratedFinish: concentrated[concentrator=finish_concentrator]() - triggerFinish: trigger() - startup.trigger -> prepareContexts.trigger,ready -> concentratedFinish.trigger,data -> triggerFinish.stream,end -> manageLogs.stop - - build_aarch64: buildTestAyaForArch[logger=logger, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( - short_rust_arch="aarch64", - full_rust_arch="aarch64-unknown-linux-gnu", - ubuntu_arch="arm64" - ) - /*build_armv7: buildTestAyaForArch[logger=logger, dispatcher=dispatcher, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( - short_rust_arch="armv7", - full_rust_arch="armv7-unknown-linux-gnueabi", - ubuntu_arch="armhf", - repository_clone_ref=repository_clone_ref, - repository_clone_url=repository_clone_url - ) - build_powerpc64le: buildTestAyaForArch[logger=logger, dispatcher=dispatcher, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( - short_rust_arch="powerpc64le", - full_rust_arch="powerpc64le-unknown-linux-gnu", - ubuntu_arch="ppc64le", - repository_clone_ref=repository_clone_ref, - repository_clone_url=repository_clone_url - ) - build_riscv64gc: buildTestAyaForArch[logger=logger, dispatcher=dispatcher, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( - short_rust_arch="riscv64gc", - full_rust_arch="riscv64gc-unknown-linux-gnu", - ubuntu_arch="riscv64", - repository_clone_ref=repository_clone_ref, - repository_clone_url=repository_clone_url - ) - build_s390x: buildTestAyaForArch[logger=logger, dispatcher=dispatcher, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( - short_rust_arch="s390x", - full_rust_arch="s390x-unknown-linux-gnu", - ubuntu_arch="s390x", - repository_clone_ref=repository_clone_ref, - repository_clone_url=repository_clone_url - ) - build_x86_64: buildTestAyaForArch[logger=logger, dispatcher=dispatcher, github_contexts=github_contexts, finish_concentrator=finish_concentrator]( - short_rust_arch="x86_64", - full_rust_arch="x86_64-unknown-linux-gnu", - ubuntu_arch="amd64", - repository_clone_ref=repository_clone_ref, - repository_clone_url=repository_clone_url - )*/ - - prepareContexts.ready -> build_aarch64.trigger - /*prepareContexts.ready -> build_armv7.trigger - prepareContexts.ready -> build_powerpc64le.trigger - prepareContexts.ready -> build_riscv64gc.trigger - prepareContexts.ready -> build_s390x.trigger - prepareContexts.ready -> build_x86_64.trigger*/ -} - -treatment buildTestAyaForArch[logger: Logger, github_contexts: JavaScriptEngine, finish_concentrator: Concentrator](short_rust_arch: string, full_rust_arch: string, ubuntu_arch: string) - input trigger: Block - output finished: Block -{ - concentrateFinish: concentrateBlock[concentrator=finish_concentrator]() - build.finished -> concentrateFinish.data - - prepareSystem: localStep[logger=logger]( - name = |format("prepare_system_{short}", |entry("short", short_rust_arch)), - commands = |raw_commands([ - //|format("mkdir /tmp/{short}", |entry("short", short_rust_arch)), - //|format("touch /tmp/{short}/github.env", |entry("short", short_rust_arch)), - ${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/{short}/github.env", |entry("short", short_rust_arch))*/ - ]), - variables = |wrap( - |map([ - |entry("INPUT_TARGET", full_rust_arch)/*, - |entry("GITHUB_ENV", |format("cat /tmp/{short}/github.env", |entry("short", short_rust_arch)))*/ - ]) - ) - ) - - prepareRust: localStep[logger=logger]( - name = |format("prepare_rust_{short}", |entry("short", short_rust_arch)), - commands = |raw_commands([ - |format("rustup target add {arch}", |entry("arch", full_rust_arch)), - ${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" - ]) - ) - - prepare: waitBlock() - Self.trigger -> prepareSystem.trigger,success -> prepare.a - Self.trigger -> prepareRust.trigger,success ---> prepare.b - - build: localStep[logger=logger]( - name = |format("build_{short}", |entry("short", short_rust_arch)), - commands = |raw_commands([ - // Build - ${bash -c "set -o allexport && source $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 - ${bash -c "set -o allexport && source $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 - ${bash -c "set -o allexport && source $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" - } - ]), - variables = |wrap( - |map([ - |entry("RUST_BACKTRACE", "full"), - |entry("CARGO_BUILD_TARGET", full_rust_arch) - ]) - ) - ) - - prepare.awaited -> build.trigger,finished -> Self.finished - - pendingState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |pending(), name = short_rust_arch, description = "Build and Test Aya on arch", log_response = true) - successState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |success(), name = short_rust_arch, description = "Build and Test Aya on arch", log_response = true) - errorState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |error(), name = short_rust_arch, description = "Build and Test Aya on arch", log_response = true) - failureState: postGithubStateContext[contexts=github_contexts, logger=logger](state = |failure(), name = short_rust_arch, description = "Build and Test Aya on arch", log_response = true) - - Self.trigger --> pendingState.trigger - build.success -> successState.trigger - build.error ---> errorState.trigger - build.failed --> failureState.trigger -} diff --git a/.melodium-ci/prepare.mel b/.melodium-ci/prepare.mel index da47b926..e10aeb46 100644 --- a/.melodium-ci/prepare.mel +++ b/.melodium-ci/prepare.mel @@ -4,6 +4,7 @@ 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/ops/option::|wrap use std/text/compose::|format treatment checkout[logger: Logger](label: string, repository_clone_url: string, repository_clone_ref: string, clone_directory: string) @@ -41,13 +42,13 @@ treatment setupToolchain[logger: Logger](rust_target: string) 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 -"}/*, + ${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))) + |entry("GITHUB_ENV", |format("cat /tmp/{rust_target}/github.env", |entry("rust_target", rust_target))) ]) ) )