From 6beae11f5afc71293eef1f510e63a7e290406c78 Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Wed, 13 Apr 2022 15:54:46 -0300 Subject: [PATCH 1/5] take into account extra dependencies higher up in the dependency chain --- check_dependent_project.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index c68fb72..64070b5 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -36,9 +36,11 @@ this_repo_diener_arg="$3" dependent_repo="$4" github_api_token="$5" update_crates_on_default_branch="$6" +extra_dependencies="${7:-}" this_repo_dir="$PWD" companions_dir="$this_repo_dir/companions" +extra_dependencies_dir="$this_repo_dir/extra_dependencies" github_api="https://api.github.com" org_github_prefix="https://github.com/$org" org_crates_prefix="git+$org_github_prefix" @@ -382,6 +384,31 @@ 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, when Cumulus is the dependent on Polkadot's pipeline, it is + # necessary to patch the master of Substrate into it since master will contain + # the pull request which was part of the dependency chain for this PR and was + # merged before it. + for extra_dependency in $extra_dependencies; do + git clone \ + --depth=1 \ + "https://github.com/$org/$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 + # 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 echo "Patching $this_repo into $dependent" From 3654ead2da0b059963ea182b27ab765fa306d190 Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Fri, 15 Apr 2022 05:41:44 -0300 Subject: [PATCH 2/5] enhance patching explanation --- check_dependent_project.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index 64070b5..4905bd3 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -386,14 +386,19 @@ patch_and_check_dependent() { # 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, when Cumulus is the dependent on Polkadot's pipeline, it is - # necessary to patch the master of Substrate into it since master will contain - # the pull request which was part of the dependency chain for this PR and was - # merged before it. + # 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_dir and $dependent" git clone \ --depth=1 \ - "https://github.com/$org/$extra_dependency.git" \ + "$org_github_prefix/$extra_dependency.git" \ "$extra_dependencies_dir/$extra_dependency" echo "Patching extra dependency $extra_dependency into $this_repo_dir" From aa5e79840b83a969249007e60a2dfe9d285126ea Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Fri, 15 Apr 2022 05:43:17 -0300 Subject: [PATCH 3/5] remove update_crates in favor of $extra_dependencies --- check_dependent_project.sh | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index 4905bd3..2075a8c 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -364,20 +364,6 @@ process_pr_description() { done } -update_crates() { - if [ $# -eq 0 ]; then - return - fi - - local args=() - - for crate in "$@"; do - args+=("-p" "$crate") - done - - cargo update "${args[@]}" -} - patch_and_check_dependent() { local dependent="$1" local dependent_repo_dir="$2" @@ -450,13 +436,6 @@ patch_and_check_dependent() { # would not yet how be how it should become after all merges are finished. match_dependent_crates "$dependent" - # Update the crates to the latest version. This is for example needed if there - # was a PR to Substrate which only required a Polkadot companion and Cumulus - # wasn't yet updated to use the latest commit of Polkadot. - # This should be done only *AFTER* patching so that "cargo update" will be - # able to find new crates introduced in the current pull request. - update_crates $update_crates_on_default_branch - eval "${COMPANION_CHECK_COMMAND:-cargo check --all-targets --workspace}" popd >/dev/null @@ -492,7 +471,7 @@ main() { if ! [ -e "$dependent_repo_dir" ]; then echo "Cloning $dependent_repo directly as it was not detected as a companion" dependent_repo_dir="$this_repo_dir/$dependent_repo" - git clone --depth=1 "https://github.com/$org/$dependent_repo.git" "$dependent_repo_dir" + git clone --depth=1 "$org_github_prefix/$dependent_repo.git" "$dependent_repo_dir" fi patch_and_check_dependent "$dependent_repo" "$dependent_repo_dir" From 471fa90e3ca2c7810236a9b5ea61e97eff0daa00 Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Fri, 15 Apr 2022 05:44:12 -0300 Subject: [PATCH 4/5] dedup $org_github_prefix --- check_dependent_project.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index 2075a8c..2b316ac 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -291,7 +291,7 @@ process_pr_description_line() { # be named "master") git clone \ --depth=$merge_ancestor_max_depth \ - "https://github.com/$org/$repo.git" \ + "$org_github_prefix/$repo.git" \ "$companions_dir/$repo" pushd "$companions_dir/$repo" >/dev/null From ee01f123128688577630e7fbdbe019ae57254df4 Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Fri, 15 Apr 2022 06:08:40 -0300 Subject: [PATCH 5/5] fix log --- check_dependent_project.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index 2b316ac..9676d34 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -381,7 +381,7 @@ patch_and_check_dependent() { # 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_dir and $dependent" + 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" \