Skip to content

Commit a5c016e

Browse files
committed
esp/ci: Reorginize pipeline to minimize jobs running for MRs
Toolchain tests are ran on default branch only or when forced by 'toolchain_tests' label in MR.
1 parent e17298f commit a5c016e

1 file changed

Lines changed: 79 additions & 23 deletions

File tree

.gitlab-ci.yml

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ variables:
3131
ESP_RELEASE_BRANCH: origin/$CI_DEFAULT_BRANCH
3232
CCACHE_DIR: ${CI_PROJECT_DIR}/.ccache
3333
CCACHE_MAXSIZE: 10G
34+
CCACHE_SLOPPINESS: "time_macros,file_macro,include_file_mtime,include_file_ctime"
3435

3536
workflow:
3637
rules:
@@ -169,7 +170,7 @@ rebase_on_main:
169170
else
170171
rc=$?
171172
echo "Rebasing branch '$BRANCH_NAME' on 'origin/$SCHED_REBASE_ONTO_BR' failed!"
172-
echo Please rebase '$BRANCH_NAME' onto 'origin/$SCHED_REBASE_ONTO_BR' branch manually.
173+
echo "Please rebase '$BRANCH_NAME' onto 'origin/$SCHED_REBASE_ONTO_BR' branch manually."
173174
if [ -d "${GIT_DIR}/rebase-merge" ] || [ -d "${GIT_DIR}/rebase-apply" ] ; then
174175
echo "Abort rebase"
175176
git rebase --abort
@@ -219,12 +220,14 @@ check_commit_message:
219220
USE_LINKER: "ld"
220221
CROSS_BUILD_MINGW: "OFF"
221222
BUILD_TARGET_LIBS: "OFF"
223+
BUILD_GNU_BINUTILS: "OFF"
222224
RUN_CORE_TESTS: "OFF"
223225
RUN_PKG_TESTS: "OFF"
224226
RUN_TOOLCHAIN_TESTS: "OFF"
225227
PACK_TOOLCHAIN: "ON"
226-
PACK_STANDALONE_LIBS: "ON"
228+
PACK_STANDALONE_LIBS: "OFF"
227229
PACK_TARGET_LIBS: "OFF"
230+
PACK_EXTRA_TOOLS: "OFF"
228231
rules:
229232
- <<: *if-esp-main-workflow
230233
when: never
@@ -283,8 +286,8 @@ check_commit_message:
283286
fi
284287
- AUX_BUILD_ARGS="";
285288
- >
286-
if [ "${ESP_FORCE_LLVM_PARALLEL_COMPILE_JOBS:-}" != "" ]; then
287-
AUX_BUILD_ARGS="${AUX_BUILD_ARGS} -DLLVM_PARALLEL_COMPILE_JOBS=${ESP_FORCE_LLVM_PARALLEL_COMPILE_JOBS}";
289+
if [ "${ESP_LLVM_PARALLEL_COMPILE_JOBS:-}" != "" ]; then
290+
AUX_BUILD_ARGS="${AUX_BUILD_ARGS} -DLLVM_PARALLEL_COMPILE_JOBS=${ESP_LLVM_PARALLEL_COMPILE_JOBS}";
288291
fi
289292
# build toolchain core w/o any libs and GNU components
290293
- time cmake $PWD/esp-llvm-embedded-toolchain -GNinja
@@ -298,7 +301,7 @@ check_commit_message:
298301
-DLLVM_TOOLCHAIN_C_LIBRARY=${USE_LIBC}
299302
-DLLVM_TOOLCHAIN_CXX_LIBRARIES=${USE_LIBCXX}
300303
-DLLVM_TOOLCHAIN_RT_LIBRARIES=${USE_RTLIB}
301-
-DLLVM_TOOLCHAIN_INCLUDE_GNU_BINUTILS=ON
304+
-DLLVM_TOOLCHAIN_INCLUDE_GNU_BINUTILS=${BUILD_GNU_BINUTILS}
302305
-DLLVM_TOOLCHAIN_ESPRESSIF=ON
303306
-DLLVM_TOOLCHAIN_HOST_TRIPLE=${CONF_HOST}
304307
-DLLVM_TOOLCHAIN_ENABLED_TARGETS="${TARGET}"
@@ -357,9 +360,20 @@ check_commit_message:
357360
- mkdir -p ${PWD}/${DIST_DIR}
358361
- >
359362
if [[ "${PACK_TOOLCHAIN}" == "ON" ]]; then
360-
echo "Build/Unpack toolchain";
363+
echo "Pack toolchain";
364+
time ninja -C ${BUILD_PATH} package-llvm-toolchain 2>&1 >> ${BUILD_PATH}/build.log
365+
echo "Pack toolchain finished";
366+
DISTRO_PACK_PATH=$(ninja -C ${BUILD_PATH} print-llvm-toolchain-package-path | tail -n 1)
367+
echo "DISTRO_PACK_PATH=${DISTRO_PACK_PATH}"
368+
mv ${DISTRO_PACK_PATH} ${PWD}/${DIST_DIR}/
369+
ARCHIVE_NAME=$(basename ${DISTRO_PACK_PATH})
370+
echo "${ARCHIVE_NAME}" > ${PWD}/${DIST_DIR}/dist_name_${CONF_HOST}
371+
fi
372+
- >
373+
if [[ "${PACK_EXTRA_TOOLS}" == "ON" ]]; then
374+
echo "Unpack toolchain";
361375
time ninja -C ${BUILD_PATH} unpack-llvm-toolchain 2>&1 >> ${BUILD_PATH}/build.log
362-
echo "Build/Unpack toolchain finished";
376+
echo "Unpack toolchain finished";
363377
# pack clangd
364378
echo "Pack clangd";
365379
time ninja -C ${BUILD_PATH} package-clangd 2>&1 >> ${BUILD_PATH}/build.log
@@ -373,11 +387,6 @@ check_commit_message:
373387
echo "Re-pack toolchain";
374388
time ninja -C ${BUILD_PATH} repack-llvm-toolchain 2>&1 >> ${BUILD_PATH}/build.log
375389
echo "Re-pack toolchain finished";
376-
DISTRO_PACK_PATH=$(ninja -C ${BUILD_PATH} print-llvm-toolchain-package-path | tail -n 1)
377-
echo "DISTRO_PACK_PATH=${DISTRO_PACK_PATH}"
378-
mv ${DISTRO_PACK_PATH} ${PWD}/${DIST_DIR}/
379-
ARCHIVE_NAME=$(basename ${DISTRO_PACK_PATH})
380-
echo "${ARCHIVE_NAME}" > ${PWD}/${DIST_DIR}/dist_name_${CONF_HOST}
381390
fi
382391
# pack distro with standalone libs
383392
- >
@@ -432,7 +441,7 @@ build_and_test:
432441
- if: '$CI_COMMIT_REF_NAME == $ESP_MAIN_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $ESP_MAIN_BRANCH'
433442
variables:
434443
CACHE_KEY: ccache-esp_main-$CI_JOB_NAME
435-
- when: on_success
444+
- when: always
436445
cache:
437446
key: $CACHE_KEY
438447
paths:
@@ -456,8 +465,8 @@ build_and_test:
456465
- mkdir -p ${BUILD_PATH}
457466
- AUX_BUILD_ARGS="";
458467
- >
459-
if [ "${ESP_FORCE_LLVM_PARALLEL_COMPILE_JOBS:-}" != "" ]; then
460-
AUX_BUILD_ARGS="${AUX_BUILD_ARGS} -DLLVM_PARALLEL_COMPILE_JOBS=${ESP_FORCE_LLVM_PARALLEL_COMPILE_JOBS}";
468+
if [ "${ESP_LLVM_PARALLEL_COMPILE_JOBS:-}" != "" ]; then
469+
AUX_BUILD_ARGS="${AUX_BUILD_ARGS} -DLLVM_PARALLEL_COMPILE_JOBS=${ESP_LLVM_PARALLEL_COMPILE_JOBS}";
461470
fi
462471
- time cmake -G Ninja
463472
-S llvm
@@ -518,10 +527,24 @@ build_x86_64-linux-gnu:
518527
variables:
519528
CONF_HOST: "x86_64-linux-gnu"
520529
USE_LINKER: "lld"
521-
# Build complete distro it is necessary for running package tests
522-
BUILD_TARGET_LIBS: "ON"
523-
RUN_TOOLCHAIN_TESTS: "ON"
524-
RUN_PKG_TESTS: "ON"
530+
rules:
531+
# Build complete distro and run all tests on default branch
532+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_LABELS =~ /(^|,)toolchain_tests(,|$)/'
533+
variables:
534+
BUILD_TARGET_LIBS: "ON"
535+
BUILD_GNU_BINUTILS: "ON"
536+
RUN_TOOLCHAIN_TESTS: "ON"
537+
RUN_PKG_TESTS: "ON"
538+
# Build all distros and run all tests on tag
539+
- if: '$CI_COMMIT_TAG'
540+
variables:
541+
BUILD_TARGET_LIBS: "ON"
542+
BUILD_GNU_BINUTILS: "ON"
543+
RUN_TOOLCHAIN_TESTS: "ON"
544+
RUN_PKG_TESTS: "ON"
545+
PACK_STANDALONE_LIBS: "ON"
546+
PACK_EXTRA_TOOLS: "ON"
547+
- when: always
525548

