From cc1425e8aef7937ce5118195a63687b0ddfd5690 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Thu, 9 Nov 2023 13:58:50 +0100 Subject: [PATCH] ci: add benchmark tests --- .gitlab-ci.yml | 15 +++++++++++++++ docker/Dockerfile | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e1f503d5..f6ecf3597 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -116,6 +116,21 @@ build_release: IMAGE_TAG: "sha-$CI_COMMIT_SHORT_SHA" PODMAN_BUILD_OPTIONS: "--platform linux/amd64" +run_benchmarks: + stage: tests + extends: .docker_build + rules: + - if: $CI_COMMIT_REF_NAME =~ /^wip*$/ + when: manual + - if: $CI_COMMIT_TAG + when: never + - if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"' + - when: manual + variables: + IMAGE_NAME: "duniter/duniter-v2s-test" + IMAGE_TAG: "debug-sha-$CI_COMMIT_SHORT_SHA" + PODMAN_BUILD_OPTIONS: "--target build --build-arg benchmarks=1" + test_debug: stage: tests extends: .docker_build diff --git a/docker/Dockerfile b/docker/Dockerfile index 7b3e0dd7c..ea1cdd1b1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -33,6 +33,11 @@ RUN if [ "$debug" = 0 ]; then \ echo "TARGET_FOLDER=debug" >>/root/dynenv; \ fi +ARG benchmarks=0 +RUN if [ "$benchmarks" != 0 ]; then \ + echo "BENCH_OPTIONS=--features\ runtime-benchmarks" >>/root/dynenv; \ + fi + # Configure cross-build environment if need be RUN set -x && \ if [ "$TARGETPLATFORM" != "$BUILDPLATFORM" ]; then \ @@ -47,14 +52,14 @@ RUN set -x && \ RUN set -x && \ cat /root/dynenv && \ . /root/dynenv && \ - cargo build --locked $CARGO_OPTIONS --target "$RUST_ARCH_TRIPLET" && \ + cargo build --locked $CARGO_OPTIONS $BENCH_OPTIONS --target "$RUST_ARCH_TRIPLET" && \ mkdir -p build && \ mv target/$RUST_ARCH_TRIPLET/$TARGET_FOLDER/duniter build/ # Run tests if requested, expted when cross-building ARG cucumber=0 RUN if [ "$cucumber" != 0 ] && [ "$TARGETPLATFORM" = "$BUILDPLATFORM" ]; then \ - cargo test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests && \ + cargo test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests --features runtime-benchmarks && \ cargo cucumber -i account_creation* && \ cargo cucumber -i certification* && \ cargo cucumber -i identity_creation* && \ @@ -66,6 +71,11 @@ RUN if [ "$cucumber" != 0 ] && [ "$TARGETPLATFORM" = "$BUILDPLATFORM" ]; then \ mv cucumber_tests* ../../../build/duniter-cucumber; \ fi +# Run runtime benchmarks +RUN if [ "$benchmarks" != 0 ]; then \ + build/duniter benchmark pallet --chain dev --execution=wasm --wasm-execution=compiled --pallet "*" --extrinsic "*" --steps 2 --repeat 1; \ + fi + # ------------------------------------------------------------------------------ # Final Stage # ------------------------------------------------------------------------------ -- GitLab