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 committed by bot
parent 7c29a39d6f
commit 722a7e3b53
2 changed files with 122 additions and 26 deletions

View file

@ -6,6 +6,7 @@ stages:
- integration_test
- check
- deploy
- post_check
variables:
# System environment
@ -114,6 +115,11 @@ build_template_app:
variables:
BATCH_BUILD: "1"
IDF_CI_BUILD: "1"
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_REGULAR_TEST
script:
- git clone https://github.com/espressif/esp-idf-template.git
- cd esp-idf-template
@ -150,6 +156,12 @@ build_template_app:
expire_in: 1 week
variables:
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:
- git clone $SSC_REPOSITORY
- cd SSC
@ -176,6 +188,12 @@ build_esp_idf_tests:
- components/idf_test/unit_test/TestCaseAll.yml
- components/idf_test/unit_test/CIConfigs/*.yml
expire_in: 2 days
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_UNIT_TEST
- $BOT_LABEL_REGULAR_TEST
script:
- export PATH="$IDF_PATH/tools:$PATH"
- cd $CI_PROJECT_DIR/tools/unit-test-app
@ -214,6 +232,12 @@ build_esp_idf_tests:
variables:
IDF_CI_BUILD: "1"
LOG_PATH: "$CI_PROJECT_DIR/log_examples_make"
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_EXAMPLE_TEST
- $BOT_LABEL_REGULAR_TEST
script:
# it's not possible to build 100% out-of-tree and have the "artifacts"
# mechanism work, but this is the next best thing
@ -241,6 +265,12 @@ build_esp_idf_tests:
variables:
IDF_CI_BUILD: "1"
LOG_PATH: "$CI_PROJECT_DIR/log_examples_cmake"
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_EXAMPLE_TEST
- $BOT_LABEL_REGULAR_TEST
script:
# it's not possible to build 100% out-of-tree and have the "artifacts"
# mechanism work, but this is the next best thing
@ -321,6 +351,12 @@ build_docs:
- docs/zh_CN/sphinx-warning-log-sanitized.txt
- docs/zh_CN/_build/html
expire_in: 1 day
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_BUILD_DOCS
- $BOT_LABEL_REGULAR_TEST
script:
- cd docs
- ./check_lang_folder_sync.sh
@ -336,6 +372,11 @@ build_docs:
verify_cmake_style:
stage: build
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:
tools/cmake/run_cmake_lint.sh
@ -345,6 +386,11 @@ verify_cmake_style:
tags:
- host_test
dependencies: []
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_HOST_TEST
- $BOT_LABEL_REGULAR_TEST
test_nvs_on_host:
<<: *host_test_template
@ -359,10 +405,10 @@ test_nvs_coverage:
- components/nvs_flash/test_nvs_host/coverage_report
expire_in: 1 week
only:
- triggers
# This job takes a few hours to finish, so only run it on demand
variables:
BOT_NEEDS_TRIGGER_BY_NAME: 1
refs:
- triggers
variables:
- $BOT_LABEL_NVS_COVERAGE
script:
- cd components/nvs_flash/test_nvs_host
- make coverage_report
@ -404,8 +450,11 @@ test_fatfs_on_host:
- ${FUZZER_TEST_DIR}/fuzz_output.log
expire_in: 1 week
only:
# can only be triggered
- triggers
refs:
# can only be triggered
- triggers
variables:
- $BOT_LABEL_FUZZER_TEST
script:
- export AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 && export AFL_SKIP_CPUFREQ=1
- cd ${FUZZER_TEST_DIR}
@ -551,15 +600,19 @@ push_to_github:
- tools/ci/push_to_github.sh
deploy_docs:
stage: host_test
stage: deploy
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
tags:
- deploy
only:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
refs:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD_DOCS
dependencies:
- build_docs
before_script: *do_nothing_before
@ -591,8 +644,12 @@ check_doc_links:
tags:
- check_doc_links
only:
# can only be triggered
- triggers
refs:
# can only be triggered
- triggers
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD_DOCS
artifacts:
paths:
- docs/_build/linkcheck
@ -669,6 +726,17 @@ check_artifacts_expire_time:
# check if we have set expire time for all artifacts
- python tools/ci/check_artifacts_expire_time.py
check_pipeline_triggered_by_label:
<<: *check_job_template
stage: post_check
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:
tags:
- assign_test
@ -690,6 +758,12 @@ assign_test:
- components/idf_test/*/TC.sqlite
- $EXAMPLE_CONFIG_OUTPUT_PATH
expire_in: 1 week
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
script:
# assign example tests
@ -707,11 +781,15 @@ assign_test:
stage: integration_test
when: on_success
only:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
- schedules
refs:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
- schedules
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_EXAMPLE_TEST
dependencies:
- assign_test
- build_examples_make_00
@ -758,6 +836,16 @@ assign_test:
dependencies:
- assign_test
- 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:
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
TEST_CASE_PATH: "$CI_PROJECT_DIR/tools/unit-test-app"
@ -769,11 +857,15 @@ assign_test:
stage: integration_test
when: on_success
only:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
- schedules
refs:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
- triggers
- schedules
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_INTEGRATION_TEST
dependencies:
- assign_test
- 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.
"""
with open(test_case_path, "r") as f:
raw_data = yaml.load(f)
test_cases = raw_data["test cases"]
try:
with open(test_case_path, "r") as f:
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.
try:
key_mapping = {x.lower(): x for x in test_cases[0].keys()}