Skip to content

Commit

Permalink
harden bash script to not wait until ci server times out when startin…
Browse files Browse the repository at this point in the history
…g the jar fails
  • Loading branch information
dbu committed Sep 20, 2023
1 parent 58d6917 commit b1f6cea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,21 +30,32 @@ jobs:
- name: Checkout project
uses: actions/checkout@v2

# 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:
php-version: ${{ matrix.php-version }}
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
JACKRABBIT_VERSION=2.21.10 ./bin/jackrabbit.sh
- name: Execute test cases
run: |
Expand Down
15 changes: 14 additions & 1 deletion bin/jackrabbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit b1f6cea

Please sign in to comment.