Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/generated_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Generated files

on:
pull_request:

jobs:
check-generated:
name: Generated files
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.5

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true

- name: Install dependencies
run: pnpm install --frozen-lockfile


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build codegen image with caching
uses: docker/build-push-action@v6
with:
context: .
file: codegen.Dockerfile
tags: codegen-env:latest
load: true # makes the image available for `docker run`
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run codegen
run: make codegen

- name: Check for uncommitted changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "❌ Generated files are not up to date:"
git status --short
git diff
exit 1
else
echo "✅ No changes detected."
fi
18 changes: 3 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
update-api-spec:
@echo "Updating API spec"
@./scripts/update-api-spec.sh
@echo "Done"

Comment on lines -1 to -5
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the spec updated now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it didn't work and it isn't used anyway, so I removed it to prevent issues

.PHONY: codegen
codegen:
@echo "Generating SDK code from openapi and envd spec"
@./scripts/codegen.sh

@docker run -v "$$(pwd):/workspace" $$(docker build -q -t codegen-env . -f codegen.Dockerfile)
generate: generate-js generate-python

generate-js:
cd packages/js-sdk && pnpm generate
cd packages/js-sdk && pnpm generate-envd-api
cd spec/envd && buf generate --template buf-js.gen.yaml

generate-python:
if [ ! -f "/go/bin/protoc-gen-connect-python" ]; then \
$(MAKE) -C packages/connect-python build; \
fi
cd packages/python-sdk && make generate-api
cd spec/envd && buf generate --template buf-python.gen.yaml
cd packages/python-sdk && ./scripts/fix-python-pb.sh && black .
cd packages/python-sdk && make generate

.PHONY: init-styles
init-styles:
vale sync

22 changes: 15 additions & 7 deletions codegen.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM golang:1.23
RUN go install github.com/bufbuild/buf/cmd/buf@v1.50.1 && \
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 && \
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.18.1

# Install our custom protoc plugin, connect-python
COPY ./packages/connect-python /packages/connect-python
RUN cd /packages/connect-python && make bin/protoc-gen-connect-python
Expand All @@ -15,10 +15,16 @@ FROM python:3.9
# Set working directory
WORKDIR /workspace

ENV PROTOC_ZIP=protoc-29.3-linux-aarch_64.zip

RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v29.3/$PROTOC_ZIP
RUN unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
ENV PROTOC_VERSION=29.3
RUN ARCH=$(uname -m) && \
case "$ARCH" in \
x86_64) PROTOC_ARCH="x86_64" ;; \
arm64|aarch64) PROTOC_ARCH="aarch_64" ;; \
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
esac && \
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip && \
unzip -o protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip -d /usr/local && \
rm protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip

# Copy installed Go deps from previous build step
COPY --from=0 /go /go
Expand All @@ -38,7 +44,9 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

# Install Node.js deps
RUN npm install -g pnpm @connectrpc/protoc-gen-connect-es@1.6.1 @bufbuild/protoc-gen-es@2.2.2
RUN npm install -g \
pnpm \
@connectrpc/protoc-gen-connect-es@1.6.1 \
@bufbuild/protoc-gen-es@2.6.2

# Generate when container starts
CMD ["make", "generate"]
8 changes: 5 additions & 3 deletions packages/js-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"dev": "tsup --watch",
"example": "tsx example.mts",
"test": "vitest run",
"generate": "python ./../../spec/remove_extra_tags.py sandboxes templates auth && openapi-typescript ../../spec/openapi_generated.yml -x api_key --array-length --alphabetize --output src/api/schema.gen.ts",
"generate-envd-api": "openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts",
"generate":"npm-run-all generate:*",
"generate:api": "python ./../../spec/remove_extra_tags.py sandboxes templates auth && openapi-typescript ../../spec/openapi_generated.yml -x api_key --array-length --alphabetize --output src/api/schema.gen.ts",
"generate:envd-api": "openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts",
"generate-ref": "./scripts/generate_sdk_ref.sh",
"check-deps": "knip",
"update-deps": "ncu -u && pnpm i",
Expand All @@ -52,6 +53,7 @@
"eslint": "^8.57.1",
"knip": "^5.43.6",
"npm-check-updates": "^16.14.20",
"npm-run-all": "^4.1.5",
"openapi-typescript": "^7.6.1",
"playwright": "^1.48.0",
"react": "^18.3.1",
Expand Down Expand Up @@ -82,7 +84,7 @@
"typescript"
],
"dependencies": {
"@bufbuild/protobuf": "^2.2.2",
"@bufbuild/protobuf": "^2.6.2",
"@connectrpc/connect": "2.0.0-rc.3",
"@connectrpc/connect-web": "2.0.0-rc.3",
"compare-versions": "^6.1.0",
Expand Down
Loading