diff options
author | Barış Kaya <bkaya@google.com> | 2022-12-07 15:00:49 +0000 |
---|---|---|
committer | Barış Kaya <bkaya@google.com> | 2022-12-14 15:30:55 +0000 |
commit | e5e5bc37212707eef74cfecd4114058ebf3456a8 (patch) | |
tree | 6feb4a48481fac0cdde0460539a6c82fe6506ce4 | |
parent | cf9df6e927bafbc496e160830d378600c53bddc8 (diff) | |
download | gamesdk-e5e5bc37212707eef74cfecd4114058ebf3456a8.tar.gz |
Add preupload testing to check library versions and compare them to the VERSIONS file
Bug: b/261001108
Test: changed library versions to see if I could submit
Change-Id: Ie079c1a34035bd374b3f7142c9df575db3068a56
-rw-r--r-- | PREUPLOAD.cfg | 4 | ||||
-rwxr-xr-x | hooks/check_bugfix_version.sh | 28 | ||||
-rwxr-xr-x | hooks/check_library_versions.sh | 41 | ||||
-rwxr-xr-x | hooks/check_swappy_abi_version.sh | 32 | ||||
-rwxr-xr-x | hooks/check_tuningfork_abi_version.sh | 30 |
5 files changed, 42 insertions, 93 deletions
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg index 49e4f953..760ffcfc 100644 --- a/PREUPLOAD.cfg +++ b/PREUPLOAD.cfg @@ -1,8 +1,6 @@ [Hook Scripts] -swappy_abi_hook = ${REPO_ROOT}/gamesdk/hooks/check_swappy_abi_version.sh ${PREUPLOAD_COMMIT} ${PREUPLOAD_FILES} -tuningfork_abi_hook = ${REPO_ROOT}/gamesdk/hooks/check_tuningfork_abi_version.sh ${PREUPLOAD_COMMIT} ${PREUPLOAD_FILES} -bugfix_hook = ${REPO_ROOT}/gamesdk/hooks/check_bugfix_version.sh ${PREUPLOAD_COMMIT} ${PREUPLOAD_FILES} +versions_hook = ${REPO_ROOT}/gamesdk/hooks/check_library_versions.sh ${PREUPLOAD_COMMIT} ${PREUPLOAD_FILES} [Builtin Hooks] clang_format = true diff --git a/hooks/check_bugfix_version.sh b/hooks/check_bugfix_version.sh deleted file mode 100755 index aba002f0..00000000 --- a/hooks/check_bugfix_version.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -SWAPPY_PATTERN="games-frame-pacing/.*[.](cpp|h)$" -TUNINGFORK_PATTERN="src/tuningfork/.*[.](cpp|h)$" - -SWAPPY_COMMON_H="include/swappy/swappy_common.h" -TUNINGFORK_H="include/tuningfork/tuningfork.h" - -files=$2 -swappyChanged=0 -tuningforkChanged=0 -for file in ${files[@]}; do - echo $file - - if [[ $file =~ $SWAPPY_PATTERN ]]; then - swappyChanged=1 - fi - if [[ $file =~ $TUNINGFORK_PATTERN ]]; then - tuningforkChanged=1 - fi -done - -echo "Swappy changed: $swappyChanged" -echo "TuningFork changed: $tuningforkChanged" - -# TODO (willosborn): check that swappy and tuningfork versions match those in VERSIONS - -exit 0 diff --git a/hooks/check_library_versions.sh b/hooks/check_library_versions.sh new file mode 100755 index 00000000..ce2b95fb --- /dev/null +++ b/hooks/check_library_versions.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SWAPPY_COMMON_H="include/swappy/swappy_common.h" +TUNINGFORK_H="include/tuningfork/tuningfork.h" + +VERSIONS="VERSIONS" + +library_names=(games-frame-pacing games-performance-tuner game-activity game-text-input games-controller games-memory-advice) +header_files=(include/swappy/swappy_common.h include/tuningfork/tuningfork.h game-activity/prefab-src/modules/game-activity/include/game-activity/GameActivity.h game-text-input/prefab-src/modules/game-text-input/include/game-text-input/gametextinput.h include/paddleboat/paddleboat.h include/memory_advice/memory_advice.h) +library_version_prefix=(SWAPPY TUNINGFORK GAMEACTIVITY GAMETEXTINPUT PADDLEBOAT MEMORY_ADVICE) + + +for i in "${!library_names[@]}"; do + library="${library_names[i]}" + header="${header_files[i]}" + prefix="${library_version_prefix[i]}" + [[ `cat VERSIONS` =~ $library[[:space:]]*([0-9]+.[0-9]+.[0-9]+)[[:space:]]*([a-z]*) ]] + versions_version="${BASH_REMATCH[1]}" + version_suffix="${BASH_REMATCH[2]}" + [[ `cat $header` =~ ${prefix}_MAJOR_VERSION.([0-9]+) ]] + major="${BASH_REMATCH[1]}" + [[ `cat $header` =~ ${prefix}_MINOR_VERSION.([0-9]+) ]] + minor="${BASH_REMATCH[1]}" + [[ `cat $header` =~ ${prefix}_BUGFIX_VERSION.([0-9]+) ]] + bugfix="${BASH_REMATCH[1]}" + header_version="${major}.${minor}.${bugfix}" + if [[ "${major}.${minor}.${bugfix}" != $versions_version ]]; then + echo "Version mismatch! For ${library}, the version declared in its header is ${header_version} but the version declared in the VERSIONS file is ${versions_version}." + exit 1 + fi + if [[ $version_suffix =~ "alpha" ]] && [[ $bugfix != "0" ]]; then + echo "Invalid version! ${library} is declared as an alpha release, but has a bugfix version." + exit 1 + fi + if [[ $version_suffix =~ "beta" ]] && [[ $bugfix != "0" ]]; then + echo "Invalid version! ${library} is declared as a beta release, but has a bugfix version." + exit 1 + fi +done + +exit 0 diff --git a/hooks/check_swappy_abi_version.sh b/hooks/check_swappy_abi_version.sh deleted file mode 100755 index 7c2957da..00000000 --- a/hooks/check_swappy_abi_version.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -SWAPPY_GL_H="include/swappy/swappyGL.h" -SWAPPY_GL_EXTRA_H="include/swappy/swappyGL_extra.h" -SWAPPY_VK_H="include/swappy/swappyVk.h" -SWAPPY_VK_EXTRA_H="include/swappy/swappyVk_extra.h" -SWAPPY_COMMON_H="include/swappy/swappy_common.h" - -SWAPPY_HEADERS=($SWAPPY_GL_H $SWAPPY_GL_EXTRA_H $SWAPPY_VK_H $SWAPPY_VK_EXTRA_H $SWAPPY_COMMON_H) - -files=$2 -headerChanged=0 -for file in ${files[@]}; do - for header in ${SWAPPY_HEADERS[@]}; do - if [[ $file =~ $header ]]; then - headerChanged=1 - break - fi - done -done - -if [ $headerChanged -eq "1" ]; then - majorVersion=`git show $1 $SWAPPY_COMMON_H | grep "#define SWAPPY_MAJOR_VERSION" | wc -l` - minorVersion=`git show $1 $SWAPPY_COMMON_H | grep "#define SWAPPY_MINOR_VERSION" | wc -l` - # echo "version_files $version_files" - if [[ $majorVersion -eq "0" && $minorVersion -eq "0" ]]; then - echo "Warning: did you break the Swappy ABI without changing SWAPPY_MAJOR_VERSION or SWAPPY_MINOR_VERSION ?" - fi - -fi - -exit 0 diff --git a/hooks/check_tuningfork_abi_version.sh b/hooks/check_tuningfork_abi_version.sh deleted file mode 100755 index fdf30cb7..00000000 --- a/hooks/check_tuningfork_abi_version.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -TUNINGFORK_H="include/tuningfork/tuningfork.h" -TUNINGFORK_EXTRA_H="include/tuningfork/tuningfork_extra.h" -UNITY_TUNINGFORK_H="include/tuningfork/unity_tuningfork.h" -TUNINGFORK_HEADERS=($TUNINGFORK_H $TUNINGFORK_EXTRA_H $UNITY_TUNINGFORK_H) - -files=$2 -headerChanged=0 -for file in ${files[@]}; do - for header in ${TUNINGFORK_HEADERS[@]}; do - if [[ $file =~ $header ]]; then - headerChanged=1 - break - fi - done -done - -if [ $headerChanged -eq "1" ]; then - - majorVersion=`git show $1 $TUNINGFORK_H | grep "#define TUNINGFORK_MAJOR_VERSION" | wc -l` - minorVersion=`git show $1 $TUNINGFORK_H | grep "#define TUNINGFORK_MINOR_VERSION" | wc -l` - # echo "version_files $version_files" - if [[ $majorVersion -eq "0" && $minorVersion -eq "0" ]]; then - echo "Warning: did you break the TuningFork ABI without changing TUNINGFORK_MAJOR_VERSION or TUNINGFORK_MINOR_VERSION ?" - fi - -fi - -exit 0 |