From 843db16c212805952e3fe8931e29f3686149369b Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Oct 31 2019 13:37:13 +0000 Subject: [PATCH 1/2] Get tests working on F29 Signed-off-by: Stephen Gallagher --- diff --git a/run_tests.sh b/run_tests.sh old mode 100644 new mode 100755 index f18d12f..9b542af --- a/run_tests.sh +++ b/run_tests.sh @@ -1,18 +1,70 @@ #!/bin/bash -if [ -n "$REPO" -a -n "$BRANCH" ]; then -git remote rm proposed || true -git gc --auto -git remote add proposed "$REPO" -git fetch proposed -git checkout origin/f29 -git config --global user.email "noreply@ci.centos.org" -git config --global user.name "CentOS CI" -git merge --no-ff "proposed/$BRANCH" -m "Merge PR" - -echo "Running tests for branch $BRANCH of repo $REPO" -echo "Last commits:" -git log -2 +set -e +set -x + +ORIGIN_REPO=$(git config remote.origin.url) +MODULE_DEFAULTS_TEST_UPDATED=$(git log -1 --pretty=%H) + +if [ "$BRANCH_TO" != "None" -a "$BRANCH_TO" != "" ]; then + git config user.email "noreply@ci.centos.org" + git config user.name "CentOS CI" + + # Save the commit ID of the baseline checkout + MODULE_DEFAULTS_TEST_BASELINE=$(git log -1 --pretty=%H origin/$BRANCH_TO) + export MODULE_DEFAULTS_TEST_BASELINE + + # Merge the PR into the current tree + git remote rm proposed || true + git gc --auto + git remote add proposed "$REPO" + git fetch proposed + + MODULE_DEFAULTS_TEST_UPDATED=$(git log -1 --pretty=%H proposed/$BRANCH) + export MODULE_DEFAULTS_TEST_UPDATED + + # Test that it merges cleanly + git branch -D pullrequest || true + git checkout -b pullrequest $MODULE_DEFAULTS_TEST_BASELINE + git merge --no-ff "$MODULE_DEFAULTS_TEST_UPDATED" -m "Merge PR" + + echo "Running tests for branch $BRANCH of repo $REPO" + echo "Last commits:" + git log $MODULE_DEFAULTS_TEST_BASELINE..$MODULE_DEFAULTS_TEST_UPDATED + + # If this branch is atop the master, use its tests (possibly updated). + # Otherwise, check out origin/master for the latest tests. + set +e + git merge-base --is-ancestor -- origin/master HEAD + set -e + if [ $? -ne 0 ]; then + git checkout origin/master + fi + + # Run any tests that only apply to PRs + tests/pr_tests.sh +fi + +git reset --hard $MODULE_DEFAULTS_TEST_UPDATED + +# If this branch is atop the master, use its tests (possibly updated). +# Otherwise, check out origin/master for the latest tests. +TEMPDIR= +set +e +git merge-base --is-ancestor -- origin/master HEAD +set -e +if [ $? -ne 0 ]; then + TEMPDIR=$(mktemp -d) + git clone $ORIGIN_REPO $TEMPDIR + TEST_DIR=$TEMPDIR/tests +else + TEST_DIR=$(pwd)/tests fi -make check + +# Run any tests that apply to either PRs or commits +$TEST_DIR/common_tests.sh $(pwd)/tests + +if [ x$TEMPDIR != x ]; then + rm -Rf $TEMPDIR +fi From c9c76636ae52895d2dfe3a68b93a63428d2717cf Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Oct 31 2019 13:55:17 +0000 Subject: [PATCH 2/2] TESTS: Fix return-code checking Signed-off-by: Stephen Gallagher --- diff --git a/run_tests.sh b/run_tests.sh index 9b542af..bc1fc82 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -36,8 +36,9 @@ if [ "$BRANCH_TO" != "None" -a "$BRANCH_TO" != "" ]; then # Otherwise, check out origin/master for the latest tests. set +e git merge-base --is-ancestor -- origin/master HEAD + ret=$? set -e - if [ $? -ne 0 ]; then + if [ $ret -ne 0 ]; then git checkout origin/master fi @@ -52,8 +53,9 @@ git reset --hard $MODULE_DEFAULTS_TEST_UPDATED TEMPDIR= set +e git merge-base --is-ancestor -- origin/master HEAD +ret=$? set -e -if [ $? -ne 0 ]; then +if [ $ret -ne 0 ]; then TEMPDIR=$(mktemp -d) git clone $ORIGIN_REPO $TEMPDIR TEST_DIR=$TEMPDIR/tests