Skip to content
Snippets Groups Projects

Simplify and fix special logic for CI_ONIRO_GIT_REPO_PATH

Merged Zygmunt Krynicki requested to merge zyga/oniro:feature/merge-trains into kirkstone
All threads resolved!
1 file
+ 6
8
Compare changes
  • Side-by-side
  • Inline
  • The Oniro pipeline is a bit special, because it has to cope with several layers
    of git repositories. On one hand side oniro.git uses git-repo manifests, this
    presents the first complexity of a branch trying to change the manifest that
    needs special care to test correctly (so that the test correctly verifies the
    change, rather than previous, known-good commit). On the other hand side it can
    be used as a reusable pipeline in other repositories that are described by the
    manifest naturally have distinct projects with their own pipelines.
    
    As a sort-of special case, oniro.git fits both of those conditions. Changes to
    oniro.git need to both replace the manifest checkout stage (repo init && repo
    sync) _and_ replace what the manifest would have checked out to instead use
    what GitLab wants to check out inside $CI_PROJECT_DIR.
    
    This presents us with a puzzle, what _did_ GitLab runner do? What exactly is
    checked out in $CI_PROJECT_DIR? This depends on project settings, pipeline type
    and perhaps other things we have yet to encounter.
    
    Instead of trying to correctly model all the variants, let's do something
    stupid and brutal, but correct. When the pipeline indicates that manifest
    element needs to be replaced by setting $CI_ONIRO_GIT_REPO_PATH to a non-empty
    value then remove the git checkout prepared by git-repo and replace it with a
    symbolic link to $CI_PROJECT_DIR.
    
    This allows us to work with merge trains, pipelines for branches and pipelines
    for merge requests all at the same time.
    
    Signed-off-by: default avatarZygmunt Krynicki <zygmunt.krynicki@huawei.com>
@@ -47,14 +47,12 @@
@@ -47,14 +47,12 @@
- |
- |
set -x
set -x
if [ -n "$CI_ONIRO_GIT_REPO_PATH" ]; then
if [ -n "$CI_ONIRO_GIT_REPO_PATH" ]; then
if [ -n "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL" ]; then
if [ ! -d "$CI_ONIRO_GIT_REPO_PATH/.git" ]; then
echo "CI: Bootstrapping '$CI_PROJECT_DIR' as 'incoming-merged' remote in '$CI_ONIRO_GIT_REPO_PATH'";
echo "Configuration error? $CI_ONIRO_GIT_REPO_PATH is not a git repository"
( cd "$CI_ONIRO_GIT_REPO_PATH" \
fi
&& git remote add incoming-merged "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL" \
echo "CI: Replacing $CI_ONIRO_GIT_REPO_PATH with $CI_PROJECT_DIR"
&& git fetch incoming-merged );
rm -rf "$CI_ONIRO_GIT_REPO_PATH"
fi;
ln -sf "$CI_PROJECT_DIR" "$CI_ONIRO_GIT_REPO_PATH"
echo "CI: Switching $CI_ONIRO_GIT_REPO_PATH to $CI_COMMIT_SHA";
( cd "$CI_ONIRO_GIT_REPO_PATH" && git checkout "$CI_COMMIT_SHA" );
fi
fi
set +x
set +x
Loading