From 4f33dfb9b64e70b65119e9a9e2d53758fce4675d Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 18 Jul 2024 12:50:00 -0700 Subject: [PATCH] Allow extensions to choose database type Specifically, add support for a `use_mysql` input that switches to using MySQL instead of SQLite. SEL-1067 --- .github/workflows/main.yml | 20 ++++++++++++++++++-- action.yml | 10 ++++++++-- install.sh | 14 ++++++++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8a67ab..c5d874f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 diff --git a/action.yml b/action.yml index 4219a7f..5d38ec5 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,10 @@ 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: @@ -29,8 +33,10 @@ runs: uses: shivammathur/setup-php@v2 with: php-version: ${{ inputs.php }} - extensions: mbstring, intl + extensions: ${{ env.PHP_EXTENSIONS }} tools: composer:2.1.14 + env: + PHP_EXTENSIONS: ${{ inputs.use_mysql && 'mbstring, intl, mysqli' || 'mbstring, intl' }} - name: Add Composer cache uses: actions/cache@v2 @@ -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 diff --git a/install.sh b/install.sh index 71dd6a0..d69af99 100755 --- a/install.sh +++ b/install.sh @@ -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" + DB_SERVER="127.0.0.1" +else + DB_TYPE="sqlite" + DB_SERVER="localhost" +fi # Install composer dependencies cd mediawiki && composer install php maintenance/install.php \ - --dbtype sqlite \ + --dbtype $DB_TYPE \ + --dbserver $DB_SERVER \ --dbuser root \ --dbname mw \ --dbpath $(pwd) \