-
Notifications
You must be signed in to change notification settings - Fork 0
274 lines (241 loc) · 8.98 KB
/
Copy pathshared-validation.yml
File metadata and controls
274 lines (241 loc) · 8.98 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# Unless explicitly stated otherwise all files in this repository are licensed under
# the Apache 2.0 License.
#
# This product includes software developed at Datadog
# (https://www.datadoghq.com/) Copyright 2025-Present Datadog, Inc.
name: Shared Validation
on:
workflow_call:
inputs:
# The caller sets this when a change only touches markdown or docs/
# content, allowing each validation job to skip itself while still
# surfacing a completed check in GitHub.
docs_only:
required: false
type: boolean
default: false
python_version:
required: false
type: string
default: "3.11"
run_buildifier:
required: false
type: boolean
default: false
verify_bazelrc_sync:
required: false
type: boolean
default: false
run_gofmt:
required: false
type: boolean
default: true
run_powershell_lint:
required: false
type: boolean
default: true
run_schema_validation:
required: false
type: boolean
default: false
run_fixture_json_validation:
required: false
type: boolean
default: false
run_schema_parser_parity:
required: false
type: boolean
default: false
run_rules_go_fork_drift:
required: false
type: boolean
default: false
permissions:
contents: read
env:
BUILDIFIER_VERSION: "8.2.1"
BUILDIFIER_SHA256_LINUX_AMD64: "6ceb7b0ab7cf66fceccc56a027d21d9cc557a7f34af37d2101edb56b92fcfa1a"
jobs:
shell-lint:
if: ${{ !inputs.docs_only }}
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ inputs.python_version }}
- name: Install ShellCheck
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Lint repository shell scripts
shell: bash
run: |
shellcheck --severity=error \
bazelw \
examples/common/runtests_common.sh \
examples/single_service/runtests.sh \
examples/multi_service/runtests.sh \
tools/tests/integration/*.sh \
tools/tests/python/run_python_tools_test.sh \
tools/tests/python/run_bazelw_wrapper_test.sh
- name: Install Buildifier
if: ${{ inputs.run_buildifier }}
shell: bash
run: |
curl -sSL -o /tmp/buildifier "https://github.com/bazelbuild/buildtools/releases/download/v${BUILDIFIER_VERSION}/buildifier-linux-amd64"
echo "${BUILDIFIER_SHA256_LINUX_AMD64} /tmp/buildifier" | sha256sum -c -
chmod +x /tmp/buildifier
sudo mv /tmp/buildifier /usr/local/bin/buildifier
- name: Check Starlark formatting with Buildifier
if: ${{ inputs.run_buildifier }}
shell: bash
run: |
mapfile -t starlark_files < <(
git ls-files -- \
'*.bzl' 'BUILD' 'BUILD.bazel' 'WORKSPACE' 'MODULE.bazel' \
':(exclude)third_party/rgo/**'
)
if (( ${#starlark_files[@]} == 0 )); then
echo "No Starlark files found."
exit 0
fi
buildifier -mode=check "${starlark_files[@]}"
- name: Lint embedded uploader templates (bash)
shell: bash
run: python3 tools/dev/lint_uploader_templates.py --skip-powershell-parse
- name: Verify example .bazelrc files stay in sync
if: ${{ inputs.verify_bazelrc_sync }}
shell: bash
run: |
cmp --silent examples/single_service/.bazelrc examples/multi_service/.bazelrc
gofmt-check:
if: ${{ !inputs.docs_only && inputs.run_gofmt }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Verify Go files are gofmt formatted
shell: bash
run: |
mapfile -t go_files < <(
git ls-files -- '*.go' ':(exclude)third_party/**'
)
if (( ${#go_files[@]} == 0 )); then
exit 0
fi
unformatted="$(gofmt -l "${go_files[@]}")"
if [[ -n "${unformatted}" ]]; then
echo "error: gofmt found unformatted files:"
echo "${unformatted}"
exit 1
fi
schema-validation:
if: ${{ !inputs.docs_only && inputs.run_schema_validation }}
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ inputs.python_version }}
- name: Install Python tooling dependencies
shell: bash
run: python3 -m pip install --require-hashes -r tools/requirements.txt
- name: Verify core/companion module versions are aligned
shell: bash
run: python3 tools/dev/check_module_versions.py
- name: Verify .bazelversion parity
shell: bash
run: python3 tools/dev/check_bazelversion_sync.py
- name: Validate integration fixture and snapshot JSON
if: ${{ inputs.run_fixture_json_validation }}
shell: bash
run: |
python3 - <<'PY'
import json
from pathlib import Path
files = sorted(Path("tools/tests/integration/fixtures").glob("*.json"))
files += sorted(Path("tools/tests/integration/snapshots").glob("*.json"))
for path in files:
with path.open("r", encoding="utf-8") as handle:
json.load(handle)
print(f"valid json: {path}")
PY
- name: Verify schema files are in sync
shell: bash
run: python3 tools/core/schemas/sync_agentless_schema.py --check
- name: Verify schema parser parity (PyYAML vs Ruby)
if: ${{ inputs.run_schema_parser_parity }}
shell: bash
run: python3 tools/core/schemas/check_schema_parser_parity.py
rules-go-fork-drift:
if: ${{ !inputs.docs_only && inputs.run_rules_go_fork_drift }}
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ inputs.python_version }}
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.25.0"
- name: Verify Go toolchain for generated rules_go maps
shell: bash
run: |
go version
command -v gofmt
- name: Verify rules_go fork registry and materialized trees
shell: bash
run: |
python3 tools/dev/generate_rules_go_fork_maps.py --check
RULES_GO_ORCHESTRION_CACHE="${RUNNER_TEMP}/rules_go_orchestrion_cache" \
python3 tools/dev/materialize_rules_go_fork.py check --all
python3 tools/dev/verify_rules_go_profiles.py \
--public-denylist tools/dev/private_leak_public_denylist.txt
- name: Verify rules_go fork release archive contents
shell: bash
run: python3 tools/dev/check_release_archive_contents.py
powershell-lint:
if: ${{ !inputs.docs_only && inputs.run_powershell_lint }}
timeout-minutes: 20
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ inputs.python_version }}
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) {
if (-not (Get-PackageProvider -ListAvailable -Name NuGet -ErrorAction SilentlyContinue)) {
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
}
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force -AllowClobber
}
- name: Lint integration PowerShell scripts
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path "tools/tests/integration/*.ps1" -Severity Error
if ($results) {
$results | Format-Table -AutoSize
throw "PSScriptAnalyzer found lint errors."
}
- name: Lint embedded uploader templates (PowerShell lane)
shell: pwsh
run: python tools/dev/lint_uploader_templates.py --skip-shellcheck