From 50f2980e9b8fdfe8c1f1c61651ac8546ed93c32c Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 31 Jan 2023 19:08:55 +0300 Subject: [PATCH] Verify partial repo build on CI (#1832) * verify partial repo build on CI * try with "git checkout ." * no-revert * use no-revert on CI * fix for use in Cumulus repo * move to nightly * move desc * rename script * actual rename --- .gitlab-ci.yml | 9 ++++ ...-repo-build.sh => verify-pallets-build.sh} | 53 ++++++++++++++----- 2 files changed, 50 insertions(+), 12 deletions(-) rename scripts/{verify-partial-repo-build.sh => verify-pallets-build.sh} (77%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d87b78713e696..9b9a0d2d86f96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -191,6 +191,15 @@ benchmarks-test: # we may live with failing benchmarks, it is just a signal for us allow_failure: true +partial-repo-build-test: + stage: test + <<: *docker-env + <<: *nightly-test + script: + - ./scripts/verify-pallets-build.sh --no-revert + # we may live with failing partial repo build, it is just a signal for us + allow_failure: true + #### stage: build build: diff --git a/scripts/verify-partial-repo-build.sh b/scripts/verify-pallets-build.sh similarity index 77% rename from scripts/verify-partial-repo-build.sh rename to scripts/verify-pallets-build.sh index d7de84d620f1c..daa0cc6b2113a 100755 --- a/scripts/verify-partial-repo-build.sh +++ b/scripts/verify-pallets-build.sh @@ -8,6 +8,35 @@ # - modules/relayers; # - everything required from primitives folder. +set -eux + +# show CLI help +function show_help() { + set +x + echo " " + echo Error: $1 + echo "Usage:" + echo " ./scripts/verify-pallets-build.sh Exit with code 0 if pallets code is well decoupled from the other code in the repo" + echo "Options:" + echo " --no-revert Leaves only runtime code on exit" + exit 1 +} + +# parse CLI args +NO_REVERT= +for i in "$@" +do + case $i in + --no-revert) + NO_REVERT=true + shift + ;; + *) + show_help "Unknown option: $i" + ;; + esac +done + # the script is able to work only on clean git copy [[ -z "$(git status --porcelain)" ]] || { echo >&2 "The git copy must be clean"; exit 1; } @@ -18,8 +47,7 @@ BRIDGES_FOLDER="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && p # let's leave repository/subtree in its original (clean) state if something fails below function revert_to_clean_state { - echo "Reverting to clean state..." - git reset --hard + [[ ! -z "${NO_REVERT}" ]] || { echo "Reverting to clean state..."; git checkout .; } } trap revert_to_clean_state EXIT @@ -48,17 +76,18 @@ rm -f $BRIDGES_FOLDER/ci.Dockerfile rm -f $BRIDGES_FOLDER/Dockerfile # let's fix Cargo.toml a bit (it'll be helpful if we are in the bridges repo) +if [[ ! -f "Cargo.toml" ]]; then + cat > Cargo.toml <<-CARGO_TOML + [workspace] + resolver = "2" -cat > $BRIDGES_FOLDER/Cargo.toml <<-CARGO_TOML -[workspace] -resolver = "2" - -members = [ - "bin/runtime-common", - "modules/*", - "primitives/*", -] -CARGO_TOML + members = [ + "bin/runtime-common", + "modules/*", + "primitives/*", + ] + CARGO_TOML +fi # let's test if everything we need compiles