@@ -10,27 +10,32 @@ TEST_RES_DIR='tools/src/test/resources'
1010
1111REMOTE=" https://github.com/${GITHUB_REPOSITORY:- CycloneDX/ specification} .git"
1212
13- BUF_IMAGE_VERSION=' 1.46.0'
13+ BUF_IMAGE_VERSION=' 1.50.0'
14+ BUF_IMAGE=" bufbuild/buf:$BUF_IMAGE_VERSION "
15+
16+ LOG_FORMAT=' text' # set to 'json' to see details
17+ if [[ -n " ${GITHUB_WORKFLOW:- } " ]]
18+ then
19+ LOG_FORMAT=' github-actions'
20+ fi
1421
1522
1623# # ----
1724
1825
26+ function prepare () {
27+ docker pull " $BUF_IMAGE "
28+ }
29+
30+
1931function schema-lint () {
2032 echo ' > lint schema files' >&2
2133
22- if [[ -n " ${GITHUB_WORKFLOW:- } " ]]
23- then
24- LOG_FORMAT=' github-actions'
25- else
26- LOG_FORMAT=' text'
27- fi
28-
2934 docker run --rm \
3035 --volume " ${ROOT_PATH} /${SCHEMA_DIR} :/workspace/${SCHEMA_DIR} :ro" \
3136 --volume " ${THIS_PATH} /buf_lint.yaml:/workspace/buf.yaml:ro" \
3237 --workdir ' /workspace' \
33- bufbuild/buf: " $BUF_IMAGE_VERSION " \
38+ " $BUF_IMAGE " \
3439 lint --path " $SCHEMA_DIR " \
3540 --error-format " $LOG_FORMAT "
3641
@@ -41,17 +46,11 @@ function schema-lint () {
4146function schema-breaking-version () {
4247 echo ' > test schema for breaking changes against previous version' >&2
4348
44- if [[ -n " ${GITHUB_WORKFLOW:- } " ]]
45- then
46- LOG_FORMAT=' github-actions'
47- else
48- LOG_FORMAT=' text'
49- fi
50-
5149 function compare() {
52- NEW=" bom-${1} .proto"
53- OLD=" bom-${2} .proto"
50+ local NEW=" bom-${1} .proto"
51+ local OLD=" bom-${2} .proto"
5452
53+ local NEW_NP OLD_NP
5554 NEW_NP=" $( mktemp) "
5655 OLD_NP=" $( mktemp) "
5756
@@ -66,15 +65,15 @@ function schema-breaking-version () {
6665 --volume " ${NEW_NP} :/workspaces/new/${SCHEMA_DIR} /${NEW} :ro" \
6766 --volume " ${THIS_PATH} /buf_breaking-version.yaml:/workspaces/new/buf.yaml:ro" \
6867 --workdir ' /workspaces/new' \
69- bufbuild/buf: " $BUF_IMAGE_VERSION " \
68+ " $BUF_IMAGE " \
7069 breaking \
7170 --against ../old \
7271 --error-format " $LOG_FORMAT "
7372 }
7473
7574 compare ' 1.7' ' 1.6'
76- # compare '1.6' '1.5' # <-- possible breaks are acknowledged
77- # compare '1.5' '1.4' # <-- possible breaks are acknowledged
75+ compare ' 1.6' ' 1.5' || echo " possible breaks are acknowledged for this specific version only "
76+ compare ' 1.5' ' 1.4' || echo " possible breaks are acknowledged for this specific version only "
7877 compare ' 1.4' ' 1.3'
7978
8079 echo ' >> OK.' >&2
@@ -83,18 +82,11 @@ function schema-breaking-version () {
8382function schema-breaking-remote () {
8483 echo ' > test schema for breaking changes against remote' >&2
8584
86- if [[ -n " ${GITHUB_WORKFLOW:- } " ]]
87- then
88- LOG_FORMAT=' github-actions'
89- else
90- LOG_FORMAT=' text'
91- fi
92-
9385 docker run --rm \
9486 --volume " ${ROOT_PATH} /${SCHEMA_DIR} :/workspace/${SCHEMA_DIR} :ro" \
9587 --volume " ${THIS_PATH} /buf_breaking-remote.yaml:/workspace/buf.yaml:ro" \
9688 --workdir ' /workspace' \
97- bufbuild/buf: " $BUF_IMAGE_VERSION " \
89+ " $BUF_IMAGE " \
9890 breaking --path " $SCHEMA_DIR " \
9991 --against " ${REMOTE} " \
10092 --error-format " $LOG_FORMAT "
@@ -106,10 +98,10 @@ function schema-functional () {
10698 echo ' > test all examples against the respective schema' >&2
10799
108100 function validate() {
109- FILE=" $1 "
110- SCHEMA_VERS=" $2 "
111- SCHEMA_FILE=" bom-${SCHEMA_VERS} .proto"
112- MESSAGE=" cyclonedx.v${SCHEMA_VERS/ ./ _} .Bom"
101+ local FILE=" $1 "
102+ local SCHEMA_VERS=" $2 "
103+ local SCHEMA_FILE=" bom-${SCHEMA_VERS} .proto"
104+ local MESSAGE=" cyclonedx.v${SCHEMA_VERS/ ./ _} .Bom"
113105
114106 echo " >> validate $( realpath --relative-to=" $PWD " " $FILE " ) as ${MESSAGE} of ${SCHEMA_FILE} " >&2
115107
@@ -119,13 +111,14 @@ function schema-functional () {
119111 --volume " ${ROOT_PATH} /${SCHEMA_DIR} :/workspace/${SCHEMA_DIR} :ro" \
120112 --volume " ${FILE} :/workspace/test_res:ro" \
121113 --workdir ' /workspace' \
122- bufbuild/buf: " $BUF_IMAGE_VERSION " \
114+ " $BUF_IMAGE " \
123115 convert " ${SCHEMA_DIR} /${SCHEMA_FILE} " \
124116 --type " $MESSAGE " \
125117 --from ' test_res#format=txtpb' \
126118 --to /dev/null
127119 }
128120
121+ local SCHEMA_VERS
129122 shopt -s globstar
130123 for test_res in " $ROOT_PATH " /" $TEST_RES_DIR " /* /valid-* .textproto
131124 do
@@ -142,23 +135,29 @@ function schema-functional () {
142135
143136case " ${1:- all} " in
144137 ' schema-lint' )
138+ prepare
145139 schema-lint
146140 ;;
147141 ' schema-breaking-version' )
142+ prepare
148143 schema-breaking-version
149144 ;;
150145 ' schema-breaking-remote' )
146+ prepare
151147 schema-breaking-remote
152148 ;;
153149 ' schema-breaking' )
150+ prepare
154151 schema-breaking-version
155152 schema-breaking-remote
156153 ;;
157154 ' schema-functional' )
155+ prepare
158156 schema-functional
159157 ;;
160158 ' all' )
161159 # all the above
160+ prepare
162161 schema-lint
163162 schema-breaking-version
164163 schema-breaking-remote
0 commit comments