diff options
Diffstat (limited to '.github')
-rwxr-xr-x[-rw-r--r--] | .github/scripts/test-no-error-reports.sh | 46 | ||||
-rw-r--r-- | .github/workflows/build-and-test.yml | 10 |
2 files changed, 37 insertions, 19 deletions
diff --git a/.github/scripts/test-no-error-reports.sh b/.github/scripts/test-no-error-reports.sh index e3876606d5..cfce0261a5 100644..100755 --- a/.github/scripts/test-no-error-reports.sh +++ b/.github/scripts/test-no-error-reports.sh @@ -1,27 +1,45 @@ -if [[ -d "run/crash-reports" ]]; then - echo "Crash reports detected:" - cat $directory/* +#!/usr/bin/env bash + +RUNDIR="run" +CRASH="crash-reports" +SERVERLOG="server.log" + +# enable nullglob to get 0 results when no match rather than the pattern +shopt -s nullglob +# store matches in array (don't forget to double-quote variables expansion +crash_reports=( "$RUNDIR/$CRASH/crash"*.txt ) +if [ "${#crash_reports[@]}" -gt 0 ]; then + latest_crash_report="${crash_reports[-1]}" + { + printf 'Latest crash report detected %s:\n' "${latest_crash_report##*/}" + cat "$latest_crash_report" + } >&2 exit 1 fi -if grep --quiet "Fatal errors were detected" server.log; then - echo "Fatal errors detected:" - cat server.log +if grep --quiet --fixed-strings 'Fatal errors were detected' "$SERVERLOG"; then + { + printf 'Fatal errors detected:' + cat server.log + } >&2 exit 1 fi -if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" server.log; then - echo "Server force stopped:" - cat server.log +if grep --quiet --fixed-strings 'The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED' "$SERVERLOG"; then + { + printf 'Server force stopped:' + cat server.log + } >&2 exit 1 fi -if grep --quiet 'Done .+ For help, type "help" or "?"' server.log; then - echo "Server didn't finish startup:" - cat server.log +if ! grep --quiet -Po '.+Done \(.+\)\! For help, type "help" or "\?"' "$SERVERLOG"; then + { + printf 'Server did not finish startup:' + cat server.log + } >&2 exit 1 fi -echo "No crash reports detected" +printf 'No crash reports detected' exit 0 - diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 08df9fe89f..2a74327ad6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -14,16 +14,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - with: + with: fetch-depth: 0 - + - name: Set up JDK 8 uses: actions/setup-java@v2 with: java-version: '8' distribution: 'adopt' cache: gradle - + - name: Grant execute permission for gradlew run: chmod +x gradlew @@ -36,8 +36,8 @@ jobs: - name: Run server for 1.5 minutes run: | mkdir run - echo "eula=true" > run/eula.txt - timeout 90 ./gradlew runServer | tee --append server.log || true + echo "eula=true" > run/eula.txt + timeout 90 ./gradlew runServer 2>&1 | tee -a server.log || true - name: Test no errors reported during server run run: | |