1.assign_test_template:
2  image: $CI_DOCKER_REGISTRY/ubuntu-test-env$BOT_DOCKER_IMAGE_TAG
3  stage: assign_test
4  tags:
5    - assign_test
6  variables:
7    SUBMODULES_TO_FETCH: components/esptool_py/esptool
8  artifacts:
9    paths:
10      - ${TEST_DIR}/test_configs
11      - ${BUILD_DIR}/artifact_index.json
12    when: always
13    expire_in: 1 week
14  script:
15    - python tools/ci/python_packages/ttfw_idf/IDFAssignTest.py $TEST_TYPE $TEST_DIR -c $CI_TARGET_TEST_CONFIG_FILE -o $TEST_DIR/test_configs
16
17assign_example_test:
18  extends:
19    - .assign_test_template
20    - .rules:build:example_test
21  needs:
22    - job: build_examples_cmake_esp32
23      artifacts: false
24      optional: true
25    - job: build_examples_cmake_esp32s2
26      artifacts: false
27      optional: true
28    - job: build_examples_cmake_esp32c3
29      artifacts: false
30      optional: true
31    - job: build_examples_cmake_esp32s3
32      artifacts: false
33      optional: true
34  variables:
35    TEST_TYPE: example_test
36    TEST_DIR: ${CI_PROJECT_DIR}/examples
37    BUILD_DIR: ${CI_PROJECT_DIR}/build_examples
38
39assign_custom_test:
40  extends:
41    - .assign_test_template
42    - .rules:build:custom_test
43  needs:
44    - job: build_test_apps_esp32
45      artifacts: false
46      optional: true
47    - job: build_test_apps_esp32s2
48      artifacts: false
49      optional: true
50    - job: build_test_apps_esp32c3
51      artifacts: false
52      optional: true
53    - job: build_test_apps_esp32s3
54      artifacts: false
55      optional: true
56  variables:
57    TEST_TYPE: custom_test
58    TEST_DIR: ${CI_PROJECT_DIR}/tools/test_apps
59    BUILD_DIR: ${CI_PROJECT_DIR}/build_test_apps
60
61assign_component_ut:
62  extends:
63    - .assign_test_template
64    - .rules:build:component_ut
65  needs:
66    - job: build_component_ut_esp32
67      artifacts: false
68      optional: true
69    - job: build_component_ut_esp32s2
70      artifacts: false
71      optional: true
72    - job: build_component_ut_esp32c3
73      artifacts: false
74      optional: true
75    - job: build_component_ut_esp32s3
76      artifacts: false
77      optional: true
78  variables:
79    TEST_TYPE: component_ut
80    TEST_DIR: ${CI_PROJECT_DIR}/component_ut
81    BUILD_DIR: ${CI_PROJECT_DIR}/build_component_ut
82  script:
83    # COMPONENT_UT_DIRS is set by `set_component_ut_vars` in `utils.sh`
84    - set_component_ut_vars
85    - python tools/ci/python_packages/ttfw_idf/IDFAssignTest.py $TEST_TYPE $COMPONENT_UT_DIRS -c $CI_TARGET_TEST_CONFIG_FILE -o $TEST_DIR/test_configs
86
87assign_unit_test:
88  extends:
89    - .assign_test_template
90    - .rules:build:unit_test
91  needs:
92    - job: build_esp_idf_tests_cmake_esp32
93      optional: true
94    - job: build_esp_idf_tests_cmake_esp32s2
95      optional: true
96    - job: build_esp_idf_tests_cmake_esp32c3
97      optional: true
98    - job: build_esp_idf_tests_cmake_esp32s3
99      optional: true
100  variables:
101    TEST_TYPE: unit_test
102    TEST_DIR: ${CI_PROJECT_DIR}/components/idf_test/unit_test
103    BUILD_DIR: ${CI_PROJECT_DIR}/tools/unit-test-app/builds
104  script:
105    - python tools/ci/python_packages/ttfw_idf/IDFAssignTest.py $TEST_TYPE $TEST_DIR -c $CI_TARGET_TEST_CONFIG_FILE -o $TEST_DIR/test_configs
106
107assign_integration_test:
108  extends:
109    - .assign_test_template
110    - .rules:test:integration_test
111  needs:
112    - build_ssc_esp32
113    - build_ssc_esp32c3
114  artifacts:
115    paths:
116      - $TEST_DIR/test_configs
117  variables:
118    TEST_DIR: ${CI_PROJECT_DIR}/tools/ci/integration_test
119    BUILD_DIR: ${CI_PROJECT_DIR}/SSC/ssc_bin
120    INTEGRATION_TEST_CASE_PATH: "${CI_PROJECT_DIR}/auto_test_script/TestCaseFiles"
121    ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py"
122    PYTHONPATH: ${CI_PROJECT_DIR}/auto_test_script/packages
123    PYTHON_VER: 3.7.7
124  script:
125    # clone test script to assign tests
126    # can not retry if downing git lfs files failed, so using empty_branch first.
127    - retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
128    - retry_failed git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
129    - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script --customized_only
130    # assign integration test cases
131    - python ${ASSIGN_TEST_CASE_SCRIPT} -t ${INTEGRATION_TEST_CASE_PATH} -c $CI_TARGET_TEST_CONFIG_FILE -b ${BUILD_DIR} -o $TEST_DIR/test_configs
132
133update_test_cases:
134  extends: .rules:ref:master-schedule
135  stage: assign_test
136  image: $CI_DOCKER_REGISTRY/ubuntu-test-env
137  tags:
138    - deploy_test
139  needs:
140    - build_esp_idf_tests_cmake_esp32
141    - build_esp_idf_tests_cmake_esp32s2
142    - build_esp_idf_tests_cmake_esp32s3
143    - build_esp_idf_tests_cmake_esp32c3
144  artifacts:
145    when: always
146    paths:
147      - ${CI_PROJECT_DIR}/test-management/*.log
148    expire_in: 1 week
149  variables:
150    SUBMODULES_TO_FETCH: "components/esptool_py/esptool"
151    UNIT_TEST_DIR: "${CI_PROJECT_DIR}/components/idf_test/unit_test"
152    BOT_ACCOUNT_CONFIG_FILE: "${CI_PROJECT_DIR}/test-management/Config/Account.local.yml"
153    PYTHONPATH: ${CI_PROJECT_DIR}/auto_test_script/packages
154    PYTHON_VER: 3.7.7
155  script:
156    - export GIT_SHA=$(echo ${PIPELINE_COMMIT_SHA} | cut -c 1-8)
157    - retry_failed git clone $TEST_MANAGEMENT_REPO
158    - python $CHECKOUT_REF_SCRIPT test-management test-management
159    - cd test-management
160    - echo $BOT_JIRA_ACCOUNT > ${BOT_ACCOUNT_CONFIG_FILE}
161    # update unit test cases
162    - export UNIT_TEST_CASE_FILES=$(find $UNIT_TEST_DIR -maxdepth 1 -name "*.yml" | xargs)
163    - python ImportTestCase.py $JIRA_TEST_MANAGEMENT_PROJECT unity -d $UNIT_TEST_CASE_FILES -r $GIT_SHA
164    # update example test cases
165    - python ImportTestCase.py $JIRA_TEST_MANAGEMENT_PROJECT tiny_test_fw -d ${CI_PROJECT_DIR}/examples -r $GIT_SHA
166    - python ImportTestCase.py $JIRA_TEST_MANAGEMENT_PROJECT tiny_test_fw -d ${CI_PROJECT_DIR}/tools/test_apps -r $GIT_SHA
167    # organize test cases
168    - python OrganizeTestCases.py $JIRA_TEST_MANAGEMENT_PROJECT
169