-
Notifications
You must be signed in to change notification settings - Fork 2
219 lines (203 loc) · 6.58 KB
/
module.build.yml
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
name: "Build"
"on":
workflow_dispatch:
inputs:
## Runner to use
runner:
description: "Runner"
type: string
default: "ubuntu-latest"
## Whether to build with bzlmod
bzlmod:
description: "Enable Bzlmod"
type: boolean
default: false
## Whether to run tests
tests:
description: "Run Tests"
type: boolean
default: true
## Whether we should run integration tests (main target)
main:
description: "Main target"
type: boolean
default: false
## Whether we should report coverage
coverage:
description: "Coverage"
type: boolean
default: false
## Bazel version to use
bazel_version:
description: "Bazel version"
type: string
default: "6.3.2"
## Configuration profile to use
bazel_config:
description: "Bazel profile"
type: string
default: "bazel6"
## Additional flags to pass to Bazel
flags:
description: "Flags"
type: string
default: ""
workflow_call:
inputs:
runner:
description: "Runner"
type: string
default: "ubuntu-latest"
label:
description: "Label"
type: string
default: "Ubuntu"
bzlmod:
description: "Enable Bzlmod"
type: boolean
default: false
tests:
description: "Run Tests"
type: boolean
default: true
labs:
description: "Skip Failures"
type: boolean
default: false
bazel_version:
description: "Bazel version"
type: string
default: "6.3.2"
bazel_config:
description: "Bazel profile"
type: string
default: "bazel6"
main:
description: "Main target"
type: boolean
default: false
flags:
description: "Flags"
type: string
default: ""
coverage:
description: "Coverage"
type: boolean
default: false
secrets:
## Secrets: BuildBuddy API key
BUILDBUDDY_APIKEY:
required: false
## Secrets: Buildless API key
BUILDLESS_APIKEY:
required: false
## Secrets: Codecov Reporting Token
CODECOV_TOKEN:
required: false
env:
BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }}
BUILDBUDDY_APIKEY: ${{ secrets.BUILDBUDDY_APIKEY }}
jobs:
build:
name: "Build"
runs-on: ${{ inputs.runner || 'ubuntu-latest' }}
continue-on-error: ${{ inputs.labs }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit
- name: "Setup: Checkout"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Setup: msbuild"
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
if: ${{ contains(inputs.runner, 'windows') }}
- name: "Setup: Bazel"
uses: bazelbuild/setup-bazelisk@95c9bf48d0c570bb3e28e57108f3450cd67c1a44 # v2.0.0
- name: "Setup: Cache"
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: "~/.cache/bazel"
key: bazel-v3
- name: "Configure: Bazel Services"
shell: bash
if: contains(env.BUILDLESS_APIKEY || '', 'user_')
run: |
echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_APIKEY }}" >> local.bazelrc
echo "build --remote_header=x-api-key=${{ secrets.BUILDLESS_APIKEY }}" >> local.bazelrc
- name: "Configure: Bzlmod"
if: inputs.bzlmod
run: |
echo "build --config=bzlmod" >> local.bazelrc
- name: "Build: Project"
continue-on-error: ${{ inputs.labs }}
shell: bash
run: bazel build --config=ci ${{ inputs.flags }} "//e2e/project"
- name: "Testsuite"
continue-on-error: ${{ inputs.labs }}
if: inputs.coverage
shell: bash
run: bazel coverage --config=ci ${{ inputs.flags }} "//tools/..." "//javatests/..." "//.aspect/..."
- name: "Report: Coverage"
uses: codecov/codecov-action@v3
if: inputs.coverage
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: bazel-out/_coverage/_coverage_report.dat
flags: tools
verbose: true
fail_ci_if_error: true # optional (default = false)
integration-tests:
name: ${{ matrix.label }}
runs-on: ${{ inputs.runner || 'ubuntu-latest' }}
continue-on-error: ${{ inputs.labs || matrix.labs }}
if: inputs.main
strategy:
fail-fast: false
matrix:
label: ["E2E Basic"]
target: ["//e2e/project"]
action: ["build"]
directory: ["."]
labs: [false]
skip: [false]
include:
# Test: E2E Sample
- label: E2E Basic
target: //e2e/project
action: build
directory: "."
labs: false
skip: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit
- name: "Setup: Checkout"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Setup: msbuild"
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
if: ${{ contains(inputs.runner, 'windows') }}
- name: "Setup: Bazel"
uses: bazelbuild/setup-bazelisk@95c9bf48d0c570bb3e28e57108f3450cd67c1a44 # v2.0.0
- name: "Configure: Bazel Version"
shell: bash
if: matrix.skip != true && inputs.bazel_version != '' && inputs.bazel_config != ''
run: |
echo "${{ inputs.bazel_version }}" > .bazelversion
echo "import %workspace%/tools/bazel/${{ inputs.bazel_config }}.bazelrc" > version.bazelrc
- name: "Configure: Bazel Services"
shell: bash
if: contains(env.BUILDLESS_APIKEY || '', 'user_')
run: |
echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_APIKEY }}" >> local.bazelrc
echo "build --remote_header=x-api-key=${{ secrets.BUILDLESS_APIKEY }}" >> local.bazelrc
- name: "Test: ${{ matrix.label }}"
if: matrix.skip == false
continue-on-error: ${{ inputs.labs }}
working-directory: ${{ matrix.directory }}
shell: bash
run: bazel ${{ matrix.action || 'build' }} "${{ matrix.target || '//...' }}"