diff --git a/.github/scripts/test-no-error-reports.sh b/.github/scripts/test-no-error-reports.sh deleted file mode 100755 index 84c1e5d..0000000 --- a/.github/scripts/test-no-error-reports.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -RUNDIR="run" -CRASH="crash-reports" -SERVERLOG="server.log" - -if [[ -d $RUNDIR/$CRASH ]]; then - echo "Crash reports detected:" - cat $RUNDIR/$CRASH/crash*.txt - exit 1 -fi - -if grep --quiet "Fatal errors were detected" $SERVERLOG; then - echo "Fatal errors detected:" - cat server.log - exit 1 -fi - -if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" $SERVERLOG; then - echo "Server force stopped:" - cat server.log - exit 1 -fi - -if ! grep --quiet -Po '.+Done \(.+\)\! For help, type "help" or "\?"' $SERVERLOG; then - echo "Server didn't finish startup:" - cat server.log - exit 1 -fi - -echo "No crash reports detected" -exit 0 - diff --git a/.github/scripts/test_no_error_reports b/.github/scripts/test_no_error_reports new file mode 100755 index 0000000..1fcc739 --- /dev/null +++ b/.github/scripts/test_no_error_reports @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# bashsupport disable=BP5006 # Global environment variables +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 +crash_reports=("$RUNDIR/$CRASH/crash"*.txt) + +# if array not empty there are crash_reports +if [ "${#crash_reports[@]}" -gt 0 ]; then + # get the latest crash_report from array + 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 --fixed-strings 'Fatal errors were detected' "$SERVERLOG"; then + { + printf 'Fatal errors detected:\n' + cat server.log + } >&2 + exit 1 +fi + +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 --perl-regexp --only-matching '.+Done \(.+\)\! For help, type "help" or "\?"' "$SERVERLOG"; then + { + printf 'Server did not finish startup:' + cat server.log + } >&2 + exit 1 +fi + +printf 'No crash reports detected' +exit 0 diff --git a/.github/scripts/update-version.sh b/.github/scripts/update-version.sh deleted file mode 100755 index 228e637..0000000 --- a/.github/scripts/update-version.sh +++ /dev/null @@ -1,10 +0,0 @@ -if [ ! -z $(git diff --name-only HEAD HEAD~1 | grep build.gradle) ]; then - new_version="$(date +%s)" - sed --in-place "s!^//version:.*!//version: $new_version!g" build.gradle - git add build.gradle - git commit -m "[ci skip] update build script version to $new_version" - git push - echo "Updated buildscript version to $new_version"; -else - echo "Ignored buildscript version update: no changes detected" -fi diff --git a/.github/scripts/update_version b/.github/scripts/update_version new file mode 100755 index 0000000..3e5f752 --- /dev/null +++ b/.github/scripts/update_version @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +if ! git diff --name-only HEAD HEAD~1 | grep -qF 'build.gradle'; then + new_version="$(date +%s)" + sed --in-place "s!^//version:.*!//version: $new_version!g" build.gradle + git add build.gradle + git commit -m "[ci skip] update build script version to $new_version" + git push + printf 'Updated buildscript version to %s\n' "$new_version" +else + printf 'Ignored buildscript version update: no changes detected\n' +fi diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2a74327..56a1ad5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -41,5 +41,5 @@ jobs: - name: Test no errors reported during server run run: | - chmod +x .github/scripts/test-no-error-reports.sh - .github/scripts/test-no-error-reports.sh + chmod +x .github/scripts/test_no_error_reports + .github/scripts/test_no_error_reports diff --git a/.github/workflows/buildscript-maintenance.yml b/.github/workflows/buildscript-maintenance.yml index f5128e3..e973110 100644 --- a/.github/workflows/buildscript-maintenance.yml +++ b/.github/workflows/buildscript-maintenance.yml @@ -21,4 +21,4 @@ jobs: git config user.email "<>" - name: Ensure build script version is up to date - run: .github/scripts/update-version.sh + run: .github/scripts/update_version