-
Notifications
You must be signed in to change notification settings - Fork 8
88 lines (74 loc) · 2.72 KB
/
grpc-compatibility.yml
File metadata and controls
88 lines (74 loc) · 2.72 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
name: gRPC Contract Compatibility
on:
workflow_call:
inputs:
base-ref:
description: 'Base branch reference to compare against'
required: true
type: string
outputs:
has-breaking-changes:
description: 'Whether breaking changes were detected'
value: ${{ jobs.check-compatibility.outputs.has-breaking-changes }}
breaking-changes:
description: 'List of breaking changes detected'
value: ${{ jobs.check-compatibility.outputs.breaking-changes }}
env:
DOTNET_VERSION: "10.0.x"
jobs:
check-compatibility:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
has-breaking-changes: ${{ steps.compare.outputs.has-breaking-changes }}
breaking-changes: ${{ steps.compare.outputs.breaking-changes }}
steps:
- name: Checkout current code
uses: actions/checkout@v4
with:
path: current
- name: Checkout base code
uses: actions/checkout@v4
with:
ref: ${{ inputs.base-ref }}
path: baseline
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Generate current schema
working-directory: current
run: |
.github/scripts/generate-grpc-schema.sh current-schema.proto
- name: Generate baseline schema
run: |
# Use the script from current (PR) branch to generate schema for baseline code
current/.github/scripts/generate-grpc-schema.sh baseline/baseline-schema.proto $PWD/baseline
- name: Compare schemas
id: compare
working-directory: current
run: |
set +e
# Run the comparison
.github/scripts/compare-grpc-schemas.sh ../baseline/baseline-schema.proto current-schema.proto > comparison-output.txt 2>&1
RESULT=$?
cat comparison-output.txt
if [ $RESULT -eq 0 ]; then
echo "has-breaking-changes=false" >> $GITHUB_OUTPUT
echo "breaking-changes=" >> $GITHUB_OUTPUT
else
echo "has-breaking-changes=true" >> $GITHUB_OUTPUT
# Extract breaking changes and format for output
CHANGES=$(grep "^ - " comparison-output.txt | sed 's/^ - //' | tr '\n' ';' | sed 's/;$//')
echo "breaking-changes=$CHANGES" >> $GITHUB_OUTPUT
fi
- name: Upload schemas for reference
if: always()
uses: actions/upload-artifact@v4
with:
name: grpc-schemas
path: |
current/current-schema.proto
baseline/baseline-schema.proto
current/comparison-output.txt