Moodle Plugin CI Tests #2140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Moodle Plugin CI Tests | |
| # Automatically triggered on push to main branch, on pull requests, and daily at 6:00 UTC. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tags: | |
| description: 'Add additional test tags. It needs "&&" to concatenate and a leading @. Example: "&&@mtmoodle-x"' | |
| required: false | |
| default: "" | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - "**" | |
| schedule: | |
| - cron: "0 6 * * *" | |
| # Cancel simultaneous runs for the same branch or PR. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| behat-tests: | |
| runs-on: ubuntu-latest | |
| # Define required services. | |
| services: | |
| postgres: | |
| image: postgres:17 | |
| env: | |
| POSTGRES_USER: "postgres" | |
| POSTGRES_HOST_AUTH_METHOD: "trust" | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] | |
| moodle_branch: | |
| [ | |
| "MOODLE_39_STABLE", | |
| "MOODLE_311_STABLE", | |
| "MOODLE_400_STABLE", | |
| "MOODLE_401_STABLE", | |
| "MOODLE_402_STABLE", | |
| "MOODLE_403_STABLE", | |
| "MOODLE_404_STABLE", | |
| "MOODLE_405_STABLE", | |
| "MOODLE_500_STABLE", | |
| "MOODLE_501_STABLE", | |
| "main", | |
| ] | |
| database: [pgsql] | |
| browser: ["chrome", "firefox"] | |
| exclude: | |
| # Exclude Moodle+PHP incompatible versions | |
| # See: https://docs.moodle.org/dev/Moodle_and_PHP | |
| - moodle_branch: "MOODLE_402_STABLE" | |
| php: "7.4" | |
| - moodle_branch: "MOODLE_403_STABLE" | |
| php: "7.4" | |
| - moodle_branch: "MOODLE_404_STABLE" | |
| php: "7.4" | |
| - moodle_branch: "MOODLE_405_STABLE" | |
| php: "7.4" | |
| - moodle_branch: "MOODLE_500_STABLE" | |
| php: "7.4" | |
| - moodle_branch: "MOODLE_501_STABLE" | |
| php: "7.4" | |
| - moodle_branch: "main" | |
| php: "7.4" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.0" | |
| - moodle_branch: "MOODLE_404_STABLE" | |
| php: "8.0" | |
| - moodle_branch: "MOODLE_405_STABLE" | |
| php: "8.0" | |
| - moodle_branch: "MOODLE_500_STABLE" | |
| php: "8.0" | |
| - moodle_branch: "MOODLE_501_STABLE" | |
| php: "8.0" | |
| - moodle_branch: "main" | |
| php: "8.0" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_311_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_400_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_500_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_501_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "main" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.2" | |
| - moodle_branch: "MOODLE_311_STABLE" | |
| php: "8.2" | |
| - moodle_branch: "MOODLE_400_STABLE" | |
| php: "8.2" | |
| - moodle_branch: "MOODLE_401_STABLE" | |
| php: "8.2" | |
| - moodle_branch: "main" | |
| php: "8.2" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_311_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_400_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_401_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_402_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_403_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "main" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_311_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_400_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_401_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_402_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_403_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_404_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_405_STABLE" | |
| php: "8.4" | |
| steps: | |
| # 0. Clone the plugin repo to the "plugin" directory. | |
| - name: Check out repository code | |
| uses: actions/checkout@v4 | |
| with: | |
| path: plugin | |
| # 0.1 Detect branch name based on event type. | |
| - name: Set branch name | |
| id: get_branch | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV | |
| else | |
| echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV | |
| fi | |
| # 0.2 Log current matrix info. | |
| - name: Log info | |
| run: | | |
| echo "PHP: ${{ matrix.php }}" | |
| echo "Moodle: ${{ matrix.moodle_branch }}" | |
| echo "Browser: ${{ matrix.browser }}" | |
| echo "Branch: ${{ env.BRANCH_NAME }}" | |
| # 0.3 Cache Composer for faster builds. | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/.composer/cache | |
| ${{ github.workspace }}/.npm | |
| key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.moodle_branch }} | |
| restore-keys: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.moodle_branch }} | |
| # 1. Setup PHP for the current matrix. | |
| - name: Setup PHP ${{ matrix.php }} | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: ${{ matrix.extensions }} | |
| ini-values: max_input_vars=10000 | |
| coverage: none | |
| # 2. Install moodle-plugin-ci tool. | |
| - name: Initialise moodle-plugin-ci | |
| run: | | |
| composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 | |
| echo $(cd ci/bin; pwd) >> $GITHUB_PATH | |
| echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH | |
| sudo locale-gen en_AU.UTF-8 | |
| echo NVM_DIR=$NVM_DIR >> $GITHUB_ENV | |
| env: | |
| IGNORE_PATHS: classes/privacy,ignore,node_modules,integration,render | |
| COVERAGE: false | |
| CODECHECKER_IGNORE_PATHS: classes/privacy,ignore,node_modules,integration,render | |
| PHPUNIT_IGNORE_PATHS: classes/privacy,ignore,node_modules,integration,render | |
| # 3. Install Atto MathType plugin for specific Moodle branches. | |
| - name: Add MathType plugin for Atto | |
| if: ${{ contains(fromJson('[ "MOODLE_39_STABLE", "MOODLE_311_STABLE", "MOODLE_400_STABLE", "MOODLE_401_STABLE", "MOODLE_402_STABLE", "MOODLE_403_STABLE", "MOODLE_404_STABLE", "MOODLE_405_STABLE"]'), matrix.moodle_branch) }} | |
| id: install-plugin-atto | |
| continue-on-error: true | |
| run: | | |
| moodle-plugin-ci add-plugin --branch ${{ env.BRANCH_NAME }} wiris/moodle-atto_wiris | |
| - name: Add MathType plugin for Atto using the main branch | |
| if: ${{ contains(fromJson('["MOODLE_39_STABLE", "MOODLE_311_STABLE", "MOODLE_400_STABLE", "MOODLE_401_STABLE", "MOODLE_402_STABLE", "MOODLE_403_STABLE", "MOODLE_404_STABLE", "MOODLE_405_STABLE"]'), matrix.moodle_branch) && steps.install-plugin-atto.outcome != 'success' }} | |
| run: | | |
| moodle-plugin-ci add-plugin --branch main wiris/moodle-atto_wiris | |
| # 4. Install TinyMCE MathType plugin for modern Moodle branches. | |
| - name: Add MathType plugin for TinyMCE | |
| id: install-plugin-tiny | |
| if: ${{ !contains(fromJson('["MOODLE_39_STABLE", "MOODLE_311_STABLE", "MOODLE_400_STABLE"]'), matrix.moodle_branch) }} | |
| continue-on-error: true | |
| run: | | |
| moodle-plugin-ci add-plugin --branch ${{ env.BRANCH_NAME }} wiris/moodle-tiny_wiris | |
| - name: Add MathType plugin for TinyMCE using the main branch | |
| if: ${{ !contains(fromJson('["MOODLE_39_STABLE", "MOODLE_311_STABLE", "MOODLE_400_STABLE"]'), matrix.moodle_branch) && steps.install-plugin-tiny.outcome != 'success' }} | |
| run: | | |
| moodle-plugin-ci add-plugin --branch main wiris/moodle-tiny_wiris | |
| # 4.1 Install legacy TinyMCE plugin for old Moodle versions. | |
| - name: Add legacy MathType plugin for TinyMCE | |
| if: ${{ contains(fromJson('["MOODLE_39_STABLE", "MOODLE_311_STABLE", "MOODLE_400_STABLE"]'), matrix.moodle_branch) }} | |
| run: | | |
| moodle-plugin-ci add-plugin --branch main wiris/moodle-tinymce_tiny_mce_wiris | |
| # 5. Install Wiris Quizzes plugin. | |
| - name: Add Wiris Quizzes plugin | |
| id: install-plugin-quizzes | |
| if: ${{ always() }} | |
| continue-on-error: true | |
| run: | | |
| moodle-plugin-ci add-plugin --branch ${{ env.BRANCH_NAME }} wiris/moodle-qtype_wq | |
| - name: Add Wiris Quizzes plugin using the main branch | |
| if: ${{ steps.install-plugin-quizzes.outcome != 'success' }} | |
| run: | | |
| moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_wq | |
| # 6. Install plugin and configure DB. | |
| - name: Install moodle-plugin-ci | |
| run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 | |
| env: | |
| DB: ${{ matrix.database }} | |
| MOODLE_BRANCH: ${{ matrix.moodle_branch }} | |
| # 7. Run PHPUnit tests. | |
| - name: PHPUnit tests | |
| if: ${{ always() }} | |
| run: moodle-plugin-ci phpunit ./plugin | |
| continue-on-error: true | |
| # 7.1 Run Moodle code validation. | |
| - name: Validating | |
| if: ${{ always() }} | |
| run: moodle-plugin-ci validate ./plugin | |
| continue-on-error: true | |
| # 8. Run Behat tests. | |
| - name: Behat features for ( ${{ matrix.moodle_branch }} on PHP ${{ matrix.php }} ) | |
| id: behat | |
| run: | | |
| case "${{ matrix.moodle_branch }}" in | |
| "MOODLE_39_STABLE"|"MOODLE_311_STABLE") | |
| TAG="@3.x_filter${{ github.event.inputs.tags }}" | |
| ;; | |
| "MOODLE_400_STABLE") | |
| TAG="@4.0_filter${{ github.event.inputs.tags }}" | |
| ;; | |
| "MOODLE_401_STABLE"|"MOODLE_402_STABLE"|"MOODLE_403_STABLE"|"MOODLE_404_STABLE"|"MOODLE_405_STABLE") | |
| TAG="@4.x_filter${{ github.event.inputs.tags }}" | |
| ;; | |
| "MOODLE_500_STABLE"|"MOODLE_501_STABLE"|"main") | |
| TAG="@5.x_filter${{ github.event.inputs.tags }}" | |
| ;; | |
| *) | |
| TAG="@filter${{ github.event.inputs.tags }}" | |
| ;; | |
| esac | |
| moodle-plugin-ci behat --tags=$TAG --profile ${{ matrix.browser }} --auto-rerun=2 --verbose -vvv | |
| # 8.1 Upload Behat fail dumps when errors occur. | |
| - name: Upload Behat Faildump | |
| if: ${{ failure() && steps.behat.outcome == 'failure' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Behat Faildump (${{ matrix.php }}, ${{ matrix.moodle_branch }}, ${{ matrix.browser }}) | |
| path: ${{ github.workspace }}/moodledata/behat_dump | |
| retention-days: 1 | |
| if-no-files-found: ignore |