From f54d42a6f5197047241607a6b8483e77ba5522d2 Mon Sep 17 00:00:00 2001 From: Matthias Steffens Date: Wed, 1 Nov 2023 14:39:05 +0100 Subject: [PATCH 1/6] #114 Use the faster download server when downloading the most recent Solr release --- Vagrantfile | 4 ++-- bin/install_solr_docker.sh | 2 +- build.xml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index c2d5cae..e90ded7 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -42,9 +42,9 @@ mkdir -p "downloads" cd downloads SOLR_TAR="solr-$SOLR_VERSION.tgz" if test ! -f "$SOLR_TAR"; then - SOLR_URL="https://archive.apache.org/dist/solr/solr/$SOLR_VERSION/$SOLR_TAR" + SOLR_URL="https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/$SOLR_TAR?action=download" echo "Getting: $SOLR_URL" - wget -q --show-progress --progress=bar:force $SOLR_URL + wget -q --show-progress --progress=bar:force $SOLR_URL -O $SOLR_TAR fi tar xfz "$SOLR_TAR" -C /home/vagrant cd /home/vagrant/solr-$SOLR_VERSION diff --git a/bin/install_solr_docker.sh b/bin/install_solr_docker.sh index 99e08e2..c36ac9a 100644 --- a/bin/install_solr_docker.sh +++ b/bin/install_solr_docker.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash SOLR_VERSION="9.4.0" -wget -q "https://archive.apache.org/dist/solr/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz" -O - | tar -xz +wget -q "https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz?action=download" -O - | tar -xz cd solr-$SOLR_VERSION ./bin/solr start -force ./bin/solr create -c opus4 -force diff --git a/build.xml b/build.xml index 7f489c2..137f6d2 100644 --- a/build.xml +++ b/build.xml @@ -2,7 +2,7 @@ - + @@ -60,7 +60,7 @@ - From bb4a25d1027688e17b9a30b69d8b5f0ff83bf348 Mon Sep 17 00:00:00 2001 From: Matthias Steffens Date: Wed, 1 Nov 2023 17:13:36 +0100 Subject: [PATCH 2/6] #114 Cache Solr downloads when running GitHub workflows --- .github/workflows/php.yml | 23 ++++++++++++++----- bin/download_solr_docker.sh | 46 +++++++++++++++++++++++++++++++++++++ bin/install_solr_docker.sh | 46 ++++++++++++++++++++++++++++++++++--- 3 files changed, 106 insertions(+), 9 deletions(-) create mode 100755 bin/download_solr_docker.sh mode change 100644 => 100755 bin/install_solr_docker.sh diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 53597a1..c641475 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -16,17 +16,17 @@ jobs: strategy: matrix: - php-versions: ['8.1'] + versions: [{php: '8.1', solr: '9.4.0'}] - name: PHP ${{ matrix.php-versions }} Test + name: PHP ${{ matrix.versions.php }} Test steps: - uses: actions/checkout@v3 - - name: Setup PHP ${{ matrix.php-versions }} + - name: Setup PHP ${{ matrix.versions.php }} uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.versions.php }} - name: Check PHP Version run: php -v @@ -34,8 +34,19 @@ jobs: - name: Install Composer and Dependencies run: sudo apt-get update && curl -s http://getcomposer.org/installer | php && php composer.phar self-update && php composer.phar install - - name: Solr - run: sudo bash bin/install_solr_docker.sh + - name: Get Solr ${{ matrix.versions.solr }} from cache + id: cache-solr + uses: actions/cache@v3 + with: + path: solr-${{ matrix.versions.solr }}.tgz + key: solr-${{ matrix.versions.solr }}.tgz + + - name: Download Solr ${{ matrix.versions.solr }} + if: steps.cache-solr.outputs.cache-hit != 'true' + run: sudo bash bin/download_solr_docker.sh --version ${{ matrix.versions.solr }} + + - name: Install Solr ${{ matrix.versions.solr }} + run: sudo bash bin/install_solr_docker.sh --version ${{ matrix.versions.solr }} - name: Start MySQL run: sudo systemctl start mysql.service diff --git a/bin/download_solr_docker.sh b/bin/download_solr_docker.sh new file mode 100755 index 0000000..30e1d5d --- /dev/null +++ b/bin/download_solr_docker.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# +# Script to download Solr. By default, version 9.4.0 will be downloaded. +# Another Solr version can be specified using the `--version` option. + +# Define variables and their default values +version="9.4.0" + +# Parse command line options +while [ $# -gt 0 ]; do + if [[ $1 == "--"* ]]; then # only deal with long options + if [[ -n "$2" && $2 != "-"* ]]; then # ignore options without a value + # Create variable name from option name + v="${1/--/}" # uses parameter expansion removing '--' + + # Read option value into variable + declare "$v"="$2" + + # Process next option + shift + fi + fi + shift +done + +# Check --version input +if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Unrecognized version number: $version" + echo "The --version option requires a 3-digit version number, e.g.: 9.4.0" + exit 1 +fi + +SOLR_VERSION="$version" +SOLR_TAR="solr-$SOLR_VERSION.tgz" + +# Define Solr download URL (which differs for versions >=9.0.0) +if [[ "$version" =~ ^[1-8]\.[0-9]+\.[0-9]+$ ]]; then + SOLR_URL="https://archive.apache.org/dist/lucene/solr/$SOLR_VERSION/$SOLR_TAR" +elif [[ "$version" =~ ^(9|[1-9][0-9]+)\.[0-9]+\.[0-9]+$ ]]; then + SOLR_URL="https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/$SOLR_TAR?action=download" +fi + +# Download Solr version +echo "Getting: $SOLR_URL" +wget -q --show-progress --progress=bar:force $SOLR_URL -O $SOLR_TAR diff --git a/bin/install_solr_docker.sh b/bin/install_solr_docker.sh old mode 100644 new mode 100755 index c36ac9a..3ab873f --- a/bin/install_solr_docker.sh +++ b/bin/install_solr_docker.sh @@ -1,7 +1,47 @@ #!/usr/bin/env bash -SOLR_VERSION="9.4.0" -wget -q "https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz?action=download" -O - | tar -xz +# +# Script to install Solr. By default, version 9.4.0 will be assumed. +# Another Solr version can be specified using the `--version` option. + +# Define variables and their default values +version="9.4.0" + +# Parse command line options +while [ $# -gt 0 ]; do + if [[ $1 == "--"* ]]; then # only deal with long options + if [[ -n "$2" && $2 != "-"* ]]; then # ignore options without a value + # Create variable name from option name + v="${1/--/}" # uses parameter expansion removing '--' + + # Read option value into variable + declare "$v"="$2" + + # Process next option + shift + fi + fi + shift +done + +# Check --version input +if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Unrecognized version number: $version" + echo "The --version option requires a 3-digit version number, e.g.: 9.4.0" + exit 1 +fi + +SOLR_VERSION="$version" +SOLR_TAR="solr-$SOLR_VERSION.tgz" + +# Extract Solr archive +if test ! -f "$SOLR_TAR"; then + echo "Solr archive not found: $SOLR_TAR" + exit 1 +fi +tar -xfz "$SOLR_TAR" + +# Configure & start Solr cd solr-$SOLR_VERSION ./bin/solr start -force ./bin/solr create -c opus4 -force @@ -11,4 +51,4 @@ ln -s ../../../../../conf/schema.xml schema.xml ln -s ../../../../../conf/solrconfig.xml solrconfig.xml cd ../../../../ ./bin/solr restart -force -cd .. \ No newline at end of file +cd .. From 17b36fda6a7e9de61cc2fb6d5b0286dc764dd6ed Mon Sep 17 00:00:00 2001 From: Matthias Steffens Date: Wed, 1 Nov 2023 17:29:28 +0100 Subject: [PATCH 3/6] #114 Use title case for all GitHub workflow action names --- .github/workflows/php.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c641475..2bf0887 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -34,7 +34,7 @@ jobs: - name: Install Composer and Dependencies run: sudo apt-get update && curl -s http://getcomposer.org/installer | php && php composer.phar self-update && php composer.phar install - - name: Get Solr ${{ matrix.versions.solr }} from cache + - name: Get Solr ${{ matrix.versions.solr }} from Cache id: cache-solr uses: actions/cache@v3 with: @@ -51,16 +51,16 @@ jobs: - name: Start MySQL run: sudo systemctl start mysql.service - - name: Prepare workspace + - name: Prepare Workspace run: ant prepare-workspace - - name: Prepare search config + - name: Prepare Search Config run: ant prepare-config - - name: Prepare database + - name: Prepare Database run: bash vendor/bin/opus4db --adminpwd root --userpwd root --sqlpwd root - - name: Basic PHP file check + - name: Basic PHP File Check run: ant lint - name: Tests From 9db52ac1ca64abff5cc24d0365ca675c2ab35c79 Mon Sep 17 00:00:00 2001 From: Matthias Steffens Date: Thu, 2 Nov 2023 15:10:20 +0100 Subject: [PATCH 4/6] #114 Moves the Solr download functionality back into "install_solr_docker.sh" which now only downloads the Solr archive for the given version if it doesn't exist locally --- bin/download_solr_docker.sh | 46 ------------------------------------- bin/install_solr_docker.sh | 23 ++++++++++++++----- 2 files changed, 17 insertions(+), 52 deletions(-) delete mode 100755 bin/download_solr_docker.sh diff --git a/bin/download_solr_docker.sh b/bin/download_solr_docker.sh deleted file mode 100755 index 30e1d5d..0000000 --- a/bin/download_solr_docker.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -# -# Script to download Solr. By default, version 9.4.0 will be downloaded. -# Another Solr version can be specified using the `--version` option. - -# Define variables and their default values -version="9.4.0" - -# Parse command line options -while [ $# -gt 0 ]; do - if [[ $1 == "--"* ]]; then # only deal with long options - if [[ -n "$2" && $2 != "-"* ]]; then # ignore options without a value - # Create variable name from option name - v="${1/--/}" # uses parameter expansion removing '--' - - # Read option value into variable - declare "$v"="$2" - - # Process next option - shift - fi - fi - shift -done - -# Check --version input -if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Unrecognized version number: $version" - echo "The --version option requires a 3-digit version number, e.g.: 9.4.0" - exit 1 -fi - -SOLR_VERSION="$version" -SOLR_TAR="solr-$SOLR_VERSION.tgz" - -# Define Solr download URL (which differs for versions >=9.0.0) -if [[ "$version" =~ ^[1-8]\.[0-9]+\.[0-9]+$ ]]; then - SOLR_URL="https://archive.apache.org/dist/lucene/solr/$SOLR_VERSION/$SOLR_TAR" -elif [[ "$version" =~ ^(9|[1-9][0-9]+)\.[0-9]+\.[0-9]+$ ]]; then - SOLR_URL="https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/$SOLR_TAR?action=download" -fi - -# Download Solr version -echo "Getting: $SOLR_URL" -wget -q --show-progress --progress=bar:force $SOLR_URL -O $SOLR_TAR diff --git a/bin/install_solr_docker.sh b/bin/install_solr_docker.sh index 3ab873f..2dfde27 100755 --- a/bin/install_solr_docker.sh +++ b/bin/install_solr_docker.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# Script to install Solr. By default, version 9.4.0 will be assumed. +# Script to install Solr. By default, version 9.4.0 will be installed. # Another Solr version can be specified using the `--version` option. # Define variables and their default values @@ -34,15 +34,26 @@ fi SOLR_VERSION="$version" SOLR_TAR="solr-$SOLR_VERSION.tgz" -# Extract Solr archive +mkdir -p "downloads" +cd downloads + +# Get & extract Solr archive if test ! -f "$SOLR_TAR"; then - echo "Solr archive not found: $SOLR_TAR" - exit 1 + # the Solr download URL differs for versions >=9.0.0 + if [[ "$version" =~ ^[1-8]\.[0-9]+\.[0-9]+$ ]]; then + SOLR_URL="https://archive.apache.org/dist/lucene/solr/$SOLR_VERSION/$SOLR_TAR" + elif [[ "$version" =~ ^(9|[1-9][0-9]+)\.[0-9]+\.[0-9]+$ ]]; then + SOLR_URL="https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/$SOLR_TAR?action=download" + fi + + # Download Solr version + echo "Getting: $SOLR_URL" + wget -q --show-progress --progress=bar:force $SOLR_URL -O $SOLR_TAR fi -tar -xfz "$SOLR_TAR" +tar xfz "$SOLR_TAR" -C .. # Configure & start Solr -cd solr-$SOLR_VERSION +cd ../solr-$SOLR_VERSION ./bin/solr start -force ./bin/solr create -c opus4 -force cd server/solr/opus4/conf/ From 3952fcfd2ddb98e883d1a41099abf02b6ce03f48 Mon Sep 17 00:00:00 2001 From: Matthias Steffens Date: Thu, 2 Nov 2023 15:17:06 +0100 Subject: [PATCH 5/6] #114 The GitHub workflow now caches downloaded Solr versions within a "downloads" folder --- .github/workflows/php.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 2bf0887..9e9671c 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -38,12 +38,8 @@ jobs: id: cache-solr uses: actions/cache@v3 with: - path: solr-${{ matrix.versions.solr }}.tgz - key: solr-${{ matrix.versions.solr }}.tgz - - - name: Download Solr ${{ matrix.versions.solr }} - if: steps.cache-solr.outputs.cache-hit != 'true' - run: sudo bash bin/download_solr_docker.sh --version ${{ matrix.versions.solr }} + path: downloads + key: solr-${{ matrix.versions.solr }} - name: Install Solr ${{ matrix.versions.solr }} run: sudo bash bin/install_solr_docker.sh --version ${{ matrix.versions.solr }} From 789a7e66e1668cf1336c8957e90c7e5f54d222fe Mon Sep 17 00:00:00 2001 From: Matthias Steffens Date: Thu, 2 Nov 2023 15:29:15 +0100 Subject: [PATCH 6/6] #114 Minor changes to code comments --- bin/install_solr_docker.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/install_solr_docker.sh b/bin/install_solr_docker.sh index 2dfde27..b0e1094 100755 --- a/bin/install_solr_docker.sh +++ b/bin/install_solr_docker.sh @@ -37,7 +37,7 @@ SOLR_TAR="solr-$SOLR_VERSION.tgz" mkdir -p "downloads" cd downloads -# Get & extract Solr archive +# Download Solr version if test ! -f "$SOLR_TAR"; then # the Solr download URL differs for versions >=9.0.0 if [[ "$version" =~ ^[1-8]\.[0-9]+\.[0-9]+$ ]]; then @@ -46,10 +46,11 @@ if test ! -f "$SOLR_TAR"; then SOLR_URL="https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/$SOLR_TAR?action=download" fi - # Download Solr version echo "Getting: $SOLR_URL" wget -q --show-progress --progress=bar:force $SOLR_URL -O $SOLR_TAR fi + +# Extract Solr archive tar xfz "$SOLR_TAR" -C .. # Configure & start Solr