From e01a208d4f65a7baadb5f56dcdfbe626463b4916 Mon Sep 17 00:00:00 2001 From: Ryan Roberts Date: Fri, 18 Oct 2024 18:48:50 +0100 Subject: [PATCH] test: Run test-sync.sh repo sync tests on CI Jean-Philippe's test-sync.sh does an excellent job of testing Shrinkwrap's various repo sync options work as intended. So let's hook it up so the CI runs it automatically as a regression test. For simplicity, let's call it from within test.py so that we can easily add a junit test result for it, which Gitlab will display. Unfortunately there are some complications for running in the container; We can't use ssh for the remote submodules, so let's use file://, but this requires overriding a global config to allow it. And we must configure name and email. So let's create a temporary gitconfig for the test. Signed-off-by: Ryan Roberts --- test/test-sync.sh | 19 ++++++++++++++++--- test/test.py | 12 +++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/test/test-sync.sh b/test/test-sync.sh index ea26665..c662da1 100755 --- a/test/test-sync.sh +++ b/test/test-sync.sh @@ -21,6 +21,19 @@ trap "rm -rf $T" EXIT export SHRINKWRAP_BUILD=$T/build export SHRINKWRAP_PACKAGE=$T/package +cat << EOF > $T/gitconfig +# Needed when not configured in config (e.g. on ci) +[user] + name = Mr T. Ester + email = mr.t.ester@test-sync.sh + +# Needed so we can use local repo paths for submodules +[protocol.file] + allow = always +EOF + +export GIT_CONFIG_GLOBAL=$T/gitconfig + # Test $1 must succeed OK () { local name="$1" @@ -75,7 +88,7 @@ TESTS () { git add README git commit -m "commit 0" - git submodule add ssh://localhost:$T/module1 module + git submodule add file://$T/module1 module git commit -a -m "Add module 1" popd } >> $LOG @@ -406,7 +419,7 @@ TESTS Override branch git add README git commit -a -m "commit 0" - git submodule add ssh://localhost:$T/module2 module + git submodule add file://$T/module2 module git commit -a -m "Add module 2" popd } >> $LOG @@ -455,7 +468,7 @@ TESTS Update module URL { pushd $T/repo2 git submodule set-branch -b main module - git submodule set-url module ssh://localhost:$T/module1 + git submodule set-url module file://$T/module1 git submodule update --remote git commit -a -m "Update module URL" popd diff --git a/test/test.py b/test/test.py index 10c8613..e39b59e 100755 --- a/test/test.py +++ b/test/test.py @@ -20,7 +20,9 @@ IMAGE = None FVPJOBS = None -ASSETS = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets') +SCRIPTDIR = os.path.dirname(os.path.abspath(__file__)) +SYNCTEST = os.path.join(SCRIPTDIR, 'test-sync.sh') +ASSETS = os.path.join(SCRIPTDIR, 'assets') KERNEL = os.path.join(ASSETS, 'Image') BOOTWRAPPER = os.path.join(ASSETS, 'linux-system.axf') ROOTFS = os.path.join(ASSETS, 'rootfs.ext4') @@ -372,6 +374,14 @@ def do_main(args): build_configs(configs, btvarss=btvarss) run_configs(configs, rtvarss=rtvarss) + # Run repo sync tests. + ret = subprocess.run(SYNCTEST).returncode + results.append({ + 'type': 'repo-sync-behaviours', + 'status': 'pass' if ret == 0 else 'fail', + 'error': None, + }) + success = print_results(args.junit) exit(not success) -- GitLab