• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

dependencies/11-Mar-2024-572440

README.mdD11-Mar-20247.8 KiB226159

assign-test.ymlD11-Mar-20245.7 KiB169155

build.ymlD11-Mar-202411 KiB390335

deploy.ymlD11-Mar-20242.7 KiB7666

docs.ymlD11-Mar-20246.5 KiB231200

host-test.ymlD11-Mar-202410.1 KiB374324

pre_check.ymlD11-Mar-20246.6 KiB205177

rules.ymlD11-Mar-202429.8 KiB1,013856

static-code-analysis.ymlD11-Mar-20245.1 KiB131105

target-test.ymlD11-Mar-202420.2 KiB970802

README.md

1# IDF CI
2
3- [IDF CI](#idf-ci)
4  - [General Workflow](#general-workflow)
5  - [What if Expected Jobs ARE NOT Created?](#what-if-expected-jobs-are-not-created)
6  - [MR labels for additional jobs](#mr-labels-for-additional-jobs)
7    - [Supported MR Labels](#supported-mr-labels)
8    - [How to trigger a `detached` pipeline without pushing new commits?](#how-to-trigger-a-detached-pipeline-without-pushing-new-commits)
9  - [How to Develop With `rules.yml`?](#how-to-develop-with-rulesyml)
10    - [General Concepts](#general-concepts)
11    - [How to Add a New `Job`?](#how-to-add-a-new-job)
12    - [How to Add a New `Rules` Template?](#how-to-add-a-new-rules-template)
13    - [How to Add a New `if` Anchor?](#how-to-add-a-new-if-anchor)
14    - [Naming Rules](#naming-rules)
15      - [Common Naming Rules](#common-naming-rules)
16      - [`if` Anchors Naming Rules](#if-anchors-naming-rules)
17      - [`rules` Template Naming Rules](#rules-template-naming-rules)
18  - [Reusable Shell Script `tools/ci/utils.sh`](#reusable-shell-script-toolsciutilssh)
19    - [Functions](#functions)
20      - [CI Job Related](#ci-job-related)
21      - [Shell Script Related](#shell-script-related)
22
23## General Workflow
24
251. Push to a remote branch
262. Create an MR, choose related labels (not required)
273. A `detached` pipeline will be created.
284. if you push a new commit, a new pipeline will be created automatically.
29
30## What if Expected Jobs ARE NOT Created?
31
321. check the file patterns
33
34   If you found a job that is not running as expected with some file changes, a git commit to improve the `pattern` will be appreciated.
35
362. please add MR labels to run additional tests, currently we have to do this only for `target-test` jobs, please use it as few as possible. Our final goal is to remove all the labels and let the file changes decide everything!
37
38## MR labels for additional jobs
39
40### Supported MR Labels
41
42- `build`
43- `build_docs`
44- `component_ut[_esp32/esp32s2/...]`
45- `custom_test[_esp32/esp32s2/...]`
46- `docker`
47- `docs`
48- `example_test[_esp32/esp32s2/...]`
49- `fuzzer_test`
50- `host_test`
51- `integration_test`
52- `iperf_stress_test`
53- `macos`
54- `macos_test`
55- `nvs_coverage`
56- `submodule`
57- `unit_test[_esp32/esp32s2/...]`
58- `weekend_test`
59- `windows`
60
61There are two general labels (not recommended since these two labels will trigger a lot of jobs)
62
63- `target_test`: includes all target for `example_test`, `custom_test`, `component_ut`, `unit_test`, `integration_test`
64- `all_test`: includes all test labels
65
66### How to trigger a `detached` pipeline without pushing new commits?
67
68Go to MR web page -> `Pipelines` tab -> click `Run pipeline` button.
69
70In very rare case, this tab will not show up because no merge_request pipeline is created before. Please use web API then.
71
72```shell
73curl -X POST --header "PRIVATE-TOKEN: [YOUR PERSONAL ACCESS TOKEN]" [GITLAB_SERVER]/api/v4/projects/103/merge_requests/[MERGE_REQUEST_IID]/pipelines
74```
75
76## How to Develop With `rules.yml`?
77
78### General Concepts
79
80- `pattern`: Defined in an array. A GitLab job will be created if the changed files in this MR matched one of the patterns. For example:
81
82    ```yaml
83    .patterns-python-files: &patterns-python-files
84      - "**/*.py"
85    ```
86
87- `label`: Defined in an if clause, similar as the previous bot command. A GitLab job will be created if the pipeline variables contains variables in `BOT_LABEL_xxx` format (DEPRECATED) or included in the MR labels. For example:
88
89    ```yaml
90    .if-label-build_docs: &if-label-build_docs
91      if: '$BOT_LABEL_BUILD_DOCS || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*build_docs(?:,[^,\n\r]+)*$/i'
92    ```
93
94- `rule`: A combination of various patterns, and labels. It will be used by GitLab YAML `extends` keyword to tell GitLab in what conditions will this job be created. For example:
95
96    ```yaml
97    .rules:build:docs:
98      rules:
99        - <<: *if-protected
100        - <<: *if-label-build_docs
101        - <<: *if-label-docs
102        - <<: *if-dev-push
103          changes: *patterns-docs
104    ```
105
106  An example for GitLab job on how to use extends:
107
108    ```yaml
109    check_docs_lang_sync:
110      extends:
111        - .pre_check_job_template
112        - .rules:build:docs
113      script:
114        - cd docs
115        - ./check_lang_folder_sync.sh
116    ```
117
118### How to Add a New `Job`?
119
120check if there's a suitable `.rules:<rules-you-need>` template
121
1221. if there is, put this in the job `extends`. All done, now you can close this window. (`extends` could be array or string)
1232. if there isn't
124    1. check [How to Add a New `Rules` Template?](#how-to-add-a-new-rules-template), create a suitable one
125    2. follow step 1
126
127### How to Add a New `Rules` Template?
128
129check if this rule is related to `labels`, `patterns`
130
1311. if it is, please refer to [dependencies/README.md](./dependencies/README.md) and add new rules by auto-generating
1322. if it isn't, please continue reading
133
134check if there's a suitable `.if-<if-anchor-you-need>` anchor
135
1361. if there is, create a rule following [`rules` Template Naming Rules](#rules-template-naming-rules).For detail information, please refer to [GitLab Documentation `rules-if`](https://docs.gitlab.com/ee/ci/yaml/README.html#rulesif). Here's an example.
137
138    ```yaml
139    .rules:dev:
140      rules:
141        - <<: *if-trigger
142        - <<: *if-dev-push
143    ```
144
1452. if there isn't
146
147    1. check [How to Add a New `if` Anchor?](#how-to-add-a-new-if-anchor), create a suitable one
148    2. follow step 1
149
150### How to Add a New `if` Anchor?
151
152Create an `if` anchor following [`if` Anchors Naming Rules](#if-anchors-naming-rules). For detailed information about how to write the condition clause, please refer to [GitLab Documentation `only/except (advanced)](https://docs.gitlab.com/ee/ci/yaml/README.html#onlyexcept-advanced). Here's an example.
153
154```yaml
155.if-schedule: &if-schedule:
156  if: '$CI_PIPELINE_SOURCE == "schedule"'
157```
158
159### Naming Rules
160
161#### Common Naming Rules
162
163if a phrase has multi words, use `_` to concatenate them.
164
165> e.g. `regular_test`
166
167if a name has multi phrases, use `-` to concatenate them.
168
169> e.g. `regular_test-example_test`
170
171#### `if` Anchors Naming Rules
172
173- if it's a label: `.if-label-<label_name>`
174- if it's a ref: `.if-ref-<ref_name>`
175- if it's a branch: `.if-branch-<branch_name>`
176- if it's a tag: `.if-tag-<tag_name>`
177- if it's multi-type combination: `.if-ref-<release_name>-branch-<branch_name>`
178
179  **Common Phrases/Abbreviations**
180
181    - `no_label`
182
183      `$BOT_TRIGGER_WITH_LABEL == null`
184
185    - `protected`
186
187      `($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/)`
188
189    - `target_test`
190
191      a combination of `example_test`, `custom_test`, `unit_test`, `component_ut`, `integration_test` and all targets
192
193#### `rules` Template Naming Rules
194
195- if it's tag related: `.rules:tag:<tag_1>-<tag_2>`
196- if it's label related: `.rules:labels:<label_1>-<label_2>`
197- if it's test related: `.rules:test:<test_type>`
198- if it's build related: `.rules:build:<build_type>`
199- if it's pattern related: `.rules:patterns:<patterns>`
200
201## Reusable Shell Script `tools/ci/utils.sh`
202
203It is used to put all the reusable shell scripts as small functions. If you want to set `before_script: []` for you job, now you can set `extends: .before_script_slim` instead. it will only run `source tools/ci/utils.sh`
204
205If you're developing CI shell scripts, you can use these functions without `source` them. They're already included in all `before_script`
206
207To run these commands in shell script locally, place `source tools/ci/utils.sh` at the very beginning.
208
209### Functions
210
211#### CI Job Related
212
213- `add_gitlab_ssh_keys`
214- `add_github_ssh_keys`
215- `add_doc_server_ssh_keys`
216- `fetch_submodules`
217- `get_all_submodules`
218
219#### Shell Script Related
220
221- `error`: log in red color
222- `warning`: log in orange color
223- `info`: log in green color
224- `run_cmd`: run the command with duration seconds info
225- `retry_failed`: run the command with duration seconds info, retry when failed
226