From 91971676f1f4591908f977ee3976a41f4bddc2a9 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Thu, 18 Jan 2024 13:12:16 +0100 Subject: [PATCH 01/10] CI: remove coverage, artifacts, retry from [oc.unit:protocol_compiles] This job does not need coverage instrumentation, nor does it need to store any artifacts. It is not flaky and should not have retry. --- .gitlab/ci/jobs/test/oc.unit.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/jobs/test/oc.unit.yml b/.gitlab/ci/jobs/test/oc.unit.yml index cd3a5fd4a48c..76ddfd14f1b2 100644 --- a/.gitlab/ci/jobs/test/oc.unit.yml +++ b/.gitlab/ci/jobs/test/oc.unit.yml @@ -128,6 +128,16 @@ oc.unit:js_components: - make test-js oc.unit:protocol_compiles: - extends: .oc.unit_test_template_x86_64 + extends: + - .default_settings_template + - .image_template__runtime_build_dependencies + - .rules__octez_changes + stage: test + needs: + - "oc.build_x86_64-released" + - "oc.build_x86_64-exp-dev-extra" + before_script: + - . ./scripts/version.sh + - eval $(opam env) script: - dune build @runtest_compile_protocol -- GitLab From 6d20dd22e072b02ee4346f86852d68dd3d305806 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Thu, 18 Jan 2024 13:16:17 +0100 Subject: [PATCH 02/10] CI: remove coverage, artifacts from [oc.unit:js_components] This job does not need coverage instrumentation, nor does it need to store any artifacts. --- .gitlab/ci/jobs/test/oc.unit.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/jobs/test/oc.unit.yml b/.gitlab/ci/jobs/test/oc.unit.yml index 76ddfd14f1b2..d22dc5465393 100644 --- a/.gitlab/ci/jobs/test/oc.unit.yml +++ b/.gitlab/ci/jobs/test/oc.unit.yml @@ -112,8 +112,15 @@ oc.unit:webassembly-x86_64: oc.unit:js_components: extends: - - .oc.unit_test_template_x86_64 + - .default_settings_template - .image_template__runtime_build_test_dependencies + - .rules__octez_changes + stage: test + needs: + - "oc.build_x86_64-released" + - "oc.build_x86_64-exp-dev-extra" + # This is known to have been flaky + retry: 2 variables: # See `.gitlab-ci.yml` for details on `RUNTEZTALIAS` RUNTEZTALIAS: "true" -- GitLab From cb5688f26e105cfe913b772ed4f69ccf0a0127f2 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Thu, 18 Jan 2024 13:33:57 +0100 Subject: [PATCH 03/10] CI: remove coverage, artifacts from [oc.unit:webassembly-x86_64] This job does not need coverage instrumentation, nor does it need to store any artifacts. --- .gitlab/ci/jobs/test/oc.unit.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitlab/ci/jobs/test/oc.unit.yml b/.gitlab/ci/jobs/test/oc.unit.yml index d22dc5465393..acf32b780856 100644 --- a/.gitlab/ci/jobs/test/oc.unit.yml +++ b/.gitlab/ci/jobs/test/oc.unit.yml @@ -98,17 +98,25 @@ oc.unit:non-proto-arm64: oc.unit:webassembly-x86_64: extends: - - .oc.unit_test_template_x86_64 + - .default_settings_template # The wasm tests are written in Python - .image_template__runtime_build_test_dependencies - variables: - MAKE_TARGETS: test-webassembly + - .rules__octez_changes + needs: + - "oc.build_x86_64-released" + - "oc.build_x86_64-exp-dev-extra" + stage: test # TODO: https://gitlab.com/tezos/tezos/-/issues/4663 # This test takes around 2 to 4min to complete, but it sometimes # hangs. We use a timeout to retry the test in this case. The # underlying issue should be fixed eventually, turning this timeout # unnecessary. timeout: 20 minutes + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make test-webassembly oc.unit:js_components: extends: -- GitLab From 98804d4b44d2c300d228d8b13e593024bf1f0633 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Mon, 4 Mar 2024 13:33:51 +0100 Subject: [PATCH 04/10] CI: refactor, consistent rules for schedule: [install_octez, oc.unit] To check whether we're in the schedule exteded tests pipeline we should always check _both_ [CI_PIPELINE_SOURCE] and [TZ_SCHEDULE_KIND]. --- .gitlab/ci/jobs/test/install_octez.yml | 2 +- .gitlab/ci/jobs/test/oc.unit.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/jobs/test/install_octez.yml b/.gitlab/ci/jobs/test/install_octez.yml index 3a23fe1541fb..b9564a242e27 100644 --- a/.gitlab/ci/jobs/test/install_octez.yml +++ b/.gitlab/ci/jobs/test/install_octez.yml @@ -88,7 +88,7 @@ oc.install_bin_rc_fedora_37: script: - ./docs/introduction/install-opam.sh rules: - - if: $CI_PIPELINE_SOURCE == "schedule" + - if: $CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS" when: always allow_failure: true # temporarily disable until these jobs are optimized diff --git a/.gitlab/ci/jobs/test/oc.unit.yml b/.gitlab/ci/jobs/test/oc.unit.yml index acf32b780856..b02d8297ace3 100644 --- a/.gitlab/ci/jobs/test/oc.unit.yml +++ b/.gitlab/ci/jobs/test/oc.unit.yml @@ -58,7 +58,7 @@ # [when: manual] since if the build jobs were manual and # triggered, then there is no point in having the user do another # manual action to also run the tests. - - if: $CI_PIPELINE_SOURCE == "schedule" + - if: $CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS" when: always - changes: - src/**/* -- GitLab From 95e28407bbe0b79f0e20afe358be6387a8d7a065 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Thu, 21 Mar 2024 15:07:49 +0100 Subject: [PATCH 05/10] CIAO: add [arch_to_string] and [arch_to_string_alt] --- ci/bin/common.ml | 8 ++++---- ci/bin/tezos_ci.ml | 4 ++++ ci/bin/tezos_ci.mli | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ci/bin/common.ml b/ci/bin/common.ml index 61a7c498bd92..48af173e057c 100644 --- a/ci/bin/common.ml +++ b/ci/bin/common.ml @@ -419,7 +419,7 @@ let job_docker_authenticated ?(skip_docker_initialization = false) (they do not build experimental executables) *) let job_build_static_binaries ~__POS__ ~arch ?(release = false) ?rules ?dependencies () : tezos_job = - let arch_string = match arch with Amd64 -> "x86_64" | Arm64 -> "arm64" in + let arch_string = arch_to_string arch in let name = "oc.build:static-" ^ arch_string ^ "-linux-binaries" in let artifacts = (* Extend the lifespan to prevent failure for external tools using artifacts. *) @@ -486,7 +486,7 @@ type docker_build_type = Experimental | Release | Test | Test_manual also written to an external file. *) let job_docker_build ?rules ?dependencies ~__POS__ ~arch ?(external_ = false) docker_build_type : tezos_job = - let arch_string = match arch with Amd64 -> "amd64" | Arm64 -> "arm64" in + let arch_string = arch_to_string_alt arch in let ci_docker_hub = match docker_build_type with | Release | Experimental -> true @@ -558,7 +558,7 @@ type bin_package_target = Dpkg | Rpm let job_build_bin_package ?rules ~__POS__ ~name ?(stage = Stages.build) ~arch ~target () : tezos_job = - let arch_string = match arch with Amd64 -> "amd64" | Arm64 -> "arm64" in + let arch_string = arch_to_string_alt arch in let target_string = match target with Dpkg -> "dpkg" | Rpm -> "rpm" in let image = match target with Dpkg -> Images.debian_bookworm | Rpm -> Images.fedora_39 @@ -645,7 +645,7 @@ let job_build_rpm_amd64 : unit -> tezos_job = let job_build_dynamic_binaries ?rules ~__POS__ ~arch ?(release = false) ?dependencies () = - let arch_string = match arch with Amd64 -> "x86_64" | Arm64 -> "arm64" in + let arch_string = arch_to_string arch in let name = sf "oc.build_%s-%s" diff --git a/ci/bin/tezos_ci.ml b/ci/bin/tezos_ci.ml index a46f87b28de9..a6e9f940a8b9 100644 --- a/ci/bin/tezos_ci.ml +++ b/ci/bin/tezos_ci.ml @@ -281,6 +281,10 @@ end type arch = Amd64 | Arm64 +let arch_to_string = function Amd64 -> "x86_64" | Arm64 -> "arm64" + +let arch_to_string_alt = function Amd64 -> "amd64" | Arm64 -> "arm64" + type dependency = | Job of tezos_job | Optional of tezos_job diff --git a/ci/bin/tezos_ci.mli b/ci/bin/tezos_ci.mli index c5e365c0db7e..f982ce15aa85 100644 --- a/ci/bin/tezos_ci.mli +++ b/ci/bin/tezos_ci.mli @@ -130,6 +130,12 @@ end (** Represents architectures. *) type arch = Amd64 | Arm64 +(** String representation of architectures ([Amd64] is ["x86_64"]) *) +val arch_to_string : arch -> string + +(** Alternative string representation of architectures ([Amd64] is ["amd64"]) *) +val arch_to_string_alt : arch -> string + (** A job dependency. - A job that depends on [Job j] will not start until [j] finishes. -- GitLab From 0dba99d8eaf838381829194999eac2721cd4cac4 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Fri, 15 Mar 2024 17:37:29 +0100 Subject: [PATCH 06/10] CI: generate [oc.unit] --- .../ci/jobs/test/oc.unit-before_merging.yml | 243 ++++++++++++++++ .../test/oc.unit-scheduled_extended_test.yml | 243 ++++++++++++++++ .gitlab/ci/jobs/test/oc.unit.yml | 158 ----------- .gitlab/ci/pipelines/before_merging.yml | 2 +- .../ci/pipelines/schedule_extended_test.yml | 2 +- ci/bin/code_verification.ml | 259 +++++++++++++++--- ci/bin/common.ml | 14 + ci/bin/main.ml | 1 - 8 files changed, 727 insertions(+), 195 deletions(-) create mode 100644 .gitlab/ci/jobs/test/oc.unit-before_merging.yml create mode 100644 .gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml delete mode 100644 .gitlab/ci/jobs/test/oc.unit.yml diff --git a/.gitlab/ci/jobs/test/oc.unit-before_merging.yml b/.gitlab/ci/jobs/test/oc.unit-before_merging.yml new file mode 100644 index 000000000000..274b0bee162d --- /dev/null +++ b/.gitlab/ci/jobs/test/oc.unit-before_merging.yml @@ -0,0 +1,243 @@ +# This file was automatically generated, do not edit. +# Edit file ci/bin/main.ml instead. + +oc.unit:non-proto-x86_64: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + - ./scripts/ci/merge_coverage.sh + variables: + ARCH: x86_64 + MAKE_TARGETS: test-nonproto-unit + COVERAGE_OPTIONS: --instrument-with bisect_ppx + BISECT_FILE: $CI_PROJECT_DIR/_coverage_output/ + artifacts: + name: coverage-files-$CI_JOB_ID + expire_in: 1 day + paths: + - test_results + - $BISECT_FILE + reports: + junit: test_results/*.xml + when: always + retry: 2 + +oc.unit:other-x86_64: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + - ./scripts/ci/merge_coverage.sh + variables: + ARCH: x86_64 + MAKE_TARGETS: test-other-unit + COVERAGE_OPTIONS: --instrument-with bisect_ppx + BISECT_FILE: $CI_PROJECT_DIR/_coverage_output/ + artifacts: + name: coverage-files-$CI_JOB_ID + expire_in: 1 day + paths: + - test_results + - $BISECT_FILE + reports: + junit: test_results/*.xml + when: always + retry: 2 + +oc.unit:proto-x86_64: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + - ./scripts/ci/merge_coverage.sh + variables: + ARCH: x86_64 + MAKE_TARGETS: test-proto-unit + COVERAGE_OPTIONS: --instrument-with bisect_ppx + BISECT_FILE: $CI_PROJECT_DIR/_coverage_output/ + artifacts: + name: coverage-files-$CI_JOB_ID + expire_in: 1 day + paths: + - test_results + - $BISECT_FILE + reports: + junit: test_results/*.xml + when: always + retry: 2 + +oc.unit:non-proto-arm64: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp_arm64 + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS" + when: always + - changes: + - src/**/* + - .gitlab/**/* + - .gitlab-ci.yml + when: on_success + needs: + - oc.build_arm64-released + - oc.build_arm64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + variables: + ARCH: arm64 + MAKE_TARGETS: test-nonproto-unit test-webassembly + DISTRIBUTE_TESTS_TO_PARALLELS: "true" + artifacts: + name: $CI_JOB_NAME-$CI_COMMIT_SHA-${ARCH} + expire_in: 1 day + paths: + - test_results + reports: + junit: test_results/*.xml + when: always + retry: 2 + parallel: 2 + +oc.unit:webassembly-x86_64: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + timeout: 20 minutes + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make test-webassembly + +oc.unit:js_components: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - ./scripts/ci/take_ownership.sh + - . ./scripts/version.sh + - eval $(opam env) + - . ./scripts/install_build_deps.js.sh + script: + - make test-js + variables: + RUNTEZTALIAS: "true" + retry: 2 + +oc.unit:protocol_compiles: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - dune build @runtest_compile_protocol diff --git a/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml b/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml new file mode 100644 index 000000000000..274b0bee162d --- /dev/null +++ b/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml @@ -0,0 +1,243 @@ +# This file was automatically generated, do not edit. +# Edit file ci/bin/main.ml instead. + +oc.unit:non-proto-x86_64: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + - ./scripts/ci/merge_coverage.sh + variables: + ARCH: x86_64 + MAKE_TARGETS: test-nonproto-unit + COVERAGE_OPTIONS: --instrument-with bisect_ppx + BISECT_FILE: $CI_PROJECT_DIR/_coverage_output/ + artifacts: + name: coverage-files-$CI_JOB_ID + expire_in: 1 day + paths: + - test_results + - $BISECT_FILE + reports: + junit: test_results/*.xml + when: always + retry: 2 + +oc.unit:other-x86_64: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + - ./scripts/ci/merge_coverage.sh + variables: + ARCH: x86_64 + MAKE_TARGETS: test-other-unit + COVERAGE_OPTIONS: --instrument-with bisect_ppx + BISECT_FILE: $CI_PROJECT_DIR/_coverage_output/ + artifacts: + name: coverage-files-$CI_JOB_ID + expire_in: 1 day + paths: + - test_results + - $BISECT_FILE + reports: + junit: test_results/*.xml + when: always + retry: 2 + +oc.unit:proto-x86_64: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + - ./scripts/ci/merge_coverage.sh + variables: + ARCH: x86_64 + MAKE_TARGETS: test-proto-unit + COVERAGE_OPTIONS: --instrument-with bisect_ppx + BISECT_FILE: $CI_PROJECT_DIR/_coverage_output/ + artifacts: + name: coverage-files-$CI_JOB_ID + expire_in: 1 day + paths: + - test_results + - $BISECT_FILE + reports: + junit: test_results/*.xml + when: always + retry: 2 + +oc.unit:non-proto-arm64: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp_arm64 + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS" + when: always + - changes: + - src/**/* + - .gitlab/**/* + - .gitlab-ci.yml + when: on_success + needs: + - oc.build_arm64-released + - oc.build_arm64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make $MAKE_TARGETS + variables: + ARCH: arm64 + MAKE_TARGETS: test-nonproto-unit test-webassembly + DISTRIBUTE_TESTS_TO_PARALLELS: "true" + artifacts: + name: $CI_JOB_NAME-$CI_COMMIT_SHA-${ARCH} + expire_in: 1 day + paths: + - test_results + reports: + junit: test_results/*.xml + when: always + retry: 2 + parallel: 2 + +oc.unit:webassembly-x86_64: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + timeout: 20 minutes + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - make test-webassembly + +oc.unit:js_components: + image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - ./scripts/ci/take_ownership.sh + - . ./scripts/version.sh + - eval $(opam env) + - . ./scripts/install_build_deps.js.sh + script: + - make test-js + variables: + RUNTEZTALIAS: "true" + retry: 2 + +oc.unit:protocol_compiles: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - dune build @runtest_compile_protocol diff --git a/.gitlab/ci/jobs/test/oc.unit.yml b/.gitlab/ci/jobs/test/oc.unit.yml deleted file mode 100644 index b02d8297ace3..000000000000 --- a/.gitlab/ci/jobs/test/oc.unit.yml +++ /dev/null @@ -1,158 +0,0 @@ -.oc.unit_test_template: - extends: - - .test_template - - .rules__octez_changes - - .oc.template__retry_flaky - variables: - ARCH: "" - MAKE_TARGETS: "" - script: - - make $MAKE_TARGETS - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_SHA-${ARCH}" - paths: - - test_results - reports: - junit: test_results/*.xml - expire_in: 1 day - when: always - -.oc.unit_test_template_x86_64: - extends: .oc.unit_test_template - variables: - ARCH: "x86_64" - -.oc.unit_test_template_x86_64_coverage: - extends: - - .oc.unit_test_template_x86_64 - # Enable coverage instrumentation, enable coverage trace output - # and store it in artifacts. - - .oc.template__coverage_instrumentation - - .oc.template__coverage_output_artifact - script: - - make $MAKE_TARGETS - - ./scripts/ci/merge_coverage.sh - # Merge the [artifacts:] definition of [.oc.unit_test_template] and - # of [.oc.template__coverage_output_artifact]. - artifacts: - when: always - paths: - - $BISECT_FILE - - test_results - -.oc.unit_test_template_arm64: - extends: - - .oc.unit_test_template - - .tags_template__build_arm64 - needs: - - "oc.build_arm64-released" - - "oc.build_arm64-exp-dev-extra" - variables: - ARCH: "arm64" - rules: - # These rules are implied by the rules for the [oc.build_arm64-*] - # jobs (through [needs:]), as such the build jobs always run if - # the test jobs are included. Conversely, we want to run the test - # jobs whenever the build jobs are included, so we have mostly - # have the same rules here, except that we do not make the jobs - # [when: manual] since if the build jobs were manual and - # triggered, then there is no point in having the user do another - # manual action to also run the tests. - - if: $CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS" - when: always - - changes: - - src/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - -oc.unit:non-proto-x86_64: - extends: - - .oc.unit_test_template_x86_64_coverage - # The [lib_benchmark] unit tests require Python - - .image_template__runtime_build_test_dependencies - variables: - MAKE_TARGETS: test-nonproto-unit - -oc.unit:other-x86_64: - extends: - - .oc.unit_test_template_x86_64_coverage - variables: - MAKE_TARGETS: test-other-unit - -oc.unit:proto-x86_64: - extends: - - .oc.unit_test_template_x86_64_coverage - variables: - MAKE_TARGETS: test-proto-unit - -oc.unit:non-proto-arm64: - extends: - - .oc.unit_test_template_arm64 - # The [lib_benchmark] unit tests require Python - - .image_template__runtime_build_test_dependencies - variables: - MAKE_TARGETS: test-nonproto-unit test-webassembly - DISTRIBUTE_TESTS_TO_PARALLELS: "true" - parallel: 2 - -oc.unit:webassembly-x86_64: - extends: - - .default_settings_template - # The wasm tests are written in Python - - .image_template__runtime_build_test_dependencies - - .rules__octez_changes - needs: - - "oc.build_x86_64-released" - - "oc.build_x86_64-exp-dev-extra" - stage: test - # TODO: https://gitlab.com/tezos/tezos/-/issues/4663 - # This test takes around 2 to 4min to complete, but it sometimes - # hangs. We use a timeout to retry the test in this case. The - # underlying issue should be fixed eventually, turning this timeout - # unnecessary. - timeout: 20 minutes - before_script: - - . ./scripts/version.sh - - eval $(opam env) - script: - - make test-webassembly - -oc.unit:js_components: - extends: - - .default_settings_template - - .image_template__runtime_build_test_dependencies - - .rules__octez_changes - stage: test - needs: - - "oc.build_x86_64-released" - - "oc.build_x86_64-exp-dev-extra" - # This is known to have been flaky - retry: 2 - variables: - # See `.gitlab-ci.yml` for details on `RUNTEZTALIAS` - RUNTEZTALIAS: "true" - # Note: this overrides the `before_script` inherited from - # `.test_template` to add `take_ownership.sh`. - before_script: - - ./scripts/ci/take_ownership.sh - - . ./scripts/version.sh - - eval $(opam env) - - . ./scripts/install_build_deps.js.sh - script: - - make test-js - -oc.unit:protocol_compiles: - extends: - - .default_settings_template - - .image_template__runtime_build_dependencies - - .rules__octez_changes - stage: test - needs: - - "oc.build_x86_64-released" - - "oc.build_x86_64-exp-dev-extra" - before_script: - - . ./scripts/version.sh - - eval $(opam env) - script: - - dune build @runtest_compile_protocol diff --git a/.gitlab/ci/pipelines/before_merging.yml b/.gitlab/ci/pipelines/before_merging.yml index 21e5caf41c29..8bf1089c5220 100644 --- a/.gitlab/ci/pipelines/before_merging.yml +++ b/.gitlab/ci/pipelines/before_merging.yml @@ -37,7 +37,7 @@ include: - .gitlab/ci/jobs/test/misc_opam_checks-before_merging.yml - .gitlab/ci/jobs/test/commit_titles.yml - .gitlab/ci/jobs/test/oc.semgrep-before_merging.yml - - .gitlab/ci/jobs/test/oc.unit.yml + - .gitlab/ci/jobs/test/oc.unit-before_merging.yml - .gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml - .gitlab/ci/jobs/test/oc.script:snapshot_alpha_and_link.yml - .gitlab/ci/jobs/test/oc.script:test-gen-genesis.yml diff --git a/.gitlab/ci/pipelines/schedule_extended_test.yml b/.gitlab/ci/pipelines/schedule_extended_test.yml index 2e4748ef15f6..202e749d9fc3 100644 --- a/.gitlab/ci/pipelines/schedule_extended_test.yml +++ b/.gitlab/ci/pipelines/schedule_extended_test.yml @@ -43,7 +43,7 @@ include: - .gitlab/ci/jobs/test/oc.misc_checks-scheduled_extended_test.yml - .gitlab/ci/jobs/test/misc_opam_checks-scheduled_extended_test.yml - .gitlab/ci/jobs/test/oc.semgrep-scheduled_extended_test.yml - - .gitlab/ci/jobs/test/oc.unit.yml + - .gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml - .gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml - .gitlab/ci/jobs/test/oc.script:snapshot_alpha_and_link.yml - .gitlab/ci/jobs/test/oc.script:test-gen-genesis.yml diff --git a/ci/bin/code_verification.ml b/ci/bin/code_verification.ml index d9c7a7e57658..019c9c8e4f05 100644 --- a/ci/bin/code_verification.ml +++ b/ci/bin/code_verification.ml @@ -139,6 +139,176 @@ let read_opam_packages = Some {name; group; batch_index} | _ -> fail () +let changeset_unit_test_arm64 = ["src/**/*"; ".gitlab/**/*"; ".gitlab-ci.yml"] + +let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra + ~job_build_arm64_release ~job_build_arm64_exp_dev_extra : tezos_job list = + let build_dependencies = function + | Amd64 -> + Dependent + [Job job_build_x86_64_release; Job job_build_x86_64_exp_dev_extra] + | Arm64 -> + Dependent + [Job job_build_arm64_release; Job job_build_arm64_exp_dev_extra] + in + let job_unit_test ~__POS__ ?(image = Images.runtime_build_dependencies) + ?timeout ?parallel_vector ~arch ~name ?(enable_coverage = true) + ?(rules = [job_rule ~changes:changeset_octez ()]) ~make_targets () : + tezos_job = + let arch_string = arch_to_string arch in + let script = + ["make $MAKE_TARGETS"] + @ if enable_coverage then ["./scripts/ci/merge_coverage.sh"] else [] + in + let dependencies = build_dependencies arch in + let variables = + [("ARCH", arch_string); ("MAKE_TARGETS", String.concat " " make_targets)] + in + + let variables, parallel = + (* When parallel_vector is set to non-zero (translating to the + [parallel_vector:] clause), set the variable + [DISTRIBUTE_TESTS_TO_PARALLELS] to [true], so that + [scripts/test_wrapper.sh] partitions the set of @runtest + targets to build. *) + match parallel_vector with + | Some n -> + ( variables @ [("DISTRIBUTE_TESTS_TO_PARALLELS", "true")], + Some (Vector n) ) + | None -> (variables, None) + in + let job = + job + ?timeout + ?parallel + ~__POS__ + ~retry:2 + ~name + ~stage:Stages.test + ~image + ~arch + ~dependencies + ~rules + ~variables + ~artifacts: + (artifacts + ~name:"$CI_JOB_NAME-$CI_COMMIT_SHA-${ARCH}" + ["test_results"] + ~reports:(reports ~junit:"test_results/*.xml" ()) + ~expire_in:(Days 1) + ~when_:Always) + ~before_script:(before_script ~source_version:true ~eval_opam:true []) + script + in + if enable_coverage then + job |> enable_coverage_instrumentation |> enable_coverage_output_artifact + else job + in + let oc_unit_non_proto_x86_64 = + job_unit_test + ~__POS__ + ~name:"oc.unit:non-proto-x86_64" + ~arch:Amd64 (* The [lib_benchmark] unit tests require Python *) + ~image:Images.runtime_build_test_dependencies + ~make_targets:["test-nonproto-unit"] + () + in + let oc_unit_other_x86_64 = + (* Runs unit tests for contrib. *) + job_unit_test + ~__POS__ + ~name:"oc.unit:other-x86_64" + ~arch:Amd64 + ~make_targets:["test-other-unit"] + () + in + let oc_unit_proto_x86_64 = + (* Runs unit tests for protocol. *) + job_unit_test + ~__POS__ + ~name:"oc.unit:proto-x86_64" + ~arch:Amd64 + ~make_targets:["test-proto-unit"] + () + in + let oc_unit_non_proto_arm64 = + job_unit_test + ~__POS__ + ~name:"oc.unit:non-proto-arm64" + ~parallel_vector:2 + ~arch:Arm64 (* The [lib_benchmark] unit tests require Python *) + ~image:Images.runtime_build_test_dependencies + ~rules: + [ + job_rule ~if_:Rules.schedule_extended_tests ~when_:Always (); + job_rule ~changes:changeset_unit_test_arm64 (); + ] + ~make_targets:["test-nonproto-unit"; "test-webassembly"] + (* No coverage for arm64 jobs -- the code they test is a + subset of that tested by x86_64 unit tests. *) + ~enable_coverage:false + () + in + let oc_unit_webassembly_x86_64 = + job + ~__POS__ + ~name:"oc.unit:webassembly-x86_64" + ~arch:Amd64 (* The wasm tests are written in Python *) + ~image:Images.runtime_build_test_dependencies + ~stage:Stages.test + ~dependencies:(build_dependencies Amd64) + ~rules:[job_rule ~changes:changeset_octez ()] + ~before_script:(before_script ~source_version:true ~eval_opam:true []) + (* TODO: https://gitlab.com/tezos/tezos/-/issues/4663 + This test takes around 2 to 4min to complete, but it sometimes + hangs. We use a timeout to retry the test in this case. The + underlying issue should be fixed eventually, turning this timeout + unnecessary. *) + ~timeout:(Minutes 20) + ["make test-webassembly"] + in + let oc_unit_js_components = + job + ~__POS__ + ~name:"oc.unit:js_components" + ~arch:Amd64 + ~image:Images.runtime_build_test_dependencies + ~stage:Stages.test + ~dependencies:(build_dependencies Amd64) + ~rules:[job_rule ~changes:changeset_octez ()] + ~retry:2 + ~variables:[("RUNTEZTALIAS", "true")] + ~before_script: + (before_script + ~take_ownership:true + ~source_version:true + ~eval_opam:true + ~install_js_deps:true + []) + ["make test-js"] + in + let oc_unit_protocol_compiles = + job + ~__POS__ + ~name:"oc.unit:protocol_compiles" + ~arch:Amd64 + ~image:Images.runtime_build_dependencies + ~stage:Stages.test + ~dependencies:(build_dependencies Amd64) + ~rules:[job_rule ~changes:changeset_octez ()] + ~before_script:(before_script ~source_version:true ~eval_opam:true []) + ["dune build @runtest_compile_protocol"] + in + [ + oc_unit_non_proto_x86_64; + oc_unit_other_x86_64; + oc_unit_proto_x86_64; + oc_unit_non_proto_arm64; + oc_unit_webassembly_x86_64; + oc_unit_js_components; + oc_unit_protocol_compiles; + ] + (* Encodes the conditional [before_merging] pipeline and its unconditional variant [schedule_extended_test]. *) type code_verification_pipeline = Before_merging | Schedule_extended_test @@ -156,6 +326,18 @@ let jobs pipeline_type = | Schedule_extended_test -> scheduled_suffix) job in + let jobs_external_split ?(before_merging_suffix = "before_merging") + ?(scheduled_suffix = "scheduled_extended_test") ~path jobs = + let path = + sf + "%s-%s.yml" + path + (match pipeline_type with + | Before_merging -> before_merging_suffix + | Schedule_extended_test -> scheduled_suffix) + in + jobs_external ~path jobs + in (* Used to externalize jobs that are the same on both pipelines. They're only written once. Beware: there is no check that the two jobs are actually identical. *) let job_external_once job = @@ -304,15 +486,41 @@ let jobs pipeline_type = []) |> job_external_split in + (* The build_x86_64 jobs are split in two to keep the artifact size + under the 1GB hard limit set by GitLab. *) + (* [job_build_x86_64_release] builds the released executables. *) + let job_build_x86_64_release = + job_build_dynamic_binaries + ~__POS__ + ~arch:Amd64 + ~dependencies:dependencies_needs_trigger + ~release:true + ~rules:(make_rules ~changes:changeset_octez ()) + () + |> job_external_split + in + (* 'oc.build_x86_64-exp-dev-extra' builds the developer and experimental + executables, as well as the tezt test suite used by the subsequent + 'tezt' jobs and TPS evaluation tool. *) + let job_build_x86_64_exp_dev_extra = + job_build_dynamic_binaries + ~__POS__ + ~arch:Amd64 + ~dependencies:dependencies_needs_trigger + ~release:false + ~rules:(make_rules ~changes:changeset_octez ()) + () + |> job_external_split + in + let build_arm_rules = make_rules ~label:"ci--arm64" ~manual:true () in + let job_build_arm64_release : Tezos_ci.tezos_job = + job_build_arm64_release ~rules:build_arm_rules () |> job_external_split + in + let job_build_arm64_exp_dev_extra : Tezos_ci.tezos_job = + job_build_arm64_exp_dev_extra ~rules:build_arm_rules () + |> job_external_split + in let build = - let build_arm_rules = make_rules ~label:"ci--arm64" ~manual:true () in - let job_build_arm64_release : Tezos_ci.tezos_job = - job_build_arm64_release ~rules:build_arm_rules () |> job_external_split - in - let job_build_arm64_exp_dev_extra : Tezos_ci.tezos_job = - job_build_arm64_exp_dev_extra ~rules:build_arm_rules () - |> job_external_split - in let job_static_x86_64_experimental = job_build_static_binaries ~__POS__ @@ -339,32 +547,6 @@ let jobs pipeline_type = [job_build_dpkg_amd64; job_build_rpm_amd64] | Before_merging -> [] in - (* The build_x86_64 jobs are split in two to keep the artifact size - under the 1GB hard limit set by GitLab. *) - (* [job_build_x86_64_release] builds the released executables. *) - let job_build_x86_64_release = - job_build_dynamic_binaries - ~__POS__ - ~arch:Amd64 - ~dependencies:dependencies_needs_trigger - ~release:true - ~rules:(make_rules ~changes:changeset_octez ()) - () - |> job_external_split - in - (* 'oc.build_x86_64-exp-dev-extra' builds the developer and experimental - executables, as well as the tezt test suite used by the subsequent - 'tezt' jobs and TPS evaluation tool. *) - let job_build_x86_64_exp_dev_extra = - job_build_dynamic_binaries - ~__POS__ - ~arch:Amd64 - ~dependencies:dependencies_needs_trigger - ~release:false - ~rules:(make_rules ~changes:changeset_octez ()) - () - |> job_external_split - in let job_ocaml_check : tezos_job = job ~__POS__ @@ -656,6 +838,14 @@ let jobs pipeline_type = ] |> job_external_split in + let jobs_unit : tezos_job list = + jobs_unit_tests + ~job_build_x86_64_release + ~job_build_x86_64_exp_dev_extra + ~job_build_arm64_release + ~job_build_arm64_exp_dev_extra + |> jobs_external_split ~path:"test/oc.unit" + in [ job_kaitai_checks; job_kaitai_e2e_checks; @@ -664,6 +854,7 @@ let jobs pipeline_type = job_misc_opam_checks; job_semgrep; ] + @ jobs_unit @ match pipeline_type with | Before_merging -> diff --git a/ci/bin/common.ml b/ci/bin/common.ml index 48af173e057c..5cff0c3d9976 100644 --- a/ci/bin/common.ml +++ b/ci/bin/common.ml @@ -211,6 +211,20 @@ let enable_coverage_location : tezos_job -> tezos_job = Tezos_ci.append_variables [("BISECT_FILE", "$CI_PROJECT_DIR/_coverage_output/")] +(** Add variables for bisect_ppx output and store the traces as an + artifact. + + This function should be applied to test jobs that produce coverage. *) +let enable_coverage_output_artifact ?(expire_in = Days 1) : + tezos_job -> tezos_job = + fun job -> + job |> enable_coverage_location + |> Tezos_ci.add_artifacts + ~expire_in + ~name:"coverage-files-$CI_JOB_ID" + ~when_:On_success + ["$BISECT_FILE"] + let enable_coverage_report job : tezos_job = job |> Tezos_ci.add_artifacts diff --git a/ci/bin/main.ml b/ci/bin/main.ml index 976e39b9fcf2..172315d05b77 100644 --- a/ci/bin/main.ml +++ b/ci/bin/main.ml @@ -189,7 +189,6 @@ let () = | ".gitlab/ci/jobs/test/oc.script:test-gen-genesis.yml" | ".gitlab/ci/jobs/test/oc.script:test_octez_release_versions.yml" | ".gitlab/ci/jobs/test/oc.test-liquidity-baking-scripts.yml" - | ".gitlab/ci/jobs/test/oc.unit.yml" | ".gitlab/ci/jobs/test/test_etherlink_kernel-before_merging.yml" | ".gitlab/ci/jobs/test/test_etherlink_kernel-schedule_extended_test.yml" | ".gitlab/ci/jobs/test/test_evm_compatibility.yml" -- GitLab From f38baa8166a418b103f8aa3a4f8764e3bc711a1d Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Fri, 15 Mar 2024 17:46:46 +0100 Subject: [PATCH 07/10] CI: align [changes:] for job [oc.unit:non-proto-arm64] It's not clear why this job would need another changeset than the other unit tests. The other unit tests have a broader changeset so this change should be safe. --- .gitlab/ci/jobs/test/oc.unit-before_merging.yml | 4 ++++ .gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml | 4 ++++ ci/bin/code_verification.ml | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab/ci/jobs/test/oc.unit-before_merging.yml b/.gitlab/ci/jobs/test/oc.unit-before_merging.yml index 274b0bee162d..aad6cb952857 100644 --- a/.gitlab/ci/jobs/test/oc.unit-before_merging.yml +++ b/.gitlab/ci/jobs/test/oc.unit-before_merging.yml @@ -134,8 +134,12 @@ oc.unit:non-proto-arm64: when: always - changes: - src/**/* + - etherlink/**/* + - tezt/**/* - .gitlab/**/* - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* when: on_success needs: - oc.build_arm64-released diff --git a/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml b/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml index 274b0bee162d..aad6cb952857 100644 --- a/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml +++ b/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml @@ -134,8 +134,12 @@ oc.unit:non-proto-arm64: when: always - changes: - src/**/* + - etherlink/**/* + - tezt/**/* - .gitlab/**/* - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* when: on_success needs: - oc.build_arm64-released diff --git a/ci/bin/code_verification.ml b/ci/bin/code_verification.ml index 019c9c8e4f05..4f43af7352e1 100644 --- a/ci/bin/code_verification.ml +++ b/ci/bin/code_verification.ml @@ -139,8 +139,6 @@ let read_opam_packages = Some {name; group; batch_index} | _ -> fail () -let changeset_unit_test_arm64 = ["src/**/*"; ".gitlab/**/*"; ".gitlab-ci.yml"] - let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra ~job_build_arm64_release ~job_build_arm64_exp_dev_extra : tezos_job list = let build_dependencies = function @@ -241,7 +239,7 @@ let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra ~rules: [ job_rule ~if_:Rules.schedule_extended_tests ~when_:Always (); - job_rule ~changes:changeset_unit_test_arm64 (); + job_rule ~changes:changeset_octez (); ] ~make_targets:["test-nonproto-unit"; "test-webassembly"] (* No coverage for arm64 jobs -- the code they test is a -- GitLab From a8c0858a703c261a0b93fecffb05be598b9794e1 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Fri, 15 Mar 2024 18:05:39 +0100 Subject: [PATCH 08/10] CI: pipeline-specific rules for unit tests Makes the unit tests coherent with the other scheduled pipeline jobs by having them run [Always], unless if they have dependencies, in which case they run [On_success]. --- .../ci/jobs/test/oc.unit-before_merging.yml | 2 - .../test/oc.unit-scheduled_extended_test.yml | 72 ++------------ ci/bin/code_verification.ml | 97 +++++++++++-------- 3 files changed, 61 insertions(+), 110 deletions(-) diff --git a/.gitlab/ci/jobs/test/oc.unit-before_merging.yml b/.gitlab/ci/jobs/test/oc.unit-before_merging.yml index aad6cb952857..8af3ca7b6e74 100644 --- a/.gitlab/ci/jobs/test/oc.unit-before_merging.yml +++ b/.gitlab/ci/jobs/test/oc.unit-before_merging.yml @@ -130,8 +130,6 @@ oc.unit:non-proto-arm64: tags: - gcp_arm64 rules: - - if: $CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS" - when: always - changes: - src/**/* - etherlink/**/* diff --git a/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml b/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml index aad6cb952857..8961df1b43ab 100644 --- a/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml +++ b/.gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml @@ -7,15 +7,7 @@ oc.unit:non-proto-x86_64: tags: - gcp rules: - - changes: - - src/**/* - - etherlink/**/* - - tezt/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - michelson_test_scripts/**/* - - tzt_reference_test_suite/**/* - when: on_success + - when: on_success needs: - oc.build_x86_64-released - oc.build_x86_64-exp-dev-extra @@ -48,15 +40,7 @@ oc.unit:other-x86_64: tags: - gcp rules: - - changes: - - src/**/* - - etherlink/**/* - - tezt/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - michelson_test_scripts/**/* - - tzt_reference_test_suite/**/* - when: on_success + - when: on_success needs: - oc.build_x86_64-released - oc.build_x86_64-exp-dev-extra @@ -89,15 +73,7 @@ oc.unit:proto-x86_64: tags: - gcp rules: - - changes: - - src/**/* - - etherlink/**/* - - tezt/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - michelson_test_scripts/**/* - - tzt_reference_test_suite/**/* - when: on_success + - when: on_success needs: - oc.build_x86_64-released - oc.build_x86_64-exp-dev-extra @@ -130,17 +106,7 @@ oc.unit:non-proto-arm64: tags: - gcp_arm64 rules: - - if: $CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS" - when: always - - changes: - - src/**/* - - etherlink/**/* - - tezt/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - michelson_test_scripts/**/* - - tzt_reference_test_suite/**/* - when: on_success + - when: on_success needs: - oc.build_arm64-released - oc.build_arm64-exp-dev-extra @@ -171,15 +137,7 @@ oc.unit:webassembly-x86_64: tags: - gcp rules: - - changes: - - src/**/* - - etherlink/**/* - - tezt/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - michelson_test_scripts/**/* - - tzt_reference_test_suite/**/* - when: on_success + - when: on_success needs: - oc.build_x86_64-released - oc.build_x86_64-exp-dev-extra @@ -197,15 +155,7 @@ oc.unit:js_components: tags: - gcp rules: - - changes: - - src/**/* - - etherlink/**/* - - tezt/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - michelson_test_scripts/**/* - - tzt_reference_test_suite/**/* - when: on_success + - when: on_success needs: - oc.build_x86_64-released - oc.build_x86_64-exp-dev-extra @@ -227,15 +177,7 @@ oc.unit:protocol_compiles: tags: - gcp rules: - - changes: - - src/**/* - - etherlink/**/* - - tezt/**/* - - .gitlab/**/* - - .gitlab-ci.yml - - michelson_test_scripts/**/* - - tzt_reference_test_suite/**/* - when: on_success + - when: on_success needs: - oc.build_x86_64-released - oc.build_x86_64-exp-dev-extra diff --git a/ci/bin/code_verification.ml b/ci/bin/code_verification.ml index 4f43af7352e1..d01701cd69da 100644 --- a/ci/bin/code_verification.ml +++ b/ci/bin/code_verification.ml @@ -35,6 +35,39 @@ open Gitlab_ci.Util open Tezos_ci open Common +(* Encodes the conditional [before_merging] pipeline and its + unconditional variant [schedule_extended_test]. *) +type code_verification_pipeline = Before_merging | Schedule_extended_test + +(* [make_rules] makes rules for jobs that are: + - automatic in scheduled pipelines; + - conditional in [before_merging] pipelines. + + If [label], [changes] and [manual] are omitted, then rules will + enable the job [On_success] in the [before_merging] + pipeline. This is safe, but prefer specifying a [changes] clause + if possible. *) +let make_rules ?label ?changes ?(manual = false) ?(dependent = false) + pipeline_type = + match pipeline_type with + | Schedule_extended_test -> + (* The scheduled pipeline always runs all jobs unconditionally + -- unless they are dependent on a previous, non-trigger job, in the + pipeline. *) + [job_rule ~when_:(if dependent then On_success else Always) ()] + | Before_merging -> + (* MR labels can be used to force tests to run. *) + (match label with + | Some label -> + [job_rule ~if_:Rules.(has_mr_label label) ~when_:On_success ()] + | None -> []) + (* Modifying some files can force tests to run. *) + @ (match changes with + | None -> [] + | Some changes -> [job_rule ~changes ~when_:On_success ()]) + (* For some tests, it can be relevant to have a manual trigger. *) + @ if manual then [job_rule ~when_:Manual ()] else [] + type opam_package_group = Executable | All type opam_package = { @@ -140,7 +173,8 @@ let read_opam_packages = | _ -> fail () let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra - ~job_build_arm64_release ~job_build_arm64_exp_dev_extra : tezos_job list = + ~job_build_arm64_release ~job_build_arm64_exp_dev_extra pipeline_type : + tezos_job list = let build_dependencies = function | Amd64 -> Dependent @@ -149,10 +183,20 @@ let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra Dependent [Job job_build_arm64_release; Job job_build_arm64_exp_dev_extra] in + let rules = + (* TODO: Note that all jobs defined in this function are + [dependent] in the sense that they all have + [dependencies:]. However, AFAICT, these dependencies are all + dummy dependencies for ordering -- not for artifacts. This + means that these unit tests can very well run even if their + dependencies failed. Moreover, the ordering serves no purpose + on scheduled pipelines, so we might even remove them for that + [pipeline_type]. *) + make_rules ~changes:changeset_octez ~dependent:true pipeline_type + in let job_unit_test ~__POS__ ?(image = Images.runtime_build_dependencies) ?timeout ?parallel_vector ~arch ~name ?(enable_coverage = true) - ?(rules = [job_rule ~changes:changeset_octez ()]) ~make_targets () : - tezos_job = + ~make_targets () : tezos_job = let arch_string = arch_to_string arch in let script = ["make $MAKE_TARGETS"] @@ -236,11 +280,6 @@ let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra ~parallel_vector:2 ~arch:Arm64 (* The [lib_benchmark] unit tests require Python *) ~image:Images.runtime_build_test_dependencies - ~rules: - [ - job_rule ~if_:Rules.schedule_extended_tests ~when_:Always (); - job_rule ~changes:changeset_octez (); - ] ~make_targets:["test-nonproto-unit"; "test-webassembly"] (* No coverage for arm64 jobs -- the code they test is a subset of that tested by x86_64 unit tests. *) @@ -255,7 +294,7 @@ let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra ~image:Images.runtime_build_test_dependencies ~stage:Stages.test ~dependencies:(build_dependencies Amd64) - ~rules:[job_rule ~changes:changeset_octez ()] + ~rules ~before_script:(before_script ~source_version:true ~eval_opam:true []) (* TODO: https://gitlab.com/tezos/tezos/-/issues/4663 This test takes around 2 to 4min to complete, but it sometimes @@ -273,7 +312,7 @@ let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra ~image:Images.runtime_build_test_dependencies ~stage:Stages.test ~dependencies:(build_dependencies Amd64) - ~rules:[job_rule ~changes:changeset_octez ()] + ~rules ~retry:2 ~variables:[("RUNTEZTALIAS", "true")] ~before_script: @@ -293,7 +332,7 @@ let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra ~image:Images.runtime_build_dependencies ~stage:Stages.test ~dependencies:(build_dependencies Amd64) - ~rules:[job_rule ~changes:changeset_octez ()] + ~rules ~before_script:(before_script ~source_version:true ~eval_opam:true []) ["dune build @runtest_compile_protocol"] in @@ -307,13 +346,12 @@ let jobs_unit_tests ~job_build_x86_64_release ~job_build_x86_64_exp_dev_extra oc_unit_protocol_compiles; ] -(* Encodes the conditional [before_merging] pipeline and its unconditional variant - [schedule_extended_test]. *) -type code_verification_pipeline = Before_merging | Schedule_extended_test - (* Encodes the conditional [before_merging] pipeline and its unconditional variant [schedule_extended_test]. *) let jobs pipeline_type = + let make_rules ?label ?changes ?manual ?dependent () = + make_rules ?label ?changes ?manual ?dependent pipeline_type + in (* Externalization *) let job_external_split ?(before_merging_suffix = "before_merging") ?(scheduled_suffix = "scheduled_extended_test") job = @@ -349,34 +387,6 @@ let jobs pipeline_type = | Before_merging -> jobs_external ~path jobs | Schedule_extended_test -> jobs in - (* [make_rules] makes rules for jobs that are: - - automatic in scheduled pipelines; - - conditional in [before_merging] pipelines. - - If [label], [changes] and [manual] are omitted, then rules will - enable the job [On_success] in the [before_merging] - pipeline. This is safe, but prefer specifying a [changes] clause - if possible. *) - let make_rules ?label ?changes ?(manual = false) ?(dependent = false) () = - match pipeline_type with - | Schedule_extended_test -> - (* The scheduled pipeline always runs all jobs unconditionally - -- unless they are dependent on a previous, non-trigger job, in the - pipeline. *) - [job_rule ~when_:(if dependent then On_success else Always) ()] - | Before_merging -> - (* MR labels can be used to force tests to run. *) - (match label with - | Some label -> - [job_rule ~if_:Rules.(has_mr_label label) ~when_:On_success ()] - | None -> []) - (* Modifying some files can force tests to run. *) - @ (match changes with - | None -> [] - | Some changes -> [job_rule ~changes ~when_:On_success ()]) - (* For some tests, it can be relevant to have a manual trigger. *) - @ if manual then [job_rule ~when_:Manual ()] else [] - in (* Stages *) (* All stages should be empty, as explained below, until the full pipeline is generated. *) let trigger, dependencies_needs_trigger = @@ -842,6 +852,7 @@ let jobs pipeline_type = ~job_build_x86_64_exp_dev_extra ~job_build_arm64_release ~job_build_arm64_exp_dev_extra + pipeline_type |> jobs_external_split ~path:"test/oc.unit" in [ -- GitLab From 8033f376b16be6cb901e74ca5aaf3f86e2692aad Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Mon, 18 Mar 2024 11:20:42 +0100 Subject: [PATCH 09/10] CI: generate [oc.integration:compiler-rejections] --- ...ion:compiler-rejections-before_merging.yml | 27 +++++++++++++++++++ ...ler-rejections-scheduled_extended_test.yml | 19 +++++++++++++ .../oc.integration:compiler-rejections.yml | 6 ----- .gitlab/ci/pipelines/before_merging.yml | 2 +- .../ci/pipelines/schedule_extended_test.yml | 2 +- ci/bin/code_verification.ml | 15 +++++++++++ 6 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 .gitlab/ci/jobs/test/oc.integration:compiler-rejections-before_merging.yml create mode 100644 .gitlab/ci/jobs/test/oc.integration:compiler-rejections-scheduled_extended_test.yml delete mode 100644 .gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml diff --git a/.gitlab/ci/jobs/test/oc.integration:compiler-rejections-before_merging.yml b/.gitlab/ci/jobs/test/oc.integration:compiler-rejections-before_merging.yml new file mode 100644 index 000000000000..cc8ac5280334 --- /dev/null +++ b/.gitlab/ci/jobs/test/oc.integration:compiler-rejections-before_merging.yml @@ -0,0 +1,27 @@ +# This file was automatically generated, do not edit. +# Edit file ci/bin/main.ml instead. + +oc.integration:compiler-rejections: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - changes: + - src/**/* + - etherlink/**/* + - tezt/**/* + - .gitlab/**/* + - .gitlab-ci.yml + - michelson_test_scripts/**/* + - tzt_reference_test_suite/**/* + when: on_success + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - dune build @runtest_rejections diff --git a/.gitlab/ci/jobs/test/oc.integration:compiler-rejections-scheduled_extended_test.yml b/.gitlab/ci/jobs/test/oc.integration:compiler-rejections-scheduled_extended_test.yml new file mode 100644 index 000000000000..267236a7f54d --- /dev/null +++ b/.gitlab/ci/jobs/test/oc.integration:compiler-rejections-scheduled_extended_test.yml @@ -0,0 +1,19 @@ +# This file was automatically generated, do not edit. +# Edit file ci/bin/main.ml instead. + +oc.integration:compiler-rejections: + image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version} + stage: test + tags: + - gcp + rules: + - when: always + needs: + - oc.build_x86_64-released + - oc.build_x86_64-exp-dev-extra + dependencies: [] + before_script: + - . ./scripts/version.sh + - eval $(opam env) + script: + - dune build @runtest_rejections diff --git a/.gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml b/.gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml deleted file mode 100644 index 4c3b47592650..000000000000 --- a/.gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml +++ /dev/null @@ -1,6 +0,0 @@ -oc.integration:compiler-rejections: - extends: - - .test_template - - .rules__octez_changes - script: - - dune build @runtest_rejections diff --git a/.gitlab/ci/pipelines/before_merging.yml b/.gitlab/ci/pipelines/before_merging.yml index 8bf1089c5220..7153c0f902c7 100644 --- a/.gitlab/ci/pipelines/before_merging.yml +++ b/.gitlab/ci/pipelines/before_merging.yml @@ -38,7 +38,7 @@ include: - .gitlab/ci/jobs/test/commit_titles.yml - .gitlab/ci/jobs/test/oc.semgrep-before_merging.yml - .gitlab/ci/jobs/test/oc.unit-before_merging.yml - - .gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml + - .gitlab/ci/jobs/test/oc.integration:compiler-rejections-before_merging.yml - .gitlab/ci/jobs/test/oc.script:snapshot_alpha_and_link.yml - .gitlab/ci/jobs/test/oc.script:test-gen-genesis.yml - .gitlab/ci/jobs/test/oc.script:test_octez_release_versions.yml diff --git a/.gitlab/ci/pipelines/schedule_extended_test.yml b/.gitlab/ci/pipelines/schedule_extended_test.yml index 202e749d9fc3..f0ce579f8c03 100644 --- a/.gitlab/ci/pipelines/schedule_extended_test.yml +++ b/.gitlab/ci/pipelines/schedule_extended_test.yml @@ -44,7 +44,7 @@ include: - .gitlab/ci/jobs/test/misc_opam_checks-scheduled_extended_test.yml - .gitlab/ci/jobs/test/oc.semgrep-scheduled_extended_test.yml - .gitlab/ci/jobs/test/oc.unit-scheduled_extended_test.yml - - .gitlab/ci/jobs/test/oc.integration:compiler-rejections.yml + - .gitlab/ci/jobs/test/oc.integration:compiler-rejections-scheduled_extended_test.yml - .gitlab/ci/jobs/test/oc.script:snapshot_alpha_and_link.yml - .gitlab/ci/jobs/test/oc.script:test-gen-genesis.yml - .gitlab/ci/jobs/test/oc.script:test_octez_release_versions.yml diff --git a/ci/bin/code_verification.ml b/ci/bin/code_verification.ml index d01701cd69da..16228aa0a353 100644 --- a/ci/bin/code_verification.ml +++ b/ci/bin/code_verification.ml @@ -855,6 +855,20 @@ let jobs pipeline_type = pipeline_type |> jobs_external_split ~path:"test/oc.unit" in + let job_oc_integration_compiler_rejections : tezos_job = + job + ~__POS__ + ~name:"oc.integration:compiler-rejections" + ~stage:Stages.test + ~image:Images.runtime_build_dependencies + ~rules:(make_rules ~changes:changeset_octez ()) + ~dependencies: + (Dependent + [Job job_build_x86_64_release; Job job_build_x86_64_exp_dev_extra]) + ~before_script:(before_script ~source_version:true ~eval_opam:true []) + ["dune build @runtest_rejections"] + |> job_external_split + in [ job_kaitai_checks; job_kaitai_e2e_checks; @@ -862,6 +876,7 @@ let jobs pipeline_type = job_oc_misc_checks; job_misc_opam_checks; job_semgrep; + job_oc_integration_compiler_rejections; ] @ jobs_unit @ -- GitLab From 3b5b7f0b1547c1cb268e12cc65c4a703a7a8ca04 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Thu, 21 Mar 2024 15:24:15 +0100 Subject: [PATCH 10/10] Docs: Testing and CI updates --- docs/developer/protocol_release_checklist.rst | 4 ---- docs/developer/testing.rst | 22 ++++++------------- docs/scripts/test_install_scripts.sh | 2 +- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/docs/developer/protocol_release_checklist.rst b/docs/developer/protocol_release_checklist.rst index f5e1766a8aa3..3cb7fa53b2ae 100644 --- a/docs/developer/protocol_release_checklist.rst +++ b/docs/developer/protocol_release_checklist.rst @@ -64,10 +64,6 @@ The release of a new protocol requires some manual configuration in the CI: This is done by adding and removing the respective protocols to ``active_protocol_versions``, :src:`scripts/remove-old-protocols.sh` will ``rm`` the appropriate older protocol. -Additionally, the ``unit:NNN_PROTONAME`` unit test jobs in -:src:`.gitlab/ci/jobs/test/oc.unit.yml` must be updated to test the new protocols and stop -testing the old ones, in the same manner as above. - **Final Tests and sign-off:** In the below, “Protocol Shepherd” is abbreviated “Shepherd”. diff --git a/docs/developer/testing.rst b/docs/developer/testing.rst index ad3cc274e09f..f73b60c13f2e 100644 --- a/docs/developer/testing.rst +++ b/docs/developer/testing.rst @@ -503,29 +503,21 @@ Adding tests to the CI When adding a new test that should be run in the CI (which should be the case for most automatic tests), you need to make sure that it is -properly specified in the :src:`.gitlab-ci.yml` file. The procedure -for doing this depends on the type of test you've added: +properly configured. The procedure for doing this depends on the type +of test you've added: Tezt integration and regression tests New Tezt tests will be included automatically in the CI. - To rebalance the Tezt batches, run (from the root of the Octez repository): - ``make && dune exec tezt/tests/main.exe -- --record tezt/test-results.json`` The OCaml package tests (Alcotest & QCheck) - Any non-protocol tests located in a folder named ``src/**/test/`` will be - picked up automatically by the CI. No intervention is necessary. - - Protocol tests must be added to :src:`.gitlab/ci/jobs/test/oc.unit.yml` under the - protocol that they are testing. For example, to run a new protocol test for - ``proto_XXX_YYYYYYYY``, add the corresponding - ``src/proto_XXX_YYYYYYYY/lib_\*.test_proto`` to the ``unit:XXX_YYYYYYYY`` - ``make`` invocation. + Any tests located in a folder named ``src/**/test/`` that are + executed through ``dune runtest`` will be picked up automatically by + the CI. No intervention is necessary. Other For other types of tests, you need to manually modify the - :src:`.gitlab-ci.yml`. Please refer to the `GitLab CI Pipeline - Reference `_. A helpful tool for - this task is the `CI Lint tool `_. + CI configuration. Please refer to the CI configuration's README + (:src:`ci/README.md`) for more information. Test coverage in merge requests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/scripts/test_install_scripts.sh b/docs/scripts/test_install_scripts.sh index 76cb0857c202..bac3c57c3c61 100755 --- a/docs/scripts/test_install_scripts.sh +++ b/docs/scripts/test_install_scripts.sh @@ -10,7 +10,7 @@ # - by the CI to check them on a regular basis (e.g. every day) # # Therefore, mind keeping in sync the list of scenarios with both the Makefile -# and the CI (file .gitlab/ci/test/install-octez.yml). +# and the CI (file .gitlab/ci/jobs/test/install_octez.yml). # Ubuntu Focal Fossa 20.04 LTS: UBUNTU_FOCAL=public.ecr.aws/lts/ubuntu:20.04_stable -- GitLab