Skip to content

Commit

Permalink
fix: separated node and java code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzzimmer committed Apr 5, 2023
1 parent 771ddd1 commit 36bf51d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 38 deletions.
23 changes: 5 additions & 18 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,7 @@ jobs:
distribution: 'adopt'
java-version: '11'

- uses: actions/setup-node@v3
with:
cache: 'npm'
cache-dependency-path: 'node/package-lock.json'
node-version-file: 'node/.nvmrc'
registry-url: "https://npm.pkg.github.com"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: bufbuild/buf-setup-action@v1

- name: npm ci
run: npm ci
working-directory: node

- name: make
- name: generate
run: make generate

- name: publish
Expand All @@ -50,6 +35,7 @@ jobs:
steps:
- uses: actions/checkout@v3

# we need Node for the local execution of protoc Typescript plugin
- uses: actions/setup-node@v3
with:
cache: 'npm'
Expand All @@ -61,12 +47,13 @@ jobs:

- uses: bufbuild/buf-setup-action@v1

# we need Node for the local execution of protoc Typescript plugin
- name: npm ci
run: npm ci
working-directory: node

- name: make
run: make generate
- name: generate
run: make generate TEMPLATE=buf.gen.node.yaml

- name: Run node checks
run: npm run checks
Expand Down
40 changes: 37 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@ on:
- main

jobs:
generate:
java:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'

- uses: bufbuild/buf-setup-action@v1

- name: generate
run: make generate

- name: test
run: ./gradlew build
working-directory: java

node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -25,8 +44,23 @@ jobs:
run: npm ci
working-directory: node

- name: generate and test code for java and node
run: make generate test
- name: generate
run: make generate TEMPLATE=buf.gen.node.yaml

- name: test
run: npm run checks
working-directory: node

go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version: '1.20'

- uses: bufbuild/buf-setup-action@v1

- name: generate go code
run: make generate TEMPLATE=buf.gen.go.yaml
Expand Down
19 changes: 19 additions & 0 deletions buf.gen.node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: v1

plugins:
# Typescript/Node
- plugin: buf.build/protocolbuffers/js:v3.21.2
out: ./node
opt: import_style=commonjs,binary

- plugin: buf.build/grpc/node:v1.12.4
out: ./node
opt: grpc_js

# TODO: migrate to a remote plugin for Typescript generation
- plugin: protoc-gen-ts
out: ./node
path: ./node/node_modules/.bin/protoc-gen-ts
opt:
- mode=grpc-js
- service=grpc-node
17 changes: 0 additions & 17 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ plugins:
- plugin: buf.build/grpc/java:v1.53.0
out: ./java/src/main/java

# Typescript/Node
- plugin: buf.build/protocolbuffers/js:v3.21.2
out: ./node
opt: import_style=commonjs,binary

- plugin: buf.build/grpc/node:v1.12.4
out: ./node
opt: grpc_js

# TODO: migrate to a remote plugin for Typescript generation
- plugin: protoc-gen-ts
out: ./node
path: ./node/node_modules/.bin/protoc-gen-ts
opt:
- mode=grpc-js
- service=grpc-node

# Python
- plugin: buf.build/protocolbuffers/python:v22.0
out: gen/python
Expand Down

0 comments on commit 36bf51d

Please sign in to comment.