From 479e8f9628966e485805631d3008e8755e0685f5 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 17 Apr 2024 10:59:46 +0200 Subject: [PATCH] Fix dependency checking tool --- scripts/check-dependencies.bash | 57 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/scripts/check-dependencies.bash b/scripts/check-dependencies.bash index 91b4e22a..503b995f 100755 --- a/scripts/check-dependencies.bash +++ b/scripts/check-dependencies.bash @@ -80,33 +80,36 @@ fi # Now, lets make sure that the core and captive core version used in the tests use the same version and that they depend # on the same XDR revision -# TODO: The sed extractions below won't work when the commit is not included in the Core image tag/debian packages version -CORE_CONTAINER_REVISION=$($SED -n 's/.*\/\(stellar-core\|unsafe-stellar-core\(-next\)\{0,1\}\)\:.*\.\([a-zA-Z0-9]*\)\..*/\3/p' < cmd/soroban-rpc/internal/test/docker-compose.yml) -CAPTIVE_CORE_PKG_REVISION=$($SED -n 's/.*DEBIAN_PKG_VERSION:..*\.\([a-zA-Z0-9]*\)\..*/\1/p' < .github/workflows/soroban-rpc.yml) - -if [ "$CORE_CONTAINER_REVISION" != "$CAPTIVE_CORE_PKG_REVISION" ]; then - echo "Soroban RPC integration tests are using different versions of the Core container and Captive Core Debian package." - echo - echo "Core container image commit $CORE_CONTAINER_REVISION" - echo "Captive core debian package commit $CAPTIVE_CORE_PKG_REVISION" - exit 1 -fi - -# Revision of https://github.com/stellar/rs-stellar-xdr by Core. -# We obtain it from src/rust/src/host-dep-tree-curr.txt but Alternatively/in addition we could: -# * Check the rs-stellar-xdr revision of host-dep-tree-prev.txt -# * Check the stellar-xdr revision -CORE_HOST_DEP_TREE_CURR=$($CURL https://raw.githubusercontent.com/stellar/stellar-core/${CORE_CONTAINER_REVISION}/src/rust/src/host-dep-tree-curr.txt) - - -RS_STELLAR_XDR_REVISION_FROM_CORE=$(echo "$CORE_HOST_DEP_TREE_CURR" | stellar_xdr_version_from_rust_dep_tree) -if [ "$RS_STELLAR_XDR_REVISION" != "$RS_STELLAR_XDR_REVISION_FROM_CORE" ]; then - echo "The Core revision used in integration tests (${CORE_CONTAINER_REVISION}) uses a different revision of https://github.com/stellar/rs-stellar-xdr" - echo - echo "Current repository's revision $RS_STELLAR_XDR_REVISION" - echo "Core's revision $RS_STELLAR_XDR_REVISION_FROM_CORE" - exit 1 -fi +PROTOCOL_VERSIONS=$(grep 'protocol-version: ' .github/workflows/soroban-rpc.yml | grep -o -E '[0-9]+') + +for P in $PROTOCOL_VERSIONS; do + CORE_CONTAINER_REVISION=$($SED -n 's/.*PROTOCOL_'$P'_CORE_DOCKER_IMG:.*\/\(stellar-core\|unsafe-stellar-core\(-next\)\{0,1\}\)\:.*\.\([a-zA-Z0-9]*\)\..*/\3/p' < .github/workflows/soroban-rpc.yml) + CAPTIVE_CORE_PKG_REVISION=$($SED -n 's/.*PROTOCOL_'$P'_CORE_DEBIAN_PKG_VERSION:.*\.\([a-zA-Z0-9]*\)\..*/\1/p' < .github/workflows/soroban-rpc.yml) + + if [ "$CORE_CONTAINER_REVISION" != "$CAPTIVE_CORE_PKG_REVISION" ]; then + echo "Soroban RPC protocol $P integration tests are using different versions of the Core container and Captive Core Debian package." + echo + echo "Core container image commit $CORE_CONTAINER_REVISION" + echo "Captive core debian package commit $CAPTIVE_CORE_PKG_REVISION" + exit 1 + fi + + # Revision of https://github.com/stellar/rs-stellar-xdr by Core. + # We obtain it from src/rust/src/host-dep-tree-curr.txt but Alternatively/in addition we could: + # * Check the rs-stellar-xdr revision of host-dep-tree-prev.txt + # * Check the stellar-xdr revision + CORE_HOST_DEP_TREE_CURR=$($CURL https://raw.githubusercontent.com/stellar/stellar-core/${CORE_CONTAINER_REVISION}/src/rust/src/host-dep-tree-curr.txt) + + + RS_STELLAR_XDR_REVISION_FROM_CORE=$(echo "$CORE_HOST_DEP_TREE_CURR" | stellar_xdr_version_from_rust_dep_tree) + if [ "$RS_STELLAR_XDR_REVISION" != "$RS_STELLAR_XDR_REVISION_FROM_CORE" ]; then + echo "The Core revision used in protocol $P integration tests (${CORE_CONTAINER_REVISION}) uses a different revision of https://github.com/stellar/rs-stellar-xdr" + echo + echo "Current repository's revision $RS_STELLAR_XDR_REVISION" + echo "Core's revision $RS_STELLAR_XDR_REVISION_FROM_CORE" + exit 1 + fi +done