1.pre_check_base_template:
2  stage: pre_check
3  image: $ESP_ENV_IMAGE
4  tags:
5    - host_test
6  dependencies: []
7
8.pre_check_job_template:
9  extends:
10    - .pre_check_base_template
11    - .before_script_no_sync_submodule
12
13.check_pre_commit_template:
14  extends: .pre_check_job_template
15  image: "$CI_DOCKER_REGISTRY/esp-idf-pre-commit:1"
16  before_script:
17    - source tools/ci/utils.sh
18    - export PYTHONPATH="$CI_PROJECT_DIR/tools:$CI_PROJECT_DIR/tools/ci/python_packages:$PYTHONPATH"
19
20check_pre_commit_master_release:
21  extends:
22    - .check_pre_commit_template
23    - .rules:protected
24  script:
25    - git diff-tree --no-commit-id --name-only -r $PIPELINE_COMMIT_SHA | xargs pre-commit run --files
26
27check_pre_commit_MR:
28  extends:
29    - .check_pre_commit_template
30    - .rules:dev
31  script:
32    - python ${CI_PROJECT_DIR}/tools/ci/ci_get_mr_info.py files ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} | xargs pre-commit run --files
33
34check_version:
35  # Don't run this for feature/bugfix branches, so that it is possible to modify
36  # esp_idf_version.h in a branch before tagging the next version.
37  extends:
38    - .pre_check_job_template
39    - .rules:protected
40  script:
41    - export IDF_PATH=$PWD
42    - tools/ci/check_idf_version.sh
43
44check_examples_cmake_make:
45  extends: .pre_check_job_template
46  script:
47  - python ${IDF_PATH}/tools/ci/check_examples_cmake_make.py
48
49check_rom_api_header:
50  extends: .pre_check_job_template
51  script:
52    - tools/ci/check_examples_rom_header.sh
53    - tools/ci/check_api_violation.sh
54
55check_python_style:
56  extends:
57    - .pre_check_base_template
58    - .rules:patterns:python-files
59  variables:
60    PYTHON_VER: 3.6.13
61  artifacts:
62    when: on_failure
63    paths:
64      - flake8_output.txt
65    expire_in: 1 week
66  script:
67    - python -m flake8 --config=$IDF_PATH/.flake8 --output-file=flake8_output.txt --tee --benchmark $IDF_PATH
68
69test_check_kconfigs:
70  extends: .pre_check_job_template
71  variables:
72    PYTHON_VER: 3.6.13
73  artifacts:
74    when: on_failure
75    paths:
76      - components/*/Kconfig*.new
77      - examples/*/*/*/Kconfig*.new
78      - examples/*/*/*/*/Kconfig*.new
79      - tools/*/Kconfig*.new
80      - tools/*/*/Kconfig*.new
81      - tools/*/*/*/Kconfig*.new
82    expire_in: 1 week
83  script:
84    - python ${IDF_PATH}/tools/ci/test_check_kconfigs.py
85
86check_blobs:
87  extends: .pre_check_base_template
88  tags:
89    - build
90  variables:
91    SUBMODULES_TO_FETCH: "components/esp_wifi/lib;components/esp_phy/lib"
92  script:
93    # Check if Wi-Fi library header files match between IDF and the version used when compiling the libraries
94    - IDF_TARGET=esp32 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
95    - IDF_TARGET=esp32s2 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
96    - IDF_TARGET=esp32s3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
97    - IDF_TARGET=esp32c3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
98    # Check if Wi-Fi, PHY, BT blobs contain references to specific symbols
99    - bash $IDF_PATH/tools/ci/check_blobs.sh
100
101check_fuzzer_compilation:
102   extends: .pre_check_base_template
103   image: $AFL_FUZZER_TEST_IMAGE
104   script:
105     - cd ${IDF_PATH}/components/lwip/test_afl_host
106     - make MODE=dhcp_server
107     - make MODE=dhcp_client
108     - make MODE=dns
109     - cd ${IDF_PATH}/components/mdns/test_afl_fuzz_host
110     - make
111
112check_public_headers:
113  extends:
114    - .pre_check_base_template
115    - .rules:build
116  tags:
117    - build
118  script:
119    - python tools/ci/check_public_headers.py --jobs 4 --prefix xtensa-esp32-elf-
120
121check_soc_struct_headers:
122  extends:
123    - .pre_check_base_template
124    - .rules:build
125  tags:
126    - build
127  script:
128    - find ${IDF_PATH}/components/soc/*/include/soc/ -name "*_struct.h" -print0 | xargs -0 -n1 ./tools/ci/check_soc_struct_headers.py
129
130check_esp_err_to_name:
131  extends:
132    - .pre_check_base_template
133    - .rules:build
134  tags:
135    - build
136  artifacts:
137    when: on_failure
138    paths:
139      - components/esp_common/esp_err_to_name.c
140    expire_in: 1 week
141  script:
142    - cd ${IDF_PATH}/tools/
143    - ./gen_esp_err_to_name.py
144    - git diff --exit-code -- ../components/esp_common/src/esp_err_to_name.c || { echo 'Differences found. Please run gen_esp_err_to_name.py and commit the changes.'; exit 1; }
145
146scan_tests:
147  extends:
148    - .pre_check_base_template
149    - .rules:build:target_test
150  image: $CI_DOCKER_REGISTRY/ubuntu-test-env$BOT_DOCKER_IMAGE_TAG
151  tags:
152    - assign_test
153  artifacts:
154    paths:
155      - $EXAMPLE_TEST_OUTPUT_DIR
156      - $TEST_APPS_OUTPUT_DIR
157      - $COMPONENT_UT_OUTPUT_DIR
158  variables:
159    EXAMPLE_TEST_DIR: ${CI_PROJECT_DIR}/examples
160    EXAMPLE_TEST_OUTPUT_DIR: ${CI_PROJECT_DIR}/examples/test_configs
161    TEST_APPS_TEST_DIR: ${CI_PROJECT_DIR}/tools/test_apps
162    TEST_APPS_OUTPUT_DIR: ${CI_PROJECT_DIR}/tools/test_apps/test_configs
163    COMPONENT_UT_OUTPUT_DIR: ${CI_PROJECT_DIR}/component_ut/test_configs
164    CI_SCAN_TESTS_PY: ${CI_PROJECT_DIR}/tools/ci/python_packages/ttfw_idf/CIScanTests.py
165    EXTRA_TEST_DIRS: >-
166      examples/bluetooth/esp_ble_mesh/ble_mesh_console
167      examples/bluetooth/hci/controller_hci_uart_esp32
168      examples/wifi/iperf
169  script:
170    - set_component_ut_vars
171    - run_cmd python $CI_SCAN_TESTS_PY example_test $EXAMPLE_TEST_DIR -b make --exclude examples/build_system/idf_as_lib -c $CI_TARGET_TEST_CONFIG_FILE -o $EXAMPLE_TEST_OUTPUT_DIR
172    - run_cmd python $CI_SCAN_TESTS_PY example_test $EXAMPLE_TEST_DIR -b cmake --exclude examples/build_system/idf_as_lib -c $CI_TARGET_TEST_CONFIG_FILE -o $EXAMPLE_TEST_OUTPUT_DIR --extra_test_dirs $EXTRA_TEST_DIRS
173    - run_cmd python $CI_SCAN_TESTS_PY test_apps $TEST_APPS_TEST_DIR -c $CI_TARGET_TEST_CONFIG_FILE -o $TEST_APPS_OUTPUT_DIR
174    - run_cmd python $CI_SCAN_TESTS_PY component_ut $COMPONENT_UT_DIRS --exclude $COMPONENT_UT_EXCLUDES -c $CI_TARGET_TEST_CONFIG_FILE -o $COMPONENT_UT_OUTPUT_DIR
175
176# For release tag pipelines only, make sure the tag was created with 'git tag -a' so it will update
177# the version returned by 'git describe'
178check_version_tag:
179  extends:
180    - .pre_check_job_template
181    - .rules:tag:release
182  script:
183    - (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || (echo "ESP-IDF versions must be annotated tags." && exit 1)
184
185check_ut_cmake_make:
186  extends: .pre_check_job_template
187  tags:
188    - build
189  script:
190    - tools/ci/check_ut_cmake_make.sh
191
192check_artifacts_expire_time:
193  extends: .pre_check_job_template
194  script:
195    # check if we have set expire time for all artifacts
196    - python tools/ci/check_artifacts_expire_time.py
197
198check_commit_msg:
199  extends: .pre_check_job_template
200  script:
201    - git status
202    - git log -n10 --oneline ${PIPELINE_COMMIT_SHA}
203    # commit start with "WIP: " need to be squashed before merge
204    - 'git log --pretty=%s origin/master..${PIPELINE_COMMIT_SHA} -- | grep -i "^WIP:" && exit 1 || exit 0'
205