From 331919a4d0799cd4ad139dd7f8232962910a643b Mon Sep 17 00:00:00 2001 From: Morten Mjelva Date: Sat, 28 Sep 2024 12:21:27 +0200 Subject: [PATCH] Make protobuf generation step conditional on existence of pkg/proto --- .github/workflows/master.yaml | 2 +- .github/workflows/pull-requests.yaml | 2 +- tools/github_workflows/workflows_template.libsonnet | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml index b35193a8..11d10b55 100644 --- a/.github/workflows/master.yaml +++ b/.github/workflows/master.yaml @@ -37,7 +37,7 @@ }, { "name": "Protobuf generation", - "run": "find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\nbazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\nfind bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\ndone\n" + "run": "if [ -d bazel-bin/pkg/proto ]; then\n find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\n bazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\n find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\n done\nfi\n" }, { "name": "Embedded asset generation", diff --git a/.github/workflows/pull-requests.yaml b/.github/workflows/pull-requests.yaml index fb6d6073..0e2a9e6d 100644 --- a/.github/workflows/pull-requests.yaml +++ b/.github/workflows/pull-requests.yaml @@ -37,7 +37,7 @@ }, { "name": "Protobuf generation", - "run": "find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\nbazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\nfind bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\ndone\n" + "run": "if [ -d bazel-bin/pkg/proto ]; then\n find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\n bazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\n find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\n done\nfi\n" }, { "name": "Embedded asset generation", diff --git a/tools/github_workflows/workflows_template.libsonnet b/tools/github_workflows/workflows_template.libsonnet index b99675b6..8d0a80db 100644 --- a/tools/github_workflows/workflows_template.libsonnet +++ b/tools/github_workflows/workflows_template.libsonnet @@ -95,11 +95,13 @@ { name: 'Protobuf generation', run: ||| - find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true - bazel build $(bazel query --output=label 'kind("go_proto_library", //...)') - find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do - cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|') - done + if [ -d bazel-bin/pkg/proto ]; then + find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true + bazel build $(bazel query --output=label 'kind("go_proto_library", //...)') + find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do + cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|') + done + fi |||, }, {