Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-paulo-parity committed Apr 26, 2022
1 parent 8cd7bf7 commit 6f7c244
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 35 deletions.
73 changes: 39 additions & 34 deletions check_dependent_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -384,35 +384,39 @@ patch_and_check_dependent() {

pushd "$dependent_repo_dir" >/dev/null

# It is necessary to patch in extra dependencies which have already been
# merged in previous steps of the Companion Build System's dependency chain.
# For instance, consider the following dependency chain:
# Substrate -> Polkadot -> Cumulus
# When this script is running for Cumulus as the dependent, on Polkadot's
# pipeline, it is necessary to patch the master of Substrate into this
# script's branches because Substrate's master will contain the pull request
# which was part of the dependency chain for this PR and was merged before
# this script gets to run for the last time (after lockfile updates and before
# merge).
for extra_dependency in $extra_dependencies; do
echo "Cloning extra dependency $extra_dependency to patch its default branch into $this_repo and $dependent"
git clone \
--depth=1 \
"$org_github_prefix/$extra_dependency.git" \
"$extra_dependencies_dir/$extra_dependency"

echo "Patching extra dependency $extra_dependency into $this_repo_dir"
diener patch \
--target "$org_github_prefix/$extra_dependency" \
--crates-to-patch "$extra_dependencies_dir/$extra_dependency" \
--path "$this_repo_dir/Cargo.toml"

echo "Patching extra dependency $extra_dependency into $dependent"
diener patch \
--target "$org_github_prefix/$extra_dependency" \
--crates-to-patch "$extra_dependencies_dir/$extra_dependency" \
--path Cargo.toml
done
if [ "${has_overridden_dependent_repo_ref:-}" ]; then
echo "Skipping extra_dependencies ($extra_dependencies) as the dependent repository's ref has been overridden"
else
# It is necessary to patch in extra dependencies which have already been
# merged in previous steps of the Companion Build System's dependency chain.
# For instance, consider the following dependency chain:
# Substrate -> Polkadot -> Cumulus
# When this script is running for Cumulus as the dependent, on Polkadot's
# pipeline, it is necessary to patch the master of Substrate into this
# script's branches because Substrate's master will contain the pull request
# which was part of the dependency chain for this PR and was merged before
# this script gets to run for the last time (after lockfile updates and before
# merge).
for extra_dependency in $extra_dependencies; do
echo "Cloning extra dependency $extra_dependency to patch its default branch into $this_repo and $dependent"
git clone \
--depth=1 \
"$org_github_prefix/$extra_dependency.git" \
"$extra_dependencies_dir/$extra_dependency"

echo "Patching extra dependency $extra_dependency into $this_repo_dir"
diener patch \
--target "$org_github_prefix/$extra_dependency" \
--crates-to-patch "$extra_dependencies_dir/$extra_dependency" \
--path "$this_repo_dir/Cargo.toml"

echo "Patching extra dependency $extra_dependency into $dependent"
diener patch \
--target "$org_github_prefix/$extra_dependency" \
--crates-to-patch "$extra_dependencies_dir/$extra_dependency" \
--path Cargo.toml
done
fi

# Patch this repository (the dependency) into the dependent for the sake of
# being able to test how the dependency graph will behave after the merge
Expand Down Expand Up @@ -473,8 +477,6 @@ main() {
# This PR might be targetting a custom ref (i.e. not master) through
# --companion-overrides, in which case it won't be proper to merge master
# (since it's not targetting master) before realizing the companion checks
local prevent_master_merge_before_companion_check

local dependent_repo_dir="$companions_dir/$dependent_repo"
if ! [ -e "$dependent_repo_dir" ]; then
local dependent_clone_options=(
Expand Down Expand Up @@ -544,8 +546,9 @@ main() {

local successor_branch_name
while IFS= read -r line; do
echo "Found candidate branch $line in $dependent_repo"
echo "Got candidate branch $line in $dependent_repo's refs"
if [ "${line:0:${#dependent_repo_override_prefix}}" == "$dependent_repo_override_prefix" ]; then
echo "Found candidate branch $line as the successor of $branch_name"
successor_branch_name="$line"
break
fi
Expand Down Expand Up @@ -577,7 +580,7 @@ main() {

# when a ref is matched through --companion-overrides, don't merge
# master into the branch in order to avoid disturbing its state
prevent_master_merge_before_companion_check=true
has_overridden_dependent_repo_ref=true

break
done
Expand All @@ -591,7 +594,9 @@ main() {
"$dependent_repo_dir"
fi

if [ ! "${prevent_master_merge_before_companion_check:-}" ]; then
if [ "${has_overridden_dependent_repo_ref:-}" ]; then
echo "Skipping master merge of $this_repo as the dependent repository's ref has been overridden"
else
# Merge master into this branch so that we have a better expectation of the
# integration still working after this PR lands.
# Since master's HEAD is being merged here, at the start the dependency chain,
Expand Down
4 changes: 3 additions & 1 deletion utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ get_arg() {
local option_arg="$1"
shift

local args=("$@")

unset out
out=()

local get_next_arg
for arg in "$@"; do
for arg in "$args"; do
if [ "${get_next_arg:-}" ]; then
out+=("$arg")
unset get_next_arg
Expand Down

0 comments on commit 6f7c244

Please sign in to comment.