Skip to content

Commit

Permalink
Allow extensions to choose database type
Browse files Browse the repository at this point in the history
Specifically, add support for a `use_mysql` input that switches to using MySQL
instead of SQLite.

SEL-1067
  • Loading branch information
DanielWTQ committed Jul 18, 2024
1 parent 7edd01f commit 14b1903
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
on: [push]

jobs:
mediawiki-extension-action:
mediawiki-extension-action-sqlite:
runs-on: ubuntu-latest
name: Dummy extension test
name: Dummy extension test (sqlite)
steps:
# check out the repository
- name: Checkout
Expand All @@ -15,3 +15,19 @@ jobs:
php: 7.4
mwbranch: REL1_39
extension: DummyExtension

mediawiki-extension-action-mysql:
runs-on: ubuntu-latest
name: Dummy extension test (mysql)
steps:
# check out the repository
- name: Checkout
uses: actions/checkout@v3
- name: Test dummy extension
uses: ./ # Uses an action in the root directory
id: extension-test
with:
php: 7.4
mwbranch: REL1_39
extension: DummyExtension
use_mysql: true
10 changes: 8 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ inputs:
description: 'Path relative to the extension for a PHP file to load in settings'
required: false
default: ''
use_mysql:
description: Use MySQL instead of SQLite
required: false
default: false
runs:
using: 'composite'
steps:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php }}
extensions: mbstring, intl
extensions: ${{ USE_EXTENSIONS }}
tools: composer:2.1.14
env:
USE_EXTENSIONS: ${{ inputs.use_mysql && 'mbstring, intl, mysqli' || 'mbstring, intl' }}

- name: Add Composer cache
uses: actions/cache@v2
Expand All @@ -46,7 +52,7 @@ runs:
ref: ${{ inputs.mwbranch }}

- name: Install MediaWiki
run: bash $GITHUB_ACTION_PATH/install.sh ${{ inputs.extension }} ${{ inputs.type }} ${{ inputs.extra_file }}
run: bash $GITHUB_ACTION_PATH/install.sh ${{ inputs.extension }} ${{ inputs.type }} ${{ inputs.use_mysql }} ${{ inputs.extra_file }}
shell: bash

- uses: actions/checkout@v2
Expand Down
14 changes: 12 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ set -o pipefail

EXTENSION_NAME=$1
TYPE=$2
EXTRA_INCLUDE_FILE=$3
USE_MYSQL=$3
EXTRA_INCLUDE_FILE=$4

if [ "$USE_MYSQL" = "true" ]; then
DB_TYPE="mysql"
else
DB_TYPE="sqlite"
fi

echo $DB_TYPE
exit 1

# Install composer dependencies
cd mediawiki && composer install
php maintenance/install.php \
--dbtype sqlite \
--dbtype $DB_TYPE \
--dbuser root \
--dbname mw \
--dbpath $(pwd) \
Expand Down

0 comments on commit 14b1903

Please sign in to comment.