Skip to content

Commit 7065151

Browse files
slonkaonemanbucketrulex123
authored
Script to update protos to specific envoy version (#186)
Signed-off-by: Erik Lindblad <[email protected]> Co-authored-by: Erik Lindblad <[email protected]> Co-authored-by: rulex123 <[email protected]>
1 parent 1898ce3 commit 7065151

File tree

4 files changed

+89
-3
lines changed

4 files changed

+89
-3
lines changed

.github/workflows/update-protobuf.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: update-protobuf
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
envoy_version:
6+
description: 'Envoy version to update to'
7+
required: true
8+
9+
jobs:
10+
update-protobuf:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Run scripts
15+
working-directory: ./tools/
16+
run: |
17+
./update-sha.sh ${{ github.event.inputs.envoy_version }} | tee /dev/tty > API_SHAS
18+
./update-api.sh
19+
- name: Create Pull Request
20+
uses: peter-evans/create-pull-request@v3
21+
with:
22+
branch: update-protobuf-to-${{ github.event.inputs.envoy_version }}
23+
signoff: true
24+
title: '[protobuf] Update protobuf definitions to ${{ github.event.inputs.envoy_version }}'
25+
body: |
26+
This is an automatic PR created by github action workflow:
27+
- Updated protobuf files

server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ class EnvoyContainer extends GenericContainer<EnvoyContainer> {
3030
}
3131

3232
EnvoyContainer(String config, Supplier<Integer> controlPlanePortSupplier, int apiVersion) {
33+
// this version is changed automatically by /tools/update-sha.sh:57
34+
// if you change it make sure to reflect changes there
3335
super("envoyproxy/envoy-alpine-dev:bef18019d8fc33a4ed6aca3679aff2100241ac5e");
34-
3536
this.config = config;
3637
this.controlPlanePortSupplier = controlPlanePortSupplier;
3738
this.apiVersion = apiVersion;

tools/update-api.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cp googleapis-*/google/api/expr/v1alpha1/syntax.proto "${protodir}/google/api/ex
4343
cp googleapis-*/google/api/expr/v1alpha1/checked.proto "${protodir}/google/api/expr/v1alpha1"
4444
cp googleapis-*/google/rpc/status.proto "${protodir}/google/rpc"
4545

46-
curl -sL https://github.com/envoyproxy/protoc-gen-validate/archive/${PGV_GIT_SHA}.tar.gz | tar xz --include="*.proto"
46+
curl -sL https://github.com/envoyproxy/protoc-gen-validate/archive/v${PGV_VERSION}.tar.gz | tar xz --include="*.proto"
4747
mkdir -p "${protodir}/validate"
4848
cp -r protoc-gen-validate-*/validate/* "${protodir}/validate"
4949

@@ -52,7 +52,8 @@ mkdir -p "${protodir}/opencensus/proto"
5252
cp -r opencensus-proto-*/src/opencensus/proto/* "${protodir}/opencensus/proto"
5353

5454
curl -sL https://github.com/prometheus/client_model/archive/${PROMETHEUS_SHA}.tar.gz | tar xz --include="*.proto"
55-
cp client_model-*/metrics.proto "${protodir}"
55+
mkdir -p "${protodir}/io/prometheus/client/"
56+
cp client_model-*/io/prometheus/client/metrics.proto "${protodir}/io/prometheus/client/"
5657

5758
curl -sL https://github.com/cncf/xds/archive/${UDPA_SHA}.tar.gz | tar xz --include="*.proto"
5859
mkdir -p "${protodir}/udpa"

tools/update-sha.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
3+
function find_sha() {
4+
local CONTENT=$1
5+
local DEPENDENCY=$2
6+
echo "$CONTENT" | grep "$DEPENDENCY" -A 11 | grep -m 1 version | awk '{ print $3 }' | tr -d '"' | tr -d ","
7+
}
8+
9+
function find_date() {
10+
local CONTENT=$1
11+
local DEPENDENCY=$2
12+
echo "$CONTENT" | grep "$DEPENDENCY" -A 11 | grep -m 1 release_date | awk '{ print $3 }' | tr -d '"' | tr -d ","
13+
}
14+
15+
function find_envoy_sha_from_tag() {
16+
local TAG=$1
17+
curl -s https://api.github.com/repos/envoyproxy/envoy/tags | grep "$TAG" -A 4 | grep sha | awk '{print $2}' | tr -d '"' | tr -d ","
18+
}
19+
20+
ENVOY_VERSION=$(find_envoy_sha_from_tag "$1")
21+
22+
CURL_OUTPUT=$(curl -s "https://raw.githubusercontent.com/envoyproxy/envoy/$ENVOY_VERSION/api/bazel/repository_locations.bzl")
23+
24+
GOOGLEAPIS_SHA=$(find_sha "$CURL_OUTPUT" com_google_googleapis)
25+
GOOGLEAPIS_DATE=$(find_date "$CURL_OUTPUT" com_google_googleapis)
26+
27+
PGV_GIT_SHA=$(find_sha "$CURL_OUTPUT" com_envoyproxy_protoc_gen_validate)
28+
PGV_GIT_DATE=$(find_date "$CURL_OUTPUT" com_envoyproxy_protoc_gen_validate)
29+
30+
PROMETHEUS_SHA=$(find_sha "$CURL_OUTPUT" prometheus_metrics_model)
31+
PROMETHEUS_DATE=$(find_date "$CURL_OUTPUT" prometheus_metrics_model)
32+
33+
OPENCENSUS_SHA=$(find_sha "$CURL_OUTPUT" opencensus_proto)
34+
OPENCENSUS_DATE=$(find_date "$CURL_OUTPUT" opencensus_proto)
35+
36+
UDPA_SHA=$(find_sha "$CURL_OUTPUT" com_github_cncf_udpa)
37+
UDPA_DATE=$(find_date "$CURL_OUTPUT" com_github_cncf_udpa)
38+
39+
OPENTELEMETRY_SHA=$(find_sha "$CURL_OUTPUT" opentelemetry_proto)
40+
OPENTELEMETRY_DATE=$(find_date "$CURL_OUTPUT" opentelemetry_proto)
41+
42+
echo -n "# Update the versions here and run update-api.sh
43+
44+
# envoy (source: SHA from https://github.com/envoyproxy/envoy)
45+
ENVOY_SHA=\"$ENVOY_VERSION\"
46+
47+
# dependencies (source: https://github.com/envoyproxy/envoy/blob/$ENVOY_VERSION/api/bazel/repository_locations.bzl)
48+
GOOGLEAPIS_SHA=\"$GOOGLEAPIS_SHA\" # $GOOGLEAPIS_DATE
49+
PGV_VERSION=\"$PGV_GIT_SHA\" # $PGV_GIT_DATE
50+
PROMETHEUS_SHA=\"$PROMETHEUS_SHA\" # $PROMETHEUS_DATE
51+
OPENCENSUS_VERSION=\"$OPENCENSUS_SHA\" # $OPENCENSUS_DATE
52+
OPENTELEMETRY_VERSION=\"$OPENTELEMETRY_SHA\" # $OPENTELEMETRY_DATE
53+
UDPA_SHA=\"$UDPA_SHA\" # $UDPA_DATE
54+
"
55+
56+
# replace version in EnvoyContainer.java
57+
sed -i 's/\(envoy-alpine-dev:\).*\(\");\)/\1'"$ENVOY_VERSION"'\2/g' ../server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java

0 commit comments

Comments
 (0)