Skip to content

Commit 39c40fa

Browse files
authored
Add CI step to check generated code is up-to-date (grpc#15)
1 parent 4587c27 commit 39c40fa

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.github/workflows/soundness.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,21 @@ jobs:
1717
- name: Run license check
1818
run: |
1919
./dev/license-check.sh
20+
21+
check-generated-code:
22+
name: Check generated code
23+
runs-on: ubuntu-latest
24+
container:
25+
image: swift:latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
persist-credentials: false
31+
- name: Mark the workspace as safe
32+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
33+
- name: Install protoc
34+
run: apt update && apt install -y protobuf-compiler
35+
- name: Check generated code
36+
run: |
37+
./dev/check-generated-code.sh

dev/check-generated-code.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
## Copyright 2024, gRPC Authors All rights reserved.
3+
##
4+
## Licensed under the Apache License, Version 2.0 (the "License");
5+
## you may not use this file except in compliance with the License.
6+
## You may obtain a copy of the License at
7+
##
8+
## http://www.apache.org/licenses/LICENSE-2.0
9+
##
10+
## Unless required by applicable law or agreed to in writing, software
11+
## distributed under the License is distributed on an "AS IS" BASIS,
12+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
## See the License for the specific language governing permissions and
14+
## limitations under the License.
15+
16+
set -euo pipefail
17+
18+
log() { printf -- "** %s\n" "$*" >&2; }
19+
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
20+
fatal() { error "$@"; exit 1; }
21+
22+
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23+
24+
# Re-generate everything.
25+
log "Regenerating protos..."
26+
"$here"/protos/generate.sh
27+
28+
# Check for changes.
29+
GIT_PAGER='' git diff --exit-code '*.swift'
30+
31+
log "Generated code is up-to-date"

0 commit comments

Comments
 (0)