Skip to content

Commit 38eb87b

Browse files
committed
Fix generating in docker
1 parent 3b26f71 commit 38eb87b

9 files changed

Lines changed: 1229 additions & 75 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Generated files
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
lint:
8+
name: Generated files
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Repo
13+
uses: actions/checkout@v4
14+
15+
- name: Install make
16+
run: sudo apt-get update && sudo apt-get install -y make
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Run codegen
22+
run: make codegen
23+
24+
- name: Check generated files
25+
run: |
26+
git diff --exit-code || (echo "Generated files are not up to date. Please run 'make codegen'." && exit 1)

Makefile

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
1-
update-api-spec:
2-
@echo "Updating API spec"
3-
@./scripts/update-api-spec.sh
4-
@echo "Done"
5-
61
.PHONY: codegen
72
codegen:
83
@echo "Generating SDK code from openapi and envd spec"
9-
@./scripts/codegen.sh
4+
@docker run -v "$$(pwd):/workspace" $$(docker build -q -t codegen-env . -f codegen.Dockerfile)
105

116
generate: generate-js generate-python
127

138
generate-js:
149
cd packages/js-sdk && pnpm generate
15-
cd packages/js-sdk && pnpm generate-envd-api
16-
cd spec/envd && buf generate --template buf-js.gen.yaml
1710

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

2614
.PHONY: init-styles
2715
init-styles:
2816
vale sync
17+

codegen.Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM golang:1.23
44
RUN go install github.com/bufbuild/buf/cmd/buf@v1.50.1 && \
55
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 && \
66
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.18.1
7-
7+
88
# Install our custom protoc plugin, connect-python
99
COPY ./packages/connect-python /packages/connect-python
1010
RUN cd /packages/connect-python && make bin/protoc-gen-connect-python
@@ -38,7 +38,8 @@ RUN apt-get update && \
3838
rm -rf /var/lib/apt/lists/*
3939

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

43+
RUN pnpm i
4344
# Generate when container starts
4445
CMD ["make", "generate"]

packages/js-sdk/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
"dev": "tsup --watch",
2929
"example": "tsx example.mts",
3030
"test": "vitest run",
31-
"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",
32-
"generate-envd-api": "openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts",
31+
"generate":"npm-run-all generate:*",
32+
"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",
33+
"generate:envd-api": "openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts",
3334
"generate-ref": "./scripts/generate_sdk_ref.sh",
3435
"check-deps": "knip",
3536
"update-deps": "ncu -u && pnpm i",
@@ -52,6 +53,7 @@
5253
"eslint": "^8.57.1",
5354
"knip": "^5.43.6",
5455
"npm-check-updates": "^16.14.20",
56+
"npm-run-all": "^4.1.5",
5557
"openapi-typescript": "^7.6.1",
5658
"playwright": "^1.48.0",
5759
"react": "^18.3.1",
@@ -82,7 +84,7 @@
8284
"typescript"
8385
],
8486
"dependencies": {
85-
"@bufbuild/protobuf": "^2.2.2",
87+
"@bufbuild/protobuf": "^2.6.2",
8688
"@connectrpc/connect": "2.0.0-rc.3",
8789
"@connectrpc/connect-web": "2.0.0-rc.3",
8890
"compare-versions": "^6.1.0",

packages/python-sdk/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ generate-api:
44
rm -rf e2b/api/client
55
mv e2b/api/api/e2b_api_client e2b/api/client
66
rm -rf e2b/api/api
7+
black .
8+
9+
generate-envd:
10+
if [ ! -f "/go/bin/protoc-gen-connect-python" ]; then \
11+
$(MAKE) -C packages/connect-python build; \
12+
fi
13+
14+
cd ./../../spec/envd && buf generate --template buf-python.gen.yaml
15+
black .
16+
17+
generate: generate-api generate-envd
18+
./scripts/fix-python-pb.sh
19+
black .
720

821
init:
922
pip install openapi-python-client

0 commit comments

Comments
 (0)