Moodle qtype multianswerwiris CI #186
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 qtype multianswerwiris CI | |
| # Automatically triggered on push to main branch, on pull requests | |
| 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 * * *" | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| 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 3 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ["7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] | |
| moodle_branch: | |
| [ | |
| "MOODLE_39_STABLE", | |
| "MOODLE_401_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_401_STABLE" | |
| php: "7.3" | |
| - moodle_branch: "MOODLE_405_STABLE" | |
| php: "7.3" | |
| - moodle_branch: "MOODLE_500_STABLE" | |
| php: "7.3" | |
| - moodle_branch: "MOODLE_501_STABLE" | |
| php: "7.3" | |
| - 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: "MOODLE_39_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: "MOODLE_39_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_500_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_501_STABLE" | |
| php: "8.1" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.2" | |
| - moodle_branch: "MOODLE_401_STABLE" | |
| php: "8.2" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_401_STABLE" | |
| php: "8.3" | |
| - moodle_branch: "MOODLE_39_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_401_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "MOODLE_405_STABLE" | |
| php: "8.4" | |
| - moodle_branch: "main" | |
| include: | |
| # Only test master against latest PHP until we know which | |
| # versions are supported in the next release | |
| - moodle_branch: "main" | |
| php: "8.4" | |
| database: "pgsql" | |
| continue-on-error: ${{ matrix.branch == 'main' }} | |
| steps: | |
| - 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 filter | |
| - name: Add Wiris filter | |
| run: | | |
| moodle-plugin-ci add-plugin wiris/moodle-filter_wiris | |
| # 3.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 | |
| moodle-plugin-ci add-plugin --branch ${{ env.BRANCH_NAME }} wiris/moodle-qtype_shortanswerwiris | |
| - 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 | |
| moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_shortanswerwiris | |
| # 4. 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 }} | |
| # 5. Run PHPUnit tests. | |
| - name: PHPUnit tests | |
| if: ${{ always() }} | |
| run: moodle-plugin-ci phpunit ./plugin | |
| continue-on-error: true | |
| # 5.1 Run Moodle code validation. | |
| - name: Validating | |
| if: ${{ always() }} | |
| run: moodle-plugin-ci validate ./plugin | |
| continue-on-error: true | |
| # 6. Run Behat tests. | |
| - name: Behat features for ( ${{ matrix.moodle_branch }} on PHP ${{ matrix.php }} ) | |
| id: behat | |
| run: | | |
| case "${{ matrix.moodle_branch }}" in | |
| "MOODLE_401_STABLE"|"MOODLE_402_STABLE"|"MOODLE_403_STABLE"|"MOODLE_404_STABLE"|"MOODLE_405_STABLE"|"MOODLE_500_STABLE"|"MOODLE_501_STABLE"|"main") | |
| TAG="@qtype_multianswerwiris" | |
| ;; | |
| esac | |
| moodle-plugin-ci behat --tags=$TAG --profile ${{ matrix.browser }} --auto-rerun=2 --verbose -vvv | |
| # 6.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 | |