From 0e05308b14e0f59061b12eebed57477f25c30bff Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 20 Sep 2023 18:49:24 +0200 Subject: [PATCH] harden bash script to not wait until ci server times out when starting the jar fails --- .github/workflows/test-application.yaml | 27 ++++++++++++++++++++++--- CHANGELOG.md | 5 +++++ bin/jackrabbit.sh | 15 +++++++++++++- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 17db064d..7d7dcfbb 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -11,7 +11,7 @@ on: jobs: test: name: 'PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}' - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false @@ -25,11 +25,27 @@ jobs: - php-version: '7.4' - php-version: '8.0' - php-version: '8.1' + - php-version: '8.2' + - php-version: '8.3' steps: - name: Checkout project uses: actions/checkout@v2 + - name: Cache Jackrabbit + id: cache-jackrabbit + uses: actions/cache@v3 + with: + path: bin/jackrabbit-standalone-* + key: jackrabbit + + # default java installation not able to run newer versions of jackrabbit + - name: Install and configure Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: '8' + - name: Install and configure PHP uses: shivammathur/setup-php@v2 with: @@ -37,14 +53,19 @@ jobs: tools: 'composer:v2' - name: Install dependencies with Composer - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{ matrix.dependencies }} composer-options: --prefer-dist + - name: Get source version of phpcr-utils + run: | + rm -rf vendor/phpcr/phpcr-utils + composer update phpcr/phpcr-utils --prefer-source + - name: Start jackrabbit run: | - ./bin/jackrabbit.sh + ./bin/jackrabbit.sh - name: Execute test cases run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index a2434b6a..77fb4600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Changelog Version 1 ========= +1.4.5 +----- + +* Improved the bin/jackrabbit.sh script to detect when the .jar fails to be started. + 1.4.4 ----- diff --git a/bin/jackrabbit.sh b/bin/jackrabbit.sh index d59116ed..c4e5077f 100755 --- a/bin/jackrabbit.sh +++ b/bin/jackrabbit.sh @@ -9,16 +9,29 @@ JAR=jackrabbit-standalone-$VERSION.jar # download jackrabbit jar from archive, as the dist only contains the latest # stable versions if [ ! -f "$DIR/$JAR" ]; then - wget http://archive.apache.org/dist/jackrabbit/$VERSION/$JAR + wget -nv http://archive.apache.org/dist/jackrabbit/$VERSION/$JAR fi java -jar $DIR/$JAR& +pid=$! +echo "started prodcess $pid" echo "Waiting until Jackrabbit is ready on port 8080" while [[ -z `curl -s 'http://localhost:8080' ` ]] do echo -n "." sleep 2s + count=$(ps | grep "$pid[^[]" | wc -l) + if [[ $count -eq 0 ]] + then + echo "process $pid not found, waiting on it to determine exit status" + if wait $pid; then + echo "jackrabbit terminated with success status (this should not happen)" + else + echo "jackrabbit failed (returned $?)" + fi + exit 1 + fi done echo "Jackrabbit is up"