You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[scripts](scripts/) - scripts used by pipelines, inside steps
9
+
-[hooks](hooks/) - [Buildkite hooks](https://buildkite.com/docs/agent/v3/hooks), where global env vars and secrets are set
10
+
11
+
## Pipeline Definitions
12
+
13
+
Pipelines are defined using YAML files residing in [pipelines](pipelines/). These are mostly static definitions that are used as-is, but there are a few dynamically-generated exceptions (see below).
14
+
15
+
### Dynamically Generated Pipelines
16
+
17
+
Pull request pipelines are generated dynamically based on labels, files changed, and other properties of pull requests.
18
+
19
+
Non-pull request pipelines that include BWC version matrices must also be generated whenever the [list of BWC versions](../.ci/bwcVersions) is updated.
20
+
21
+
#### Pull Request Pipelines
22
+
23
+
Pull request pipelines are generated dynamically at CI time based on numerous properties of the pull request. See [scripts/pull-request](scripts/pull-request) for details.
24
+
25
+
#### BWC Version Matrices
26
+
27
+
For pipelines that include BWC version matrices, you will see one or more template files (e.g. [periodic.template.yml](pipelines/periodic.template.yml)) and a corresponding generated file (e.g. [periodic.yml](pipelines/periodic.yml)). The generated file is the one that is actually used by Buildkite.
28
+
29
+
These files are updated by running:
30
+
31
+
```bash
32
+
./gradlew updateCIBwcVersions
33
+
```
34
+
35
+
This also runs automatically during release procedures.
36
+
37
+
You should always make changes to the template files, and run the above command to update the generated files.
38
+
39
+
## Node / TypeScript
40
+
41
+
Node (technically `bun`), TypeScript, and related files are currently used to generate pipelines for pull request CI. See [scripts/pull-request](scripts/pull-request) for details.
Copy file name to clipboardExpand all lines: .buildkite/scripts/pull-request/README.md
+60-8Lines changed: 60 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,7 @@ Each time a pull request build is triggered, such as via commit or comment, we u
6
6
7
7
The generator handles the following:
8
8
9
-
-`allow-labels` - only trigger a step if the PR has one of these labels
10
-
-`skip-labels` - don't trigger the step if the PR has one of these labels
11
-
-`excluded-regions` - don't trigger the step if **all** of the changes in the PR match these paths/regexes
12
-
-`included-regions` - trigger the step if **all** of the changes in the PR match these paths/regexes
13
-
-`trigger-phrase` - trigger this step, and ignore all other steps, if the build was triggered by a comment and that comment matches this regex
14
-
- Note that each step has an automatic phrase of `.*run\\W+elasticsearch-ci/<step-name>.*`
9
+
- Various configurations for filtering/activating steps based on labels, changed files, etc. See below.
15
10
- Replacing `$SNAPSHOT_BWC_VERSIONS` in pipelines with an array of versions from `.ci/snapshotBwcVersions`
16
11
- Duplicating any step with `bwc_template: true` for each BWC version in `.ci/bwcVersions`
17
12
@@ -21,18 +16,75 @@ The generator handles the following:
21
16
22
17
Pipelines are in [`.buildkite/pipelines`](../../pipelines/pull-request). They are automatically picked up and given a name based on their filename.
23
18
24
-
25
19
## Setup
26
20
27
21
-[Install bun](https://bun.sh/)
28
22
-`npm install -g bun` will work if you already have `npm`
29
23
-`cd .buildkite; bun install` to install dependencies
30
24
31
-
## Run tests
25
+
## Testing
26
+
27
+
Testing the pipeline generator is done mostly using snapshot tests, which generate pipeline objects using the pipeline configurations in `mocks/pipelines` and then compare them to previously-generated snapshots in `__snapshots__` to confirm that they are correct.
28
+
29
+
The mock pipeline configurations should, therefore, try to cover all of the various features of the generator (allow-labels, skip-labels, etc).
30
+
31
+
Snapshots are generated/managed automatically whenever you create a new test that has a snapshot test condition. These are very similar to Jest snapshots.
32
+
33
+
### Run tests
32
34
33
35
```bash
34
36
cd .buildkite
35
37
bun test
36
38
```
37
39
38
40
If you need to regenerate the snapshots, run `bun test --update-snapshots`.
41
+
42
+
## Pipeline Configuration
43
+
44
+
The `config:` property at the top of pipelines inside `.buildkite/pipelines/pull-request` is a custom property used by our pipeline generator. It is not used by Buildkite.
45
+
46
+
All of the pipelines in this directory are evaluated whenever CI for a pull request is started, and the steps are filtered and combined into one pipeline based on the properties in `config:` and the state of the pull request.
47
+
48
+
The various configurations available mirror what we were using in our Jenkins pipelines.
49
+
50
+
### Config Properties
51
+
52
+
#### `allow-labels`
53
+
54
+
- Type: `string|string[]`
55
+
- Example: `["test-full-bwc"]`
56
+
57
+
Only trigger a step if the PR has one of these labels.
58
+
59
+
#### `skip-labels`
60
+
61
+
- Type: `string|string[]`
62
+
- Example: `>test-mute`
63
+
64
+
Don't trigger the step if the PR has one of these labels.
65
+
66
+
#### `excluded-regions`
67
+
68
+
- Type: `string|string[]` - must be JavaScript regexes
69
+
- Example: `["^docs/.*", "^x-pack/docs/.*"]`
70
+
71
+
Exclude the pipeline if all of the changed files in the PR match at least one regex. E.g. for the example above, don't run the step if all of the changed files are docs changes.
72
+
73
+
#### `included-regions`
74
+
75
+
- Type: `string|string[]` - must be JavaScript regexes
76
+
- Example: `["^docs/.*", "^x-pack/docs/.*"]`
77
+
78
+
Only include the pipeline if all of the changed files in the PR match at least one regex. E.g. for the example above, only run the step if all of the changed files are docs changes.
79
+
80
+
This is particularly useful for having a step that only runs, for example, when all of the other steps get filtered out because of the `excluded-regions` property.
- Default: `.*run\\W+elasticsearch-ci/<step-name>.*` (`<step-name>` is generated from the filename of the yml file).
87
+
88
+
Trigger this step, and ignore all other steps, if the build was triggered by a comment and that comment matches this regex.
89
+
90
+
Note that the entire build itself is triggered via [`.buildkite/pull-requests.json`](../pull-requests.json). So, a comment has to first match the trigger configured there.
0 commit comments