Skip to content

Commit 5868a43

Browse files
authored
chore: test protobuf acknowledged BC (#589)
2 parents 5006037 + f99dd79 commit 5868a43

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

Diff for: tools/src/test/proto/buf_breaking-version.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,13 @@
33
version: v2
44
breaking: # https://buf.build/docs/configuration/v2/buf-yaml#breaking
55
use: # see https://buf.build/docs/breaking/overview#rules-and-categories
6-
- WIRE
6+
- WIRE
7+
ignore_only:
8+
# possible breaks are acknowledged for this specific findings only
9+
FIELD_WIRE_COMPATIBLE_CARDINALITY:
10+
# DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP
11+
- 'schema/bom-1.6.proto'
12+
- 'schema/bom-1.5.proto'
13+
FIELD_WIRE_COMPATIBLE_TYPE:
14+
# DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP
15+
- 'schema/bom-1.5.proto'

Diff for: tools/src/test/proto/test.sh

+17-29
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ REMOTE="https://github.com/${GITHUB_REPOSITORY:-CycloneDX/specification}.git"
1313
BUF_IMAGE_VERSION='1.50.0'
1414
BUF_IMAGE="bufbuild/buf:$BUF_IMAGE_VERSION"
1515

16+
LOG_FORMAT='text' # set to 'json' to see details
17+
if [[ -n "${GITHUB_WORKFLOW:-}" ]]
18+
then
19+
LOG_FORMAT='github-actions'
20+
fi
21+
22+
1623
## ----
1724

1825

@@ -24,13 +31,6 @@ function prepare () {
2431
function schema-lint () {
2532
echo '> lint schema files' >&2
2633

27-
if [[ -n "${GITHUB_WORKFLOW:-}" ]]
28-
then
29-
LOG_FORMAT='github-actions'
30-
else
31-
LOG_FORMAT='text'
32-
fi
33-
3434
docker run --rm \
3535
--volume "${ROOT_PATH}/${SCHEMA_DIR}:/workspace/${SCHEMA_DIR}:ro" \
3636
--volume "${THIS_PATH}/buf_lint.yaml:/workspace/buf.yaml:ro" \
@@ -46,17 +46,11 @@ function schema-lint () {
4646
function schema-breaking-version () {
4747
echo '> test schema for breaking changes against previous version' >&2
4848

49-
if [[ -n "${GITHUB_WORKFLOW:-}" ]]
50-
then
51-
LOG_FORMAT='github-actions'
52-
else
53-
LOG_FORMAT='text'
54-
fi
55-
5649
function compare() {
57-
NEW="bom-${1}.proto"
58-
OLD="bom-${2}.proto"
50+
local NEW="bom-${1}.proto"
51+
local OLD="bom-${2}.proto"
5952

53+
local NEW_NP OLD_NP
6054
NEW_NP="$(mktemp)"
6155
OLD_NP="$(mktemp)"
6256

@@ -77,8 +71,8 @@ function schema-breaking-version () {
7771
--error-format "$LOG_FORMAT"
7872
}
7973

80-
# compare '1.6' '1.5' # <-- possible breaks are acknowledged
81-
# compare '1.5' '1.4' # <-- possible breaks are acknowledged
74+
compare '1.6' '1.5' || echo "possible breaks are acknowledged for this specific version only"
75+
compare '1.5' '1.4' || echo "possible breaks are acknowledged for this specific version only"
8276
compare '1.4' '1.3'
8377

8478
echo '>> OK.' >&2
@@ -87,13 +81,6 @@ function schema-breaking-version () {
8781
function schema-breaking-remote () {
8882
echo '> test schema for breaking changes against remote' >&2
8983

90-
if [[ -n "${GITHUB_WORKFLOW:-}" ]]
91-
then
92-
LOG_FORMAT='github-actions'
93-
else
94-
LOG_FORMAT='text'
95-
fi
96-
9784
docker run --rm \
9885
--volume "${ROOT_PATH}/${SCHEMA_DIR}:/workspace/${SCHEMA_DIR}:ro" \
9986
--volume "${THIS_PATH}/buf_breaking-remote.yaml:/workspace/buf.yaml:ro" \
@@ -110,10 +97,10 @@ function schema-functional () {
11097
echo '> test all examples against the respective schema' >&2
11198

11299
function validate() {
113-
FILE="$1"
114-
SCHEMA_VERS="$2"
115-
SCHEMA_FILE="bom-${SCHEMA_VERS}.proto"
116-
MESSAGE="cyclonedx.v${SCHEMA_VERS/./_}.Bom"
100+
local FILE="$1"
101+
local SCHEMA_VERS="$2"
102+
local SCHEMA_FILE="bom-${SCHEMA_VERS}.proto"
103+
local MESSAGE="cyclonedx.v${SCHEMA_VERS/./_}.Bom"
117104

118105
echo ">> validate $(realpath --relative-to="$PWD" "$FILE") as ${MESSAGE} of ${SCHEMA_FILE}" >&2
119106

@@ -130,6 +117,7 @@ function schema-functional () {
130117
--to /dev/null
131118
}
132119

120+
local SCHEMA_VERS
133121
shopt -s globstar
134122
for test_res in "$ROOT_PATH"/"$TEST_RES_DIR"/*/valid-*.textproto
135123
do

0 commit comments

Comments
 (0)