Skip to content

Commit

Permalink
Verify partial repo build on CI (#1832)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
svyatonik authored Jan 31, 2023
1 parent f70f823 commit 50f2980
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 12 deletions.
9 changes: 9 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 50f2980

Please sign in to comment.