Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# `ci/component/bazelisk`
> A GitLab CI component for running Bazel builds
## Getting Started
Add the CI component to the `.gitlab-ci.yml`:
```yaml
include:
- component: gitlab.arm.com/ci/component/bazelisk@<version>
```
Add a job that extends the `.bazelisk` template to recursively test the project:
```yaml
test:
extends: .bazelisk
```
## Variables
The template has some environment variables that can customise the job behaviour.
### `ROOT`
To run `bazelisk` in multiple root directories:
```yaml
test:
extends: .bazelisk
parallel:
matrix:
- ROOT:
- .
- e2e
```
### `USE_BAZEL_VERSION`
`bazelisk` will download a version of Bazel as described in the [documentation][bazelisk-download].
To run against multiple versions of Bazel:
```yaml
test:
extends: .bazelisk
parallel:
matrix:
- USE_BAZEL_VERSION:
- 6.3.1
- 7.0.0
```
## Open Container Image (OCI)
The default image has `bazelisk` available on `PATH` and a minimal set of core utilities to satisfy GitLab CI job bring-up and built-in Bazel scripts.
The intention is that this image helps prove the hermeticity of a Bazel build as all tools will need to be resolved hermetically.
To use a different base image, override the image input for the component:
```yaml
include:
- component: gitlab.arm.com/ci/component/bazelisk@<version>
inputs:
image: host.com/some/registry/bazelisk
tag: latest
```
## YAML References
The `.bazelisk` template provides a simple way to invoke `bazelisk` in a job.
GitLab CI has [`!reference`][gitlab-ci-reference] feature that allows parts of a template to be re-used in a fine grained way.
It is recommended to use this feature to build up a custom `bazelisk` job by using `!reference` to select parts of the `.bazelisk` image that are relevant.
Commonly, this is used to customise the `script` section of a job but still re-using parts of the `.bazelisk` template script:
```yaml
custom:
extends: .bazelisk
script:
- !reference [.bazelisk, rc]
- bazelisk build //...
- bazelisk run //...
```
[gitlab-ci-reference]: https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#reference-tags
[bazelisk-download]: https://github.com/bazelbuild/bazelisk#how-does-bazelisk-know-which-bazel-version-to-run