526549
# Target libs are built in build_x86_64-linux-gnu, but due to artifacts
527550
# size limit we have to produce target libs archive in this job too.
@@ -535,7 +558,10 @@ build_target_libs:
535558
CONF_HOST: "x86_64-linux-gnu"
536559
PACK_TARGET_LIBS: "ON"
537560
PACK_TOOLCHAIN: "OFF"
538-
PACK_STANDALONE_LIBS: "OFF"
561+
rules:
562+
# Build target libs only on default branch or tag
563+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
564+
when: on_success
539565

540566
build_x86_64-w64-mingw32:
541567
extends: .build_toolchain_template
@@ -545,34 +571,59 @@ build_x86_64-w64-mingw32:
545571
USE_LINKER: ""
546572
CONF_HOST: "x86_64-w64-mingw32"
547573
CROSS_BUILD_MINGW: "ON"
574+
rules:
575+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
576+
variables:
577+
BUILD_GNU_BINUTILS: "ON"
578+
- when: on_success
548579

549580
build_arm-linux-gnueabihf:
550581
extends: .build_linux-gnu_template
551582
stage: build
552583
image: ${CROSS_ARM_IMAGE}
553584
variables:
554585
CONF_HOST: "arm-linux-gnueabihf"
586+
rules:
587+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
588+
variables:
589+
BUILD_GNU_BINUTILS: "ON"
590+
- when: on_success
555591

