diff --git a/.github/workflows/check-generated-diff.yml b/.github/workflows/check-generated-diff.yml new file mode 100644 index 00000000000..85284524e7b --- /dev/null +++ b/.github/workflows/check-generated-diff.yml @@ -0,0 +1,62 @@ +name: Validate Generated Files +on: + pull_request: + paths: + - 'backend/api/**/*.proto' + - '.github/workflows/check-generated-diff.yml' + - 'backend/api/**/go_http_client/**' + - 'backend/api/**/go_client/**' + - 'backend/api/**/python_http_client/**' + - 'backend/api/**/swagger/**' + +jobs: + validate-generated-files: + runs-on: ubuntu-latest + strategy: + matrix: + api_version: ['v1beta1', 'v2beta1'] + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Install Dependencies + run: | + # Go dependencies + apt-get update && apt-get install -y protobuf-compiler jq default-jdk python3 python3-pip curl + go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@latest + go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@latest + go install github.com/golang/protobuf/protoc-gen-go@latest + go install github.com/go-swagger/go-swagger/cmd/swagger@latest + + # Python dependencies + python3 -m pip install setuptools wheel + + - name: Generate Proto Files + run: | + export API_VERSION=${{ matrix.api_version }} + export PROTOCCOMPILER=protoc + export TMP_OUTPUT=/tmp + ./backend/api/hack/generator.sh + + - name: Generate Python Package + run: | + export API_VERSION=${{ matrix.api_version }} + ./backend/api/build_kfp_server_api_python_package.sh + + - name: Check for Changes + run: | + if [[ -n "$(git status --porcelain)" ]]; then + echo "ERROR: Generated files are out of date for API version ${{ matrix.api_version }}." + echo "Please regenerate using both generate_api.sh and build_kfp_server_api_python_package.sh" + echo "Changes found in the following files:" + git status + echo "Diff of changes:" + git diff + exit 1 + fi