-
Notifications
You must be signed in to change notification settings - Fork 2.9k
70 lines (59 loc) · 1.94 KB
/
idl.yaml
File metadata and controls
70 lines (59 loc) · 1.94 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
name: Thrift Syntax Validation
on:
push:
branches: ['main']
paths:
- 'idl/**'
- '.github/workflows/idl.yaml'
pull_request:
branches: ['main']
paths:
- 'idl/**'
- '.github/workflows/idl.yaml'
permissions:
contents: read
jobs:
validate-thrift:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Install kitex tools
run: |
go install github.com/cloudwego/thriftgo@v0.4.1
go install github.com/cloudwego/kitex/tool/cmd/kitex@v0.13.1
go install github.com/cloudwego/thrift-gen-validator@v0.2.6
- name: Validate Thrift Files via kitex
run: |
# Initialize error flag
ERROR_FOUND=0
# Create temporary working directory
TEMP_DIR=$(mktemp -d)
echo "Created temporary working directory: $TEMP_DIR"
# Initialize go mod in temp directory
cd "$TEMP_DIR"
go mod init dummy
# Find all thrift files and validate them
while IFS= read -r -d '' thrift_file; do
echo "Validating $thrift_file..."
if ! kitex -streamx -thrift ignore_initialisms=false -module=dummy "$thrift_file" 2>&1; then
echo "IDL gen code error in file: $thrift_file"
ERROR_FOUND=1
fi
done < <(find "$GITHUB_WORKSPACE/idl" -name '*.thrift' -print0)
# Clean up temporary directory
cd "$GITHUB_WORKSPACE"
rm -rf "$TEMP_DIR"
echo "Cleaned up temporary working directory"
# Exit with appropriate status
if [ $ERROR_FOUND -eq 1 ]; then
echo "Thrift validation failed. Please check the errors above."
exit 1
else
echo "All Thrift files validated successfully!"
exit 0
fi