Skip to content

Commit

Permalink
Merge branch 'github-actions-part15' into master
Browse files Browse the repository at this point in the history
= GitHub Actions part 15: Test the Gradle builder against the Ant
builder once, improve the test scripts

Some time ago I wrote the following scripts:
  tools/compare-gradle-jars-against-ant-jars
  tools/compare-gradle-tests-against-ant-tests

These can be used to test if the Gradle builder produces the same JARs
as the Ant one, and if it runs the same tests.

Because the migration from Travis CI to GitHub Actions could have
broken things about Ant/Gradle, I have enabled the scripts on GHA once
on this branch to see if they succeed, which they did on Linux up to
Java 15, and thus disabled them again.

Java 16 and above fail on Linux due to actual unit test failures which
likely aren't the fault of the build system.

Further, I've noticed that the two scripts do not work on macOS and
MinGW (which GHA uses on Windows to run Ant).
But the failures are due to the different OS environments breaking the
scripts, and breaking Ant - the actual output of the builders cannot be
tested.

Since the Ant and Gradle build scripts do not contain any conditions to
do things differently on different operating systems I decided it's
enough that the scripts succeed on Linux and I do not want to spend the
effort to get them working on the other environments.

Hence I've amended them with code to exit early on macOS & MinGW,
telling the user to use Linux for them instead.

Remaining GHA work:
- Resolve the remaining 2 FIXMEs added to the code by the
  github-actions-part* branches.
  1 was resolved by this branch.
- Reduce the number of old Java versions we test on, add new ones which
  have been released meanwhile.
- Investigate why the unit tests have recently started to fail on
  Windows, and with the Ant builder on Linux for Java >= 16.
  If this can't be fixed right away disable the tests on Windows and
  file a bug.
  • Loading branch information
xor-freenet committed Jul 15, 2023
2 parents 5c7b92f + 55e03eb commit 7cfbcbe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ jobs:
# To test the Ant and Gradle builders against each other uncomment the following.
# (The scripts will use ./gradlew if there is one so we can ensure a specific Gradle version
# works if that becomes necessary someday.)
# FIXME: Do this because this script has been converted from Travis CI to GitHub Actions.
## - tools/compare-gradle-jars-with-ant-jars
## - tools/compare-gradle-tests-with-ant-tests
## tools/compare-gradle-jars-with-ant-jars
## tools/compare-gradle-tests-with-ant-tests
# Show stdout/stderr so random seeds of failed tests can be obtained by developers to
# reproduce failed test runs. Also prevents the 10 minute build timeout.
FREETALK__SHOW_GRADLE_TEST_OUTPUT=1 gradle clean test jar
Expand Down
15 changes: 14 additions & 1 deletion tools/compare-gradle-jars-with-ant-jars
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ set -o errexit
set -o errtrace
trap 'echo "Error at line $LINENO, exit code $?" >&2' ERR

case "$OSTYPE" in
darwin*)
echo "This script does not work on macOS, run it on Linux instead!" >&2
echo "(macOS' mktemp does not support the arguments we use.)" >&2
exit 1
;;
msys)
echo "This script does not work on MinGW, run it on Linux instead!" >&2
echo "(The Ant builder fails on MinGW due to /usr/share/java/junit4.jar not existing.)" >&2
exit 1
;;
esac

tmpdir="$(mktemp --directory)"
trap 'rm -rf -- "$tmpdir"' EXIT

if [ -e "./gradlew" ] ; then
# The Travis CI script expects us to use ./gradlew to test compatibility.
# The GitHub Actions script expects us to use ./gradlew to test compatibility.
echo "Found ./gradlew, using it instead of system's Gradle."
shopt -s expand_aliases
unalias -a
Expand Down
15 changes: 14 additions & 1 deletion tools/compare-gradle-tests-with-ant-tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ set -o errexit
set -o errtrace
trap 'echo "Error at line $LINENO, exit code $?" >&2' ERR

case "$OSTYPE" in
darwin*)
echo "This script does not work on macOS, run it on Linux instead!" >&2
echo "(macOS' mktemp does not support the arguments we use.)" >&2
exit 1
;;
msys)
echo "This script does not work on MinGW, run it on Linux instead!" >&2
echo "(The Ant builder fails on MinGW due to /usr/share/java/junit4.jar not existing.)" >&2
exit 1
;;
esac

tmpdir="$(mktemp --directory)"
trap 'rm -rf -- "$tmpdir"' EXIT

from_ant="$(mktemp --tmpdir="$tmpdir" --suffix=.from-ant)"
from_gradle="$(mktemp --tmpdir="$tmpdir" --suffix=.from-gradle)"

if [ -e "./gradlew" ] ; then
# The Travis CI script expects us to use ./gradlew to test compatibility.
# The GitHub Actions script expects us to use ./gradlew to test compatibility.
echo "Found ./gradlew, using it instead of system's Gradle."
shopt -s expand_aliases
unalias -a
Expand Down

0 comments on commit 7cfbcbe

Please sign in to comment.