Skip to contentSkip to conversation

automation: introduce a script for build test

PATCH In review Wei Liu 4 participants 8 messages Jul 24, 2018 – Jul 25, 2018

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 automation: introduce a script for build test

---
This is a script I wrote previously for build test.

Cc Andrew Cooper <[email protected]>
Cc George Dunlap <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>
Cc Wei Liu <[email protected]>
Cc Julien Grall <[email protected]>
Cc Anthony PERARD <[email protected]>

v5:
1. Use bash so that while do ... done < () works.
2. Move script to automation directory.

v4:
1. Check, save/restore $?.
2. Don't use trap, check exit code directly.
3. More error messages.

v3:
1. Use git-clean in default rune.
2. Print more friendly message.
3. Restore HEAD automatically.

---
 automation/scripts/build-test.sh | 68 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100755 automation/scripts/build-test.sh
automation/scripts/build-test.sh new file +68 -0
new file mode 100755
index 0000000000..885e5f7a13
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+# Run command on every commit within the range specified. If no command is
+# provided, use the default one to clean and build the whole tree.
+#
+# The default rune is rather simple. To do a cross-build, please put your usual
+# build rune in a shell script and invoke it with this script.
+
+if ! test -f xen/common/kernel.c; then
+    echo "Please run this script from top-level directory"
+    exit 1
+fi
+
+if test $# -lt 2 ; then
+    echo "Usage: $0 <BASE> <TIP> [CMD]"
+    exit 1
+fi
+
+status=`git status -s`
+if test -n "$status"; then
+    echo "Tree is dirty, aborted"
+    exit 1
+fi
+
+BASE=$1; shift
+TIP=$1; shift
+
+ORIG_BRANCH=`git symbolic-ref -q --short HEAD`
+if test $? -ne 0; then
+    echo "Detached HEAD, aborted"
+    exit 1
+fi
+
+while read num rev; do
+    echo "Testing $num $rev"
+
+    git checkout $rev
+    ret=$?
+    if test $ret -ne 0; then
+        echo "Failed to checkout $num $rev with $ret"
+        break
+    fi
+
+    if test $# -eq 0 ; then
+        git clean -fdx && ./configure && make -j4
+    else
+        "$@"
+    fi
+    ret=$?
+    if test $ret -ne 0; then
+        echo "Failed at $num $rev with $ret"
+        break
+    fi
+    echo
+done < <(git rev-list $BASE..$TIP | nl -ba | tac)
+
+echo "Restoring original HEAD"
+git checkout $ORIG_BRANCH
+gco_ret=$?
+if test $gco_ret -ne 0; then
+    echo "Failed to restore orignal HEAD. Check tree status before doing anything else!"
+    exit $gco_ret
+fi
+
+if test $ret -eq 0; then
+    echo "ok."
+fi
+exit $ret
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 4 lines · Wei Liu

---
This is a script I wrote previously for build test.

Goal here is to bisect a series to find the build failure? We could allow git bisect to do the work and just build and return success or failure instead of having to walk it by hand. I don't have one specifically for Xen but on other projects I've got something like:

./scripts/bisect.sh <GOOD> <BAD>

which looks roughly like:
#!/bin/sh

git bisect start $2 $1
git bisect run ./scripts/basic-build.sh

Then my ./scripts/basic-build.sh would look like:
#!/bin/sh

git clean -xdf
./configure || exit 1
make

Quoted 38 lines
Cc Andrew Cooper <[email protected]>
Cc George Dunlap <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>
Cc Wei Liu <[email protected]>
Cc Julien Grall <[email protected]>
Cc Anthony PERARD <[email protected]>

v5:
1. Use bash so that while do ... done < () works.
2. Move script to automation directory.

v4:
1. Check, save/restore $?.
2. Don't use trap, check exit code directly.
3. More error messages.

v3:
1. Use git-clean in default rune.
2. Print more friendly message.
3. Restore HEAD automatically.

---
 automation/scripts/build-test.sh | 68 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100755 automation/scripts/build-test.sh
automation/scripts/build-test.sh new file +2 -0
new file mode 100755
index 0000000000..885e5f7a13
@@ -0,0 +1,68 @@
+#!/bin/bash
+

automation/scripts/build-test.sh line 12

Quoted 10 lines
automation/scripts/build-test.sh new file +10 -0
+# Run command on every commit within the range specified. If no command is
+# provided, use the default one to clean and build the whole tree.
+#
+# The default rune is rather simple. To do a cross-build, please put your usual
+# build rune in a shell script and invoke it with this script.
+
+if ! test -f xen/common/kernel.c; then
+    echo "Please run this script from top-level directory"
+    exit 1
+fi

You could make it run from anywhere if you did:
pushd git rev-parse --show-toplevel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#2 lore raw
Quoted 7 lines · Doug Goldstein
Quoted 4 lines · Wei Liu

---
This is a script I wrote previously for build test.

Goal here is to bisect a series to find the build failure? We could

No, not to bisect. git-bisect would be good enough for bisection and I don't intent to poorly reinvent my own wheel.

We have seen many cases the build would be broken in the middle of a long series, but the series as a whole still builds. This script is to keep every commit in a series buildable so it doesn't break bisection.

And despite asking contributors nicely to do so, they don't tend to have the time to write all the commands in a safe way.

