From 36bf51de676945c496a5049cba52058d877f71c6 Mon Sep 17 00:00:00 2001 From: Moritz Zimmer Date: Wed, 5 Apr 2023 11:31:23 +0200 Subject: [PATCH] fix: separated node and java code generation --- .github/workflows/packages.yml | 23 ++++------------- .github/workflows/pull-request.yml | 40 +++++++++++++++++++++++++++--- buf.gen.node.yaml | 19 ++++++++++++++ buf.gen.yaml | 17 ------------- 4 files changed, 61 insertions(+), 38 deletions(-) create mode 100644 buf.gen.node.yaml diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 38ac982d..7633c240 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -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 @@ -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' @@ -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 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 602102d3..4d6ab52a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -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 @@ -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 diff --git a/buf.gen.node.yaml b/buf.gen.node.yaml new file mode 100644 index 00000000..a4523f87 --- /dev/null +++ b/buf.gen.node.yaml @@ -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 diff --git a/buf.gen.yaml b/buf.gen.yaml index 2ee4a39d..240467fc 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -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