-
Notifications
You must be signed in to change notification settings - Fork 17
186 lines (175 loc) · 6.23 KB
/
_bazel_registry.yml
File metadata and controls
186 lines (175 loc) · 6.23 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
name: _bazel_registry
permissions:
contents: read
on:
workflow_call:
inputs:
metadata:
default: metadata.json
description: Metadata file
type: string
module:
description: Module name
required: true
type: string
modules-root:
default: bazel-registry
description: Path to modules root dir
type: string
source:
default: source.json
description: Source file
type: string
template-integrity:
type: string
default: |
export SOURCE_URL=\"\(.url)\"
export MODULE=\"\($module)\"
export MODULE_VERSION=\"\($module_version)\"
export MODULES_ROOT=\"\($modules_root)\"
OUTPUT=\"$($GITHUB_WORKSPACE/.github/workflows/registry_integrity.sh)\"
jobs:
module:
runs-on: ubuntu-24.04
name: Bazel module (${{ inputs.module }})
outputs:
versions: ${{ steps.versions.outputs.value }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: envoyproxy/toolshed/actions/jq@5e0c5734ee7fc8a30629bd3f54fc910f92285bbe
id: versions
with:
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ inputs.metadata }}
input-format: json-path
filter: |
.versions
| map(select(. | endswith(".envoy")))
version:
if: >-
needs.module.outputs.versions != '[]'
runs-on: ubuntu-24.04
needs:
- module
name: Bazel module version (${{ inputs.module }}:${{ matrix.version }})
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.module.outputs.versions) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: envoyproxy/toolshed/actions/jq@5e0c5734ee7fc8a30629bd3f54fc910f92285bbe
with:
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ matrix.version }}/${{ inputs.source }}
input-format: json-path
print-result: true
- uses: envoyproxy/toolshed/actions/bson@5e0c5734ee7fc8a30629bd3f54fc910f92285bbe
id: source
with:
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ matrix.version }}/${{ inputs.source }}
input-format: json-path
filter: |
.
| "${{ inputs.module }}" as $module
| "${{ matrix.version }}" as $module_version
| "${{ inputs.modules-root }}" as $modules_root
| "${{ inputs.template-integrity }}"
| bash::output
result-filter-options: -sRc
result-filter: |
split("\n")
| map(select(length > 0) | split(" ") | {key: .[0], value: .[1]})
| from_entries
- uses: envoyproxy/toolshed/actions/bson@5e0c5734ee7fc8a30629bd3f54fc910f92285bbe
with:
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ matrix.version }}/${{ inputs.source }}
input-format: json-path
filter: |
. as $source
| ${{ steps.source.outputs.output }} as $actual
# Check main integrity
| (if $source.integrity != $actual.integrity then
{
result: "::error::✗ Integrity does not match (actual: \($actual.integrity), expected: \($source.integrity))",
error: true
}
else
{
result: "✓ Integrity matches \($actual.integrity)",
error: false
}
end) as $integrity_check
# Check overlay files
| (if $source.overlay then
[
$source.overlay
| to_entries[]
| . as $entry
| if $actual["overlay:\($entry.key)"] then
if $entry.value != $actual["overlay:\($entry.key)"] then
{
result: (
"::error::✗ Overlay \($entry.key) does not match " +
"(actual: \($actual["overlay:\($entry.key)"]), expected: \($entry.value))"
),
error: true
}
else
{
result: "✓ Overlay \($entry.key) matches \($entry.value)",
error: false
}
end
else
{
result: "::error::✗ Overlay \($entry.key) not found in calculated checksums",
error: true
}
end
]
else
[]
end) as $overlay_checks
# Check patch files
| (if $source.patches then
[
$source.patches
| to_entries[]
| . as $entry
| if $actual["patches:\($entry.key)"] then
if $entry.value != $actual["patches:\($entry.key)"] then
{
result: (
"::error::✗ Patch \($entry.key) does not match " +
"(actual: \($actual["patches:\($entry.key)"]), expected: \($entry.value))"
),
error: true
}
else
{
result: "✓ Patch \($entry.key) matches \($entry.value)",
error: false
}
end
else
{
result: "::error::✗ Patch \($entry.key) not found in calculated checksums",
error: true
}
end
]
else
[]
end) as $patch_checks
# Combine all checks
| ([$integrity_check] + $overlay_checks + $patch_checks) as $checks
# Determine if any errors occurred
| ($checks | map(select(.error)) | length > 0) as $has_errors
# Generate bash script
| $checks
| map("echo \"\(.result)\" >&2")
| join("\n")
| if $has_errors then
. + "\nexit 1"
else
.
end