Quoted 13 lines
Quoted 13 lines
automation/scripts/build-test.sh new file +7 -0
new file mode 100755
index 0000000000..885e5f7a13
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+# Run command on every commit within the range specified. If no command is
+# provided, use the default one to clean and build the whole tree.
+#
+# The default rune is rather simple. To do a cross-build, please put your usual
+# build rune in a shell script and invoke it with this script.
Quoted 8 lines

automation/scripts/build-test.sh line 12

Quoted 5 lines
automation/scripts/build-test.sh new file +5 -0
+
+if ! test -f xen/common/kernel.c; then
+    echo "Please run this script from top-level directory"
+    exit 1
+fi

You could make it run from anywhere if you did:
pushd git rev-parse --show-toplevel

Ah, thanks for the tip.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Doug Goldstein
Quoted 11 lines · Doug Goldstein
Quoted 4 lines · Wei Liu

---
This is a script I wrote previously for build test.

Goal here is to bisect a series to find the build failure? We could allow git bisect to do the work and just build and return success or failure instead of having to walk it by hand. I don't have one specifically for Xen but on other projects I've got something like:

Actually, it's a script that those a similair job to:

    git rebase --exec ./scripts/basic-build.sh <base>
Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#4 lore raw
Quoted 7 lines · Anthony PERARD
Quoted 6 lines · Doug Goldstein
Quoted 4 lines · Wei Liu

---
This is a script I wrote previously for build test.

Quoted 8 lines
Quoted 5 lines

Goal here is to bisect a series to find the build failure? We could allow git bisect to do the work and just build and return success or failure instead of having to walk it by hand. I don't have one specifically for Xen but on other projects I've got something like:

Actually, it's a script that those a similair job to:

    git rebase --exec ./scripts/basic-build.sh <base>

To expound this a bit:

That's what I used and told others to use before, but it is far more dangerous than this script because git-rebase _rewrites_ history.

A failed command also doesn't restore original head, so it is less convenient -- you have to check the status of the tree every time something breaks.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 17 lines · Wei Liu
Quoted 7 lines · Anthony PERARD
Quoted 6 lines · Doug Goldstein
Quoted 4 lines · Wei Liu

---
This is a script I wrote previously for build test.

Quoted 8 lines
Quoted 5 lines

Goal here is to bisect a series to find the build failure? We could allow git bisect to do the work and just build and return success or failure instead of having to walk it by hand. I don't have one specifically for Xen but on other projects I've got something like:

Actually, it's a script that those a similair job to:

    git rebase --exec ./scripts/basic-build.sh <base>
Quoted 8 lines

To expound this a bit:

That's what I used and told others to use before, but it is far more dangerous than this script because git-rebase _rewrites_ history.

A failed command also doesn't restore original head, so it is less convenient -- you have to check the status of the tree every time something breaks.

I'm not opposed to the script you have, but it might be worth seeing what we can do to to use git rebase, since that simplifies the processing.

We could have a script, for instance, do something like:

curbranch=$(git name-rev --name-only HEAD)
git checkout -b tmp-series-build-test
if ! git rebase --exec ... $base ; then

	git rebase --abort

fi
git checkout -f $curbranch
git delete -D tmp-series-build-test

The history rewriting is now moot because you're rewriting a temporary branch.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
Quoted 9 lines · George Dunlap
Quoted 8 lines · Wei Liu
Quoted 1 line · Anthony PERARD
    git rebase --exec ./scripts/basic-build.sh <base>

To expound this a bit:

That's what I used and told others to use before, but it is far more dangerous than this script because git-rebase _rewrites_ history.

Quoted 6 lines
Quoted 3 lines

A failed command also doesn't restore original head, so it is less convenient -- you have to check the status of the tree every time something breaks.

I'm not opposed to the script you have, but it might be worth seeing what we can do to to use git rebase, since that simplifies the processing.

On the other hand, there might not be any support for git-rebase --exec, at it's a fairly new options, so the script would work with older version of git.

Quoted 5 lines

We could have a script, for instance, do something like:

curbranch=$(git name-rev --name-only HEAD)
git checkout -b tmp-series-build-test
if ! git rebase --exec ... $base ; then

Quoted 7 lines
	git rebase --abort

fi
git checkout -f $curbranch
git delete -D tmp-series-build-test

The history rewriting is now moot because you're rewriting a temporary branch.

Also, in my experience, rebase doesn't change history as long as it only picks commits (no squash/fixup moving commits arround), but it might with thing like --autosquash.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#7 lore raw
In reply to George Dunlap
Quoted 23 lines · George Dunlap
Quoted 22 lines · Wei Liu
Quoted 7 lines · Anthony PERARD
Quoted 6 lines · Doug Goldstein
Quoted 4 lines · Wei Liu

---
This is a script I wrote previously for build test.

Quoted 8 lines
Quoted 5 lines

Goal here is to bisect a series to find the build failure? We could allow git bisect to do the work and just build and return success or failure instead of having to walk it by hand. I don't have one specifically for Xen but on other projects I've got something like:

Actually, it's a script that those a similair job to:

    git rebase --exec ./scripts/basic-build.sh <base>

To expound this a bit:

That's what I used and told others to use before, but it is far more dangerous than this script because git-rebase _rewrites_ history.

Quoted 6 lines
Quoted 3 lines

A failed command also doesn't restore original head, so it is less convenient -- you have to check the status of the tree every time something breaks.

I'm not opposed to the script you have, but it might be worth seeing what we can do to to use git rebase, since that simplifies the processing.

Unfortunately git rebase --exec isn't supported in older versions of git.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel