Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency caching for Solr in GitHub workflow #117

Merged
merged 7 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,47 @@ 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

- 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: downloads
key: solr-${{ 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

- 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
Expand Down
58 changes: 55 additions & 3 deletions bin/install_solr_docker.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,60 @@
#!/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
cd solr-$SOLR_VERSION
#
# 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
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"

mkdir -p "downloads"
cd downloads

# 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
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

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
cd ../solr-$SOLR_VERSION
./bin/solr start -force
./bin/solr create -c opus4 -force
cd server/solr/opus4/conf/
Expand Down