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