Skip to content

Commit 7eb68d2

Browse files
Copilotphlax
andauthored
bazel-registry: Add initial modules and CI (#3487)
Signed-off-by: Ryan Northey <ryan@synca.io> Co-authored-by: Ryan Northey <ryan@synca.io>
1 parent 34fc805 commit 7eb68d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1221
-1
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: _bazel_registry
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
metadata:
10+
default: metadata.json
11+
description: Metadata file
12+
type: string
13+
module:
14+
description: Module name
15+
required: true
16+
type: string
17+
modules-root:
18+
default: bazel-registry
19+
description: Path to modules root dir
20+
type: string
21+
source:
22+
default: source.json
23+
description: Source file
24+
type: string
25+
template-integrity:
26+
type: string
27+
default: |
28+
export SOURCE_URL=\"\(.url)\"
29+
export MODULE=\"\($module)\"
30+
export MODULE_VERSION=\"\($module_version)\"
31+
export MODULES_ROOT=\"\($modules_root)\"
32+
OUTPUT=\"$($GITHUB_WORKSPACE/.github/workflows/registry_integrity.sh)\"
33+
34+
35+
jobs:
36+
module:
37+
runs-on: ubuntu-24.04
38+
name: Bazel module (${{ inputs.module }})
39+
outputs:
40+
versions: ${{ steps.versions.outputs.value }}
41+
steps:
42+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
43+
- uses: envoyproxy/toolshed/actions/jq@d10938876b114aa2a001b43b43158f1bf7008f1a
44+
id: versions
45+
with:
46+
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ inputs.metadata }}
47+
input-format: json-path
48+
filter: |
49+
.versions
50+
| map(select(. | endswith(".envoy")))
51+
52+
version:
53+
if: >-
54+
needs.module.outputs.versions != '[]'
55+
runs-on: ubuntu-24.04
56+
needs:
57+
- module
58+
name: Bazel module version (${{ inputs.module }}:${{ matrix.version }})
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
version: ${{ fromJSON(needs.module.outputs.versions) }}
63+
steps:
64+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
65+
- uses: envoyproxy/toolshed/actions/jq@d10938876b114aa2a001b43b43158f1bf7008f1a
66+
with:
67+
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ matrix.version }}/${{ inputs.source }}
68+
input-format: json-path
69+
print-result: true
70+
- uses: envoyproxy/toolshed/actions/bson@d10938876b114aa2a001b43b43158f1bf7008f1a
71+
id: source
72+
with:
73+
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ matrix.version }}/${{ inputs.source }}
74+
input-format: json-path
75+
filter: |
76+
.
77+
| "${{ inputs.module }}" as $module
78+
| "${{ matrix.version }}" as $module_version
79+
| "${{ inputs.modules-root }}" as $modules_root
80+
| "${{ inputs.template-integrity }}"
81+
| bash::output
82+
result-filter-options: -sRc
83+
result-filter: |
84+
split("\n")
85+
| map(select(length > 0) | split(" ") | {key: .[0], value: .[1]})
86+
| from_entries
87+
- uses: envoyproxy/toolshed/actions/bson@d10938876b114aa2a001b43b43158f1bf7008f1a
88+
with:
89+
input: ${{ inputs.modules-root }}/modules/${{ inputs.module }}/${{ matrix.version }}/${{ inputs.source }}
90+
input-format: json-path
91+
filter: |
92+
. as $source
93+
| ${{ steps.source.outputs.output }} as $actual
94+
95+
# Check main integrity
96+
| (if $source.integrity != $actual.integrity then
97+
{
98+
result: "::error::✗ Integrity does not match (actual: \($actual.integrity), expected: \($source.integrity))",
99+
error: true
100+
}
101+
else
102+
{
103+
result: "✓ Integrity matches \($actual.integrity)",
104+
error: false
105+
}
106+
end) as $integrity_check
107+
108+
# Check overlay files
109+
| (if $source.overlay then
110+
[
111+
$source.overlay
112+
| to_entries[]
113+
| . as $entry
114+
| if $actual["overlay:\($entry.key)"] then
115+
if $entry.value != $actual["overlay:\($entry.key)"] then
116+
{
117+
result: (
118+
"::error::✗ Overlay \($entry.key) does not match " +
119+
"(actual: \($actual["overlay:\($entry.key)"]), expected: \($entry.value))"
120+
),
121+
error: true
122+
}
123+
else
124+
{
125+
result: "✓ Overlay \($entry.key) matches \($entry.value)",
126+
error: false
127+
}
128+
end
129+
else
130+
{
131+
result: "::error::✗ Overlay \($entry.key) not found in calculated checksums",
132+
error: true
133+
}
134+
end
135+
]
136+
else
137+
[]
138+
end) as $overlay_checks
139+
140+
# Check patch files
141+
| (if $source.patches then
142+
[
143+
$source.patches
144+
| to_entries[]
145+
| . as $entry
146+
| if $actual["patches:\($entry.key)"] then
147+
if $entry.value != $actual["patches:\($entry.key)"] then
148+
{
149+
result: (
150+
"::error::✗ Patch \($entry.key) does not match " +
151+
"(actual: \($actual["patches:\($entry.key)"]), expected: \($entry.value))"
152+
),
153+
error: true
154+
}
155+
else
156+
{
157+
result: "✓ Patch \($entry.key) matches \($entry.value)",
158+
error: false
159+
}
160+
end
161+
else
162+
{
163+
result: "::error::✗ Patch \($entry.key) not found in calculated checksums",
164+
error: true
165+
}
166+
end
167+
]
168+
else
169+
[]
170+
end) as $patch_checks
171+
172+
# Combine all checks
173+
| ([$integrity_check] + $overlay_checks + $patch_checks) as $checks
174+
175+
# Determine if any errors occurred
176+
| ($checks | map(select(.error)) | length > 0) as $has_errors
177+
178+
# Generate bash script
179+
| $checks
180+
| map("echo \"\(.result)\" >&2")
181+
| join("\n")
182+
| if $has_errors then
183+
. + "\nexit 1"
184+
else
185+
.
186+
end
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Bazel registry CI
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
17+
jobs:
18+
request:
19+
runs-on: ubuntu-24.04
20+
outputs:
21+
run: ${{ steps.filter.outputs.run }}
22+
modules: ${{ steps.modules.outputs.output }}
23+
steps:
24+
- uses: envoyproxy/toolshed/actions/github/should-run@d10938876b114aa2a001b43b43158f1bf7008f1a
25+
id: filter
26+
with:
27+
config: |
28+
paths:
29+
- 'bazel-registry/**'
30+
- '.github/workflows/bazel-registry.yml'
31+
- name: Find modules
32+
uses: ./actions/bson
33+
id: modules
34+
with:
35+
input: |
36+
registry_path: bazel-registry/modules
37+
metadata_file: metadata.json
38+
filter: |
39+
.
40+
| "OUTPUT=$(find \(.registry_path) -name \(.metadata_file))"
41+
| bash::output
42+
result-filter: |
43+
split("\n")
44+
| map(
45+
select(length > 0)
46+
| split("/")[2])
47+
result-filter-options: -sRc
48+
49+
modules:
50+
needs: request
51+
if: >-
52+
fromJSON(needs.request.outputs.run)
53+
&& needs.request.outputs.modules != '[]'
54+
uses: ./.github/workflows/_bazel_registry.yml
55+
with:
56+
module: ${{ matrix.module }}
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
module: ${{ fromJSON(needs.request.outputs.modules) }}
61+
62+
status:
63+
runs-on: ubuntu-24.04
64+
if: >-
65+
always()
66+
&& github.event_name == 'pull_request'
67+
name: Bazel registry CI
68+
needs:
69+
- request
70+
- modules
71+
steps:
72+
- run: |
73+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
74+
echo "One or more jobs failed or were cancelled"
75+
exit 1
76+
fi
77+
echo "All required jobs passed or were skipped"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -e -o pipefail
4+
5+
6+
VERSION_DIR="${GITHUB_WORKSPACE}/${MODULES_ROOT}/modules/${MODULE}/${MODULE_VERSION}"
7+
8+
curl -sLo upstream.tar.gz "$SOURCE_URL"
9+
echo "integrity sha256-$(openssl dgst -sha256 -binary < upstream.tar.gz | base64)"
10+
11+
if [[ -d "${VERSION_DIR}/overlay" ]]; then
12+
find "${VERSION_DIR}/overlay" -type f | sort | while read -r file; do
13+
relpath="${file#"${VERSION_DIR}"/overlay/}"
14+
checksum="sha256-$(openssl dgst -sha256 -binary < "$file" | base64)"
15+
echo "overlay:$relpath $checksum"
16+
done
17+
fi
18+
19+
if [[ -d "${VERSION_DIR}/patches" ]]; then
20+
find "${VERSION_DIR}/patches" -type f | sort | while read -r file; do
21+
relpath="${file#"${VERSION_DIR}"/patches/}"
22+
checksum="sha256-$(openssl dgst -sha256 -binary < "$file" | base64)"
23+
echo "patches:$relpath $checksum"
24+
done
25+
fi

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ $RECYCLE.BIN/
183183
!actions/github/mutex/lib
184184

