CI: only create required jobs when use bot to trigger test:

Gitlab CI now allow us to define if a job need to be created by
varialbes. This commit add label to CI jobs, so we can make some jobs
not created in certain scenarios when we trigger pipeline with @bot.
This commit is contained in:
He Yin Ling 2018-09-29 14:51:43 +08:00
parent 4eb20f4d99
commit 97610cfccf
2 changed files with 115 additions and 24 deletions

View File

@ -5,6 +5,7 @@ stages:
- unit_test - unit_test
- integration_test - integration_test
- deploy - deploy
- post_check
variables: variables:
# System environment # System environment
@ -102,6 +103,11 @@ build_template_app:
variables: variables:
BATCH_BUILD: "1" BATCH_BUILD: "1"
IDF_CI_BUILD: "1" IDF_CI_BUILD: "1"
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_REGULAR_TEST
script: script:
- git clone https://github.com/espressif/esp-idf-template.git - git clone https://github.com/espressif/esp-idf-template.git
- cd esp-idf-template - cd esp-idf-template
@ -138,6 +144,12 @@ build_template_app:
expire_in: 1 mos expire_in: 1 mos
variables: variables:
SSC_CONFIG_FOLDER: "$CI_PROJECT_DIR/SSC/configs/ESP32_IDF" SSC_CONFIG_FOLDER: "$CI_PROJECT_DIR/SSC/configs/ESP32_IDF"
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_INTEGRATION_TEST
- $BOT_LABEL_REGULAR_TEST
script: script:
- git clone $SSC_REPOSITORY - git clone $SSC_REPOSITORY
- cd SSC - cd SSC
@ -164,6 +176,12 @@ build_esp_idf_tests:
- components/idf_test/unit_test/TestCaseAll.yml - components/idf_test/unit_test/TestCaseAll.yml
- components/idf_test/unit_test/CIConfigs/*.yml - components/idf_test/unit_test/CIConfigs/*.yml
expire_in: 1 mos expire_in: 1 mos
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_UNIT_TEST
- $BOT_LABEL_REGULAR_TEST
script: script:
- cd tools/unit-test-app - cd tools/unit-test-app
- MAKEFLAGS= make help # make sure kconfig tools are built in single process - MAKEFLAGS= make help # make sure kconfig tools are built in single process
@ -189,6 +207,12 @@ build_esp_idf_tests:
variables: variables:
IDF_CI_BUILD: "1" IDF_CI_BUILD: "1"
LOG_PATH: "$CI_PROJECT_DIR/log_examples" LOG_PATH: "$CI_PROJECT_DIR/log_examples"
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_EXAMPLE_TEST
- $BOT_LABEL_REGULAR_TEST
script: script:
# it's not possible to build 100% out-of-tree and have the "artifacts" # it's not possible to build 100% out-of-tree and have the "artifacts"
# mechanism work, but this is the next best thing # mechanism work, but this is the next best thing
@ -250,6 +274,12 @@ build_docs:
- docs/zh_CN/sphinx-warning-log-sanitized.txt - docs/zh_CN/sphinx-warning-log-sanitized.txt
- docs/zh_CN/_build/html - docs/zh_CN/_build/html
expire_in: 1 mos expire_in: 1 mos
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_BUILD_DOCS
- $BOT_LABEL_REGULAR_TEST
script: script:
- cd docs - cd docs
- ./check_lang_folder_sync.sh - ./check_lang_folder_sync.sh
@ -265,6 +295,11 @@ build_docs:
verify_cmake_style: verify_cmake_style:
stage: build stage: build
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_REGULAR_TEST
script: script:
tools/cmake/run_cmake_lint.sh tools/cmake/run_cmake_lint.sh
@ -274,6 +309,11 @@ verify_cmake_style:
tags: tags:
- host_test - host_test
dependencies: [] dependencies: []
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_HOST_TEST
- $BOT_LABEL_REGULAR_TEST
test_nvs_on_host: test_nvs_on_host:
<<: *host_test_template <<: *host_test_template
@ -287,10 +327,10 @@ test_nvs_coverage:
paths: paths:
- components/nvs_flash/test_nvs_host/coverage_report - components/nvs_flash/test_nvs_host/coverage_report
only: only:
- triggers refs:
# This job takes a few hours to finish, so only run it on demand - triggers
variables: variables:
BOT_NEEDS_TRIGGER_BY_NAME: 1 - $BOT_LABEL_NVS_COVERAGE
script: script:
- cd components/nvs_flash/test_nvs_host - cd components/nvs_flash/test_nvs_host
- make coverage_report - make coverage_report
@ -389,15 +429,19 @@ push_to_github:
- tools/ci/push_to_github.sh - tools/ci/push_to_github.sh
deploy_docs: deploy_docs:
stage: host_test stage: deploy
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
tags: tags:
- deploy - deploy
only: only:
- master refs:
- /^release\/v/ - master
- /^v\d+\.\d+(\.\d+)?($|-)/ - /^release\/v/
- triggers - /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD_DOCS
dependencies: dependencies:
- build_docs - build_docs
before_script: *do_nothing_before before_script: *do_nothing_before
@ -429,8 +473,12 @@ check_doc_links:
tags: tags:
- check_doc_links - check_doc_links
only: only:
# can only be triggered refs:
- triggers # can only be triggered
- triggers
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD_DOCS
artifacts: artifacts:
paths: paths:
- docs/_build/linkcheck - docs/_build/linkcheck
@ -505,6 +553,21 @@ check_submodule_sync:
# check if all submodules are correctly synced to public repostory # check if all submodules are correctly synced to public repostory
- git submodule update --init --recursive - git submodule update --init --recursive
check_pipeline_triggered_by_label:
stage: post_check
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
dependencies: []
before_script: *do_nothing_before
tags:
- build
only:
variables:
- $BOT_TRIGGER_WITH_LABEL
script:
# If the pipeline is triggered with label, the pipeline will only succeeded if "regular_test" label is added.
# We want to make sure some jobs are always executed to detect regression.
- test "$BOT_LABEL_REGULAR_TEST" = "true" || exit -1
assign_test: assign_test:
tags: tags:
- assign_test - assign_test
@ -526,6 +589,12 @@ assign_test:
- components/idf_test/*/TC.sqlite - components/idf_test/*/TC.sqlite
- $EXAMPLE_CONFIG_OUTPUT_PATH - $EXAMPLE_CONFIG_OUTPUT_PATH
expire_in: 1 mos expire_in: 1 mos
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_UNIT_TEST
- $BOT_LABEL_INTEGRATION_TEST
- $BOT_LABEL_EXAMPLE_TEST
before_script: *add_gitlab_key_before before_script: *add_gitlab_key_before
script: script:
# assign example tests # assign example tests
@ -543,11 +612,15 @@ assign_test:
stage: integration_test stage: integration_test
when: on_success when: on_success
only: only:
- master refs:
- /^release\/v/ - master
- /^v\d+\.\d+(\.\d+)?($|-)/ - /^release\/v/
- triggers - /^v\d+\.\d+(\.\d+)?($|-)/
- schedules - triggers
- schedules
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_EXAMPLE_TEST
dependencies: dependencies:
- assign_test - assign_test
- build_examples_00 - build_examples_00
@ -586,6 +659,16 @@ assign_test:
dependencies: dependencies:
- assign_test - assign_test
- build_esp_idf_tests - build_esp_idf_tests
only:
refs:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
- schedules
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_UNIT_TEST
variables: variables:
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw" TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
TEST_CASE_PATH: "$CI_PROJECT_DIR/tools/unit-test-app" TEST_CASE_PATH: "$CI_PROJECT_DIR/tools/unit-test-app"
@ -597,11 +680,15 @@ assign_test:
stage: integration_test stage: integration_test
when: on_success when: on_success
only: only:
- master refs:
- /^release\/v/ - master
- /^v\d+\.\d+(\.\d+)?($|-)/ - /^release\/v/
- triggers - /^v\d+\.\d+(\.\d+)?($|-)/
- schedules - triggers
- schedules
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_INTEGRATION_TEST
dependencies: dependencies:
- assign_test - assign_test
- build_ssc_00 - build_ssc_00

View File

@ -106,9 +106,13 @@ class UnitTestAssignTest(CIAssignTest.AssignTest):
The unit test cases is stored in a yaml file which is created in job build-idf-test. The unit test cases is stored in a yaml file which is created in job build-idf-test.
""" """
with open(test_case_path, "r") as f: try:
raw_data = yaml.load(f) with open(test_case_path, "r") as f:
test_cases = raw_data["test cases"] raw_data = yaml.load(f)
test_cases = raw_data["test cases"]
except IOError:
print("Test case path is invalid. Should only happen when use @bot to skip unit test.")
test_cases = []
# filter keys are lower case. Do map lower case keys with original keys. # filter keys are lower case. Do map lower case keys with original keys.
try: try:
key_mapping = {x.lower(): x for x in test_cases[0].keys()} key_mapping = {x.lower(): x for x in test_cases[0].keys()}