From 8c607eb7a45bdb7fbbe5cc915fa99232b68ef8f1 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Wed, 6 Nov 2024 12:41:06 +0100 Subject: [PATCH 1/2] tests: fix BrotoBuf BCcheck on version-level (#536) Signed-off-by: Jan Kowalleck --- .../src/test/proto/buf_breaking-version.yaml | 5 +--- tools/src/test/proto/test.sh | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/src/test/proto/buf_breaking-version.yaml b/tools/src/test/proto/buf_breaking-version.yaml index 222a4ed4..e3fecdfd 100644 --- a/tools/src/test/proto/buf_breaking-version.yaml +++ b/tools/src/test/proto/buf_breaking-version.yaml @@ -3,7 +3,4 @@ version: v2 breaking: # https://buf.build/docs/configuration/v2/buf-yaml#breaking use: # see https://buf.build/docs/breaking/overview#rules-and-categories - - WIRE - except: - # scope is to detect changes from one version to the other -> so ignore "FILE_SAME_PACKAGE" - - FILE_SAME_PACKAGE \ No newline at end of file + - WIRE \ No newline at end of file diff --git a/tools/src/test/proto/test.sh b/tools/src/test/proto/test.sh index a0c1c384..ccbf30bb 100755 --- a/tools/src/test/proto/test.sh +++ b/tools/src/test/proto/test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -uex +set -ue THIS_PATH="$(realpath "$(dirname "$0")")" ROOT_PATH="$(realpath "${THIS_PATH}/../../../..")" @@ -51,23 +51,29 @@ function schema-breaking-version () { function compare() { NEW="bom-${1}.proto" OLD="bom-${2}.proto" - SCHEMA_DIR_OLD="${SCHEMA_DIR}_old" + + NEW_NP="$(mktemp)" + OLD_NP="$(mktemp)" + + # remove package identifier -> so that the comparisson works as expected + sed 's/^package .*//' "${ROOT_PATH}/${SCHEMA_DIR}/${NEW}" > "$NEW_NP" + sed 's/^package .*//' "${ROOT_PATH}/${SCHEMA_DIR}/${OLD}" > "$OLD_NP" echo ">> compare new:${NEW} -VS- old:${OLD}" >&2 # stick with the original path of "$NEW", so the reporting makes sense... docker run --rm \ - --volume "${ROOT_PATH}/${SCHEMA_DIR}/${OLD}:/workspaces/old/${NEW}:ro" \ - --volume "${ROOT_PATH}/${SCHEMA_DIR}/${NEW}:/workspaces/new/${NEW}:ro" \ + --volume "${OLD_NP}:/workspaces/old/${NEW}:ro" \ + --volume "${NEW_NP}:/workspaces/new/${NEW}:ro" \ --volume "${THIS_PATH}/buf_breaking-version.yaml:/workspaces/new/buf.yaml:ro" \ - --workdir '/workspaces' \ + --workdir '/workspaces/new' \ bufbuild/buf:"$BUF_IMAGE_VERSION" \ - breaking new \ - --against old \ + breaking \ + --against ../old \ --error-format "$LOG_FORMAT" } - compare '1.6' '1.5' - compare '1.5' '1.4' + # compare '1.6' '1.5' # <-- possible breaks are acknowledged + # compare '1.5' '1.4' # <-- possible breaks are acknowledged compare '1.4' '1.3' echo '>> OK.' >&2 From ed2371e10298eb698d9e78b84e32ce686128da5c Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Wed, 6 Nov 2024 13:01:22 +0100 Subject: [PATCH 2/2] tests: fix BrotoBuf test reports (#537) Signed-off-by: Jan Kowalleck --- tools/src/test/proto/test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/src/test/proto/test.sh b/tools/src/test/proto/test.sh index ccbf30bb..8d0c72ad 100755 --- a/tools/src/test/proto/test.sh +++ b/tools/src/test/proto/test.sh @@ -19,7 +19,7 @@ BUF_IMAGE_VERSION='1.46.0' function schema-lint () { echo '> lint schema files' >&2 - if [[ -n "${CI:-}" ]] + if [[ -n "${GITHUB_WORKFLOW:-}" ]] then LOG_FORMAT='github-actions' else @@ -60,10 +60,10 @@ function schema-breaking-version () { sed 's/^package .*//' "${ROOT_PATH}/${SCHEMA_DIR}/${OLD}" > "$OLD_NP" echo ">> compare new:${NEW} -VS- old:${OLD}" >&2 - # stick with the original path of "$NEW", so the reporting makes sense... + # stick with the original path and name of "$NEW", so the reporting makes sense... docker run --rm \ - --volume "${OLD_NP}:/workspaces/old/${NEW}:ro" \ - --volume "${NEW_NP}:/workspaces/new/${NEW}:ro" \ + --volume "${OLD_NP}:/workspaces/old/${SCHEMA_DIR}/${NEW}:ro" \ + --volume "${NEW_NP}:/workspaces/new/${SCHEMA_DIR}/${NEW}:ro" \ --volume "${THIS_PATH}/buf_breaking-version.yaml:/workspaces/new/buf.yaml:ro" \ --workdir '/workspaces/new' \ bufbuild/buf:"$BUF_IMAGE_VERSION" \