From 96a4a635db8775c13a648199c0d583ba01c96d62 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Fri, 23 Feb 2024 14:05:31 +0100 Subject: [PATCH] CT Signed-off-by: Jan Kowalleck --- .github/workflows/test_proto.yml | 24 ++++++++++++++++++++++ proto-test/*.textproto | 0 tools/src/test/proto-test.sh | 34 +++++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test_proto.yml create mode 100644 proto-test/*.textproto diff --git a/.github/workflows/test_proto.yml b/.github/workflows/test_proto.yml new file mode 100644 index 00000000..8dfd1d35 --- /dev/null +++ b/.github/workflows/test_proto.yml @@ -0,0 +1,24 @@ +# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions + +name: CT ProtoBuf + +on: + push: + branches: ['master', 'main'] + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - name: Checkout + # see https://github.com/actions/checkout + uses: actions/checkout@v4 + - name: run tests + run: tools/src/test/proto-test.sh \ No newline at end of file diff --git a/proto-test/*.textproto b/proto-test/*.textproto new file mode 100644 index 00000000..e69de29b diff --git a/tools/src/test/proto-test.sh b/tools/src/test/proto-test.sh index fa3377aa..894954df 100755 --- a/tools/src/test/proto-test.sh +++ b/tools/src/test/proto-test.sh @@ -1,6 +1,30 @@ #!/usr/bin/env bash -mkdir -p proto-test -for filename in resources/1.3/*.textproto; -do - protoc --proto_path=../../../schema/ --encode=cyclonedx.v1_3.Bom bom-1.3-SNAPSHOT.proto < $filename | protoc --proto_path=../../../schema/ --decode=cyclonedx.v1_3.Bom bom-1.3-SNAPSHOT.proto > proto-test/${filename##*/} -done; \ No newline at end of file +set -ex + +if [[ -n "$CI" ]] +then + LOG_FORMAT="github-actions" +else + LOG_FORMAT="json" +fi + +# lint protobuf schema files +docker run \ + --volume "$(pwd):/workspace" \ + --workdir /workspace \ + bufbuild/buf:1.29.0 \ + lint --error-format "$LOG_FORMAT" + +# check protobuf schema files for breaking changes +# docker run \ +# --volume "$(pwd):/workspace" \ +# --workdir /workspace \ +# bufbuild/buf:1.29.0 \ +# breaking + +# test all examples against the schema files +# mkdir -p proto-test +# for filename in resources/1.3/*.textproto; +# do +# protoc --proto_path=../../../schema/ --encode=cyclonedx.v1_3.Bom bom-1.3-SNAPSHOT.proto < $filename | protoc --proto_path=../../../schema/ --decode=cyclonedx.v1_3.Bom bom-1.3-SNAPSHOT.proto > proto-test/${filename##*/} +# done \ No newline at end of file