556592
build_aarch64-linux-gnu:
557593
extends: .build_linux-gnu_template
558594
stage: build
559595
image: ${CROSS_ARM_IMAGE}
560596
variables:
561597
CONF_HOST: "aarch64-linux-gnu"
598+
rules:
599+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
600+
variables:
601+
BUILD_GNU_BINUTILS: "ON"
602+
- when: on_success
562603

563604
build_x86_64-apple-darwin:
564605
extends: .build_toolchain_template
565606
stage: build
566607
image: ${CROSS_MACOS_IMAGE}
567608
variables:
568609
CONF_HOST: "x86_64-apple-darwin21.1"
610+
rules:
611+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
612+
variables:
613+
BUILD_GNU_BINUTILS: "ON"
614+
- when: on_success
569615

570616
build_aarch64-apple-darwin:
571617
extends: .build_toolchain_template
572618
stage: build
573619
image: ${CROSS_MACOS_IMAGE}
574620
variables:
575621
CONF_HOST: "aarch64-apple-darwin21.1"
622+
rules:
623+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
624+
variables:
625+
BUILD_GNU_BINUTILS: "ON"
626+
- when: on_success
576627

577628
.unpack_distro: &unpack_distro |
578629
pushd ${DIST_DIR}
@@ -601,7 +652,9 @@ build_aarch64-apple-darwin:
601652
when: never
602653
- <<: *if-scheduled-sync
603654
when: never
604-
- when: on_success
655+
# Pack distros only on default branch or tag
656+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
657+
when: on_success
605658
script:
606659
# update distro
607660
- *unpack_distro
@@ -674,7 +727,8 @@ pack_aarch64-apple-darwin:
674727
- if: $CI_COMMIT_TAG
675728
when: on_success
676729
allow_failure: false
677-
- when: manual
730+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
731+
when: manual
678732
allow_failure: true
679733
resource_group: macos_codesign
680734
tags: [ "darwin", "codesign" ]
@@ -752,7 +806,9 @@ sign_aarch64-apple-darwin:
752806
when: never
753807
- <<: *if-scheduled-sync
754808
when: never
755-
- when: on_success
809+
# job "build_x86_64-linux-gnu" produces full distro only on default branch or tag or when toolchain_tests label is present
810+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_LABELS =~ /(^|,)toolchain_tests(,|$)/'
811+
when: on_success
756812
script:
757813
- mkdir -p $PWD/${BUILD_DIR}
758814
- export BUILD_LOG=$PWD/${BUILD_DIR}/build.log

0 commit comments

Comments
 (0)