185185
# Bazel
186-
bazel-*
186+
/bazel-*
187+
!/bazel-registry/
187188

188189
# Rust coverage reports
189190
rust/tarpaulin-report.html
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
filegroup(
2+
name = "files",
3+
srcs = glob([
4+
"boost/**/*.h",
5+
"boost/**/*.hpp",
6+
"boost/**/*.ipp",
7+
]),
8+
visibility = ["//visibility:public"],
9+
)
10+
11+
cc_library(
12+
name = "boost.headers",
13+
hdrs = [":files"],
14+
includes = ["."],
15+
visibility = ["//visibility:public"],
16+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module(
2+
name = "boost.headers",
3+
version = "1.89.0",
4+
compatibility_level = 1,
5+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- /dev/null
2+
+++ BUILD.bazel
3+
@@ -0,0 +1,16 @@
4+
+filegroup(
5+
+ name = "files",
6+
+ srcs = glob([
7+
+ "boost/**/*.h",
8+
+ "boost/**/*.hpp",
9+
+ "boost/**/*.ipp",
10+
+ ]),
11+
+ visibility = ["//visibility:public"],
12+
+)
13+
+
14+
+cc_library(
15+
+ name = "boost.headers",
16+
+ hdrs = [":files"],
17+
+ includes = ["."],
18+
+ visibility = ["//visibility:public"],
19+
+)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
matrix:
2+
platform:
3+
- debian10
4+
- debian11
5+
- macos
6+
- macos_arm64
7+
- ubuntu2004
8+
- ubuntu2204
9+
- ubuntu2404
10+
- windows
11+
bazel:
12+
- 7.x
13+
- 8.x
14+
tasks:
15+
verify_targets:
16+
name: Verify build targets
17+
platform: ${{ platform }}
18+
bazel: ${{ bazel }}
19+
build_targets:
20+
- '@boost.headers//:files'
21+
- '@boost.headers'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"integrity": "sha256-nedY23VegzCgHZlbCiTQl5gEhACsJcA/xeqb42SxPJM=",
3+
"strip_prefix": "boost_1_89_0",
4+
"url": "https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.gz",
5+
"patches": {
6+
"add_build_file.patch": "sha256-y52yfVZqyUmNX/Pwp/xTELyr+USnpmDByizgMKXbv/c="
7+
},
8+
"patch_strip": 0
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"homepage": "https://www.boost.org",
3+
"maintainers": [],
4+
"repository": [
5+
"github:boostorg/boost"
6+
],
7+
"versions": [
8+
"1.89.0.envoy"
9+
],
10+
"yanked_versions": {}
11+
}

0 commit comments

Comments
 (0)