├── .github └── workflows │ ├── auto-author-assign.yml │ └── ci.yml ├── .gitignore ├── .htaccess ├── README.md ├── check_upgrade_savepoints ├── check_upgrade_savepoints.php ├── check_upgrade_savepoints.sh └── savepoints2checkstyle.php ├── compare_databases ├── compare_databases.php ├── compare_databases.sh └── run_conditionally.sh ├── composer.json ├── define_excluded └── define_excluded.sh ├── detect_conflicts └── detect_conflicts.sh ├── diff_extract_changes └── diff_extract_changes.php ├── generate_component_ant_files └── generate_component_ant_files.php ├── git_garbage_collector └── git_garbage_collector.sh ├── git_sync_two_branches ├── git_sync_two_branches.sh └── lib.sh ├── groovyscripts ├── add_notification_webhook_to_all_jobs.groovy └── remove_post_action_from_all_jobs.groovy ├── grunt_process └── grunt_process.sh ├── illegal_whitespace └── illegal_whitespace.sh ├── index.html ├── jenkins_cli └── jenkins-cli.jar ├── jira.sh ├── lang └── en │ └── local_ci.php ├── list_changed_files └── list_changed_files.sh ├── list_valid_components ├── list_valid_components.php └── list_valid_components.sh ├── mustache_lint ├── js_helper.php ├── mustache_lint.php ├── mustache_lint.sh ├── running_validator.txt └── simple_core_component_mustache_loader.php ├── package-lock.json ├── package.json ├── php_lint └── php_lint.sh ├── phplib └── clilib.php ├── prepare_composer_stuff └── prepare_composer_stuff.sh ├── prepare_npm_stuff └── prepare_npm_stuff.sh ├── project_size_report └── project_size_report.sh ├── rebase_security └── rebase_security.sh ├── remote_branch_checker ├── checkstyle_converter.php ├── lib.php ├── remote_branch_checker.sh ├── remote_branch_reporter.php └── xslt │ ├── checkstyle2smurf.xsl │ └── gargamel.xsl ├── run_phpunittests ├── config.php.template └── run_phpunittests.sh ├── tests ├── check_upgrade_savepoints.bats ├── checkstyle_manipulations.bats ├── compare_databases.bats ├── continuous_manage_queues_validation.bats ├── define_excluded.bats ├── detect_conflicts.bats ├── diff_extract_changes.bats ├── fixtures │ ├── 31-merge-conflict.patch │ ├── 31-mustache_lint-full-html-body.patch │ ├── 31-mustache_lint-html-validator-fail.patch │ ├── 31-mustache_lint-invalid-json.patch │ ├── 31-mustache_lint-js_test.patch │ ├── 31-mustache_lint-js_token_test.patch │ ├── 31-mustache_lint-mustache-syntax-error.patch │ ├── 31-mustache_lint-no-content.patch │ ├── 31-mustache_lint-no-example.patch │ ├── 31-mustache_lint-ok.patch │ ├── 31-mustache_lint-partials-loaded.patch │ ├── 31-mustache_lint-quote_and_uniq.patch │ ├── 31-mustache_lint-theme_loading.patch │ ├── 31-thirdparty-edgecase.patch │ ├── 31-thirdparty-error.patch │ ├── 31-thirdparty-ok.patch │ ├── 31-valid_components.txt │ ├── 31-whitespace-error.patch │ ├── 31-whitespace-upgradenotes.patch │ ├── 311-upgrade_external_backup-all-ok-plugin.patch │ ├── 311-upgrade_external_backup-all-ok-root.patch │ ├── 311-upgrade_external_backup-all-wrong.patch │ ├── 311-upgrade_external_backup-backup-ok.patch │ ├── 311-upgrade_external_backup-external-ok.patch │ ├── 311-upgrade_external_backup-no-changes.patch │ ├── 35-thirdparty-lib-added.patch │ ├── 39-grunt-js-unbuilt.patch │ ├── 39-grunt-scss-unbuilt.patch │ ├── 39-mustache_lint_plugins-ignores.patch │ ├── 39-mustache_lint_plugins-templates.patch │ ├── 402-mustache_lint-str.patch │ ├── 402-php_lint-bad.patch │ ├── 402-php_lint-ok.patch │ ├── 402-php_lint-vendor.patch │ ├── check_upgrade_savepoints │ │ ├── blank_upgrade_file.patch │ │ ├── if_without_savepoint.patch │ │ ├── multiple_return.patch │ │ ├── no_return_statement.patch │ │ ├── out_of_order.patch │ │ ├── repeated_savepoint.patch │ │ ├── returning_bool.patch │ │ ├── too_high_savepoint.patch │ │ └── wrong_savepoint_version.patch │ ├── checkstyle │ │ ├── commits-info.txt │ │ ├── commits-info.xml │ │ ├── commits.txt │ │ ├── commits.xml │ │ ├── gherkinlint_err.txt │ │ ├── gherkinlint_err.xml │ │ ├── gherkinlint_ok.txt │ │ ├── gherkinlint_ok.xml │ │ ├── grunt-build-failed.txt │ │ ├── grunt-build-failed.xml │ │ ├── grunt-errors.txt │ │ ├── grunt.txt │ │ ├── grunt.xml │ │ ├── mustachelint.txt │ │ ├── mustachelint.xml │ │ ├── phplint.txt │ │ ├── phplint.xml │ │ ├── savepoints.txt │ │ ├── savepoints.xml │ │ ├── shifter.xml │ │ ├── thirdparty.txt │ │ └── thirdparty.xml │ ├── compare_databases_wrong.patch │ ├── define_excluded │ │ ├── format-excluded-expected.txt │ │ ├── format-excluded_comma-expected.txt │ │ ├── format-excluded_comma_wildchars-expected.txt │ │ ├── format-excluded_grep-expected.txt │ │ ├── format-excluded_list-expected.txt │ │ └── format-excluded_list_wildchars-expected.txt │ ├── diff_extract_changes │ │ ├── diff_extract_changes-edge-expected.txt │ │ ├── diff_extract_changes-edge-expected.xml │ │ ├── diff_extract_changes-edge-input.patch │ │ ├── diff_extract_changes-normal-expected.txt │ │ ├── diff_extract_changes-normal-expected.xml │ │ └── diff_extract_changes-normal-input.patch │ ├── remote_branch_checker │ │ ├── local_ci_fixture_all_passing.xml │ │ ├── local_ci_fixture_bad_amos_command.regex │ │ ├── local_ci_fixture_gherkin_lint.regex │ │ ├── local_ci_fixture_good_amos_commit.regex │ │ ├── local_ci_fixture_grunt_build_failed.regex │ │ ├── local_ci_fixture_manyproblems_38.regex │ │ ├── local_ci_fixture_mustache_lint.regex │ │ ├── local_ci_fixture_mustache_lint_js.regex │ │ ├── local_ci_fixture_noncode_update.xml │ │ ├── local_ci_fixture_oldbranch_38.regex │ │ ├── local_ci_fixture_phpcs_aware_components.regex │ │ ├── local_ci_fixture_stylelint.regex │ │ ├── local_ci_fixture_thirdparty_css.regex │ │ ├── local_ci_fixture_upgrade_external_backup.regex │ │ ├── local_ci_fixture_upgrade_external_backup_skipped_for_plugins.regex │ │ ├── local_ci_fixture_upgrade_txt_for_404.regex │ │ └── local_ci_fixture_upgrade_txt_for_405.regex │ ├── remote_branch_reporter │ │ ├── MDL-54987 │ │ │ ├── commits.xml │ │ │ ├── cs.xml │ │ │ ├── csslint.out │ │ │ ├── docs.xml │ │ │ ├── errors.txt │ │ │ ├── errors.xml │ │ │ ├── eslint.xml │ │ │ ├── grunt.xml │ │ │ ├── patchset.xml │ │ │ ├── phplint.xml │ │ │ ├── savepoints.xml │ │ │ ├── shifter.xml │ │ │ ├── smurf.html │ │ │ ├── smurf.xml │ │ │ ├── stylelint.xml │ │ │ └── thirdparty.xml │ │ ├── MDL-55322 │ │ │ ├── commits.xml │ │ │ ├── cs.xml │ │ │ ├── csslint.out │ │ │ ├── docs.xml │ │ │ ├── eslint.xml │ │ │ ├── grunt.xml │ │ │ ├── patchset.xml │ │ │ ├── phplint.xml │ │ │ ├── savepoints.xml │ │ │ ├── shifter.xml │ │ │ ├── smurf.html │ │ │ ├── smurf.xml │ │ │ ├── stylelint.xml │ │ │ └── thirdparty.xml │ │ └── README.md │ ├── verify_commit_messages │ │ ├── amos-bad-syntax.patch │ │ ├── amos-good-commands.patch │ │ ├── amos-incomplete.patch │ │ ├── amos-no-modified-files.patch │ │ ├── backslash-ended-lines.patch │ │ ├── includes-parent-in-message.patch │ │ ├── no-code-area.patch │ │ ├── no-colon.patch │ │ ├── no-issue-id.patch │ │ ├── ok.patch │ │ ├── too-long-body.patch │ │ ├── too-long.patch │ │ └── warning-elsewhere.patch │ ├── verify_phpunit_xml │ │ ├── add_uncovered_test.patch │ │ └── multiple_classes_in_file.patch │ └── versions_check_set │ │ ├── extra_version_digit.patch │ │ ├── invalid_component.patch │ │ ├── invalid_date.patch │ │ ├── main_version_missing.patch │ │ ├── no_moodle_internal.patch │ │ ├── no_version_defined.patch │ │ ├── short_array_syntax.patch │ │ ├── short_version.patch │ │ └── version_too_far_in_future.patch ├── git_sync_two_branches.bats ├── grunt_process.bats ├── illegal_whitespace.bats ├── libs │ ├── bats-assert │ │ ├── load.bash │ │ └── src │ │ │ └── assert.bash │ ├── bats-support │ │ ├── load.bash │ │ └── src │ │ │ ├── error.bash │ │ │ └── output.bash │ └── shared_setup.bash ├── list_valid_components.bats ├── mustache_lint.bats ├── mustache_lint_plugins.bats ├── php_lint.bats ├── prepare_npm_stuff.bats ├── remote_branch_checker.bats ├── remote_branch_reporter.bats ├── setup.bats ├── thirdparty_check.bats ├── travis-branch-checker.bats ├── upgrade_external_backup.bats ├── verifications.bats ├── verify_commit_messages.bats ├── verify_phpunit_xml.bats └── versions_check_set.bats ├── thirdparty_check ├── thirdparty_check.sh └── thirdpartylocations.php ├── tracker_automations ├── bulk_precheck_issues │ ├── bulk_precheck_issues.sh │ ├── criteria │ │ ├── awaiting_integration │ │ │ ├── override-defaults.sh │ │ │ ├── postissue.sh │ │ │ └── query.sh │ │ ├── awaiting_peer_review │ │ │ ├── postissue.sh │ │ │ └── query.sh │ │ └── developer_request │ │ │ ├── postissue.sh │ │ │ └── query.sh │ └── util.sh ├── bulk_prelaunch_jobs │ ├── bulk_prelaunch_jobs.sh │ └── criteria │ │ ├── awaiting_component_lead_review │ │ ├── jobs.sh │ │ ├── postissue.sh │ │ └── query.sh │ │ ├── awaiting_integration │ │ ├── jobs.sh │ │ ├── postissue.sh │ │ └── query.sh │ │ ├── list_of_mdls │ │ ├── jobs.sh │ │ ├── postissue.sh │ │ └── query.sh │ │ ├── list_of_mdls_sdev │ │ ├── jobs.sh │ │ ├── postissue.sh │ │ └── query.sh │ │ └── multi_database │ │ ├── jobs.sh │ │ ├── postissue.sh │ │ └── query.sh ├── check_marked_as_integrated │ ├── check_marked_as_integrated.sh │ └── util.sh ├── close_tested_issues │ └── close_tested_issues.sh ├── component_leads_integration_mover │ ├── component_leads_integration_mover.sh │ └── lib.sh ├── continuous_manage_queues │ ├── continuous_manage_queues.sh │ └── lib.sh ├── count_delayed_last_cycle │ └── count_delayed_last_cycle.sh ├── count_reopened_last_cycle │ └── count_reopened_last_cycle.sh ├── count_test_failed_last_cycle │ └── count_test_failed_last_cycle.sh ├── delay_awaiting_issues │ └── delay_awaiting_issues.sh ├── manage_waiting_for_feedback │ └── manage_waiting_for_feedback.sh ├── move_to_current_integration │ └── move_to_current_integration.sh ├── mv_reopened_out_from_current │ └── mv_reopened_out_from_current.sh ├── normal_manage_queues │ ├── lib.sh │ └── normal_manage_queues.sh ├── progress_automated_tested │ └── progress_automated_tested.sh ├── remove_ci_label_from_waiting_integration │ └── remove_ci_label_from_waiting_integration.sh ├── remove_ci_label_from_wip │ └── remove_ci_label_from_wip.sh ├── send_rebase_message │ └── send_rebase_message.sh ├── set_integration_priority_to_one │ └── set_integration_priority_to_one.sh └── set_integration_priority_to_zero │ └── set_integration_priority_to_zero.sh ├── tracker_content_gadget ├── clr_candidate_picker.html ├── clr_candidate_picker_split.html ├── personal_candidate_picker.html └── personal_current_picker.html ├── travis └── check_branch_status.php ├── upgrade_external_backup_check └── upgrade_external_backup_check.sh ├── verify_commit_messages ├── amoslib.php ├── check_amos.php ├── commits2checkstyle.php └── verify_commit_messages.sh ├── verify_phpunit_xml ├── create_phpunit_xml.php └── verify_phpunit_xml.sh ├── version.php └── versions_check_set └── versions_check_set.sh /.github/workflows/auto-author-assign.yml: -------------------------------------------------------------------------------- 1 | name: Auto Author Assign 2 | 3 | on: 4 | pull_request_target: 5 | types: [ opened, reopened ] 6 | 7 | permissions: 8 | pull-requests: write 9 | 10 | jobs: 11 | assign-author: 12 | name: Auto assign PR 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: toshimaru/auto-author-assign@v2.1.0 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file specifies intentionally untracked files that all Moodle git 2 | # repositories should ignore. It is recommended not to modify this file in your 3 | # local clone. Instead, use .git/info/exclude and add new records there as 4 | # needed. 5 | # 6 | # Example: if you deploy a contributed plugin mod/foobar into your site, put 7 | # the following line into .git/info/exclude file in your Moodle clone: 8 | # /mod/foobar/ 9 | # 10 | # See gitignore(5) man page for more details 11 | # 12 | *~ 13 | *.swp 14 | /tags 15 | /TAGS 16 | /cscope.* 17 | /.patches/ 18 | /.idea/ 19 | /nbproject/ 20 | CVS 21 | .DS_Store 22 | /.settings/ 23 | /.project 24 | /.buildpath 25 | /.cache 26 | phpunit.xml 27 | # Ignore composer bits. 28 | composer.phar 29 | composer.lock 30 | vendor/ 31 | node_modules/ 32 | -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | Deny from all 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CI local plugin 2 | 3 | [![Build Status](https://github.com/moodlehq/moodle-local_ci/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/moodlehq/moodle-local_ci/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/moodlehq/moodle-local_ci/graph/badge.svg?token=0u0rBbFrXj)](https://codecov.io/gh/moodlehq/moodle-local_ci) 4 | 5 | This local_ci plugin contains all the scripts needed 6 | by Moodle CI servers to automate checks while 7 | integration happens. 8 | 9 | ## Dependencies 10 | 11 | + Some checks require a MySQL, Moodle main-based site to be up and running. 12 | + Some checks require a PHP engine to run (other are pure shell scripts). 13 | + Some checks require the installation of 3rd part tools (phpunit...). 14 | + Some checks require the presence of local_moodlecheck local plugin. 15 | + To get all other dependencies installed, ensure that both composer and npm are run regularly. 16 | + You can run them standalone or also with the ease and functionalities coming with different tools like: 17 | - Jenkins: http://jenkins-php.org 18 | - GitHub workflows: https://docs.github.com/en/actions/language-and-framework-guides/using-php-with-github-actions 19 | - Travis: https://docs.travis-ci.com/user/languages/php/ 20 | - Docker: https://github.com/moodlehq/moodle-php-apache 21 | - ... 22 | 23 | ## TODO 24 | 25 | + Complete the documentation. 26 | + Document each check properly. 27 | 28 | ## Self-versions 29 | 30 | + 20121112 - Eloy - Initial version of this README.md. 31 | + 20190722 - Eloy - Replace bogus link by some general information alternatives to use the scripts. 32 | -------------------------------------------------------------------------------- /check_upgrade_savepoints/check_upgrade_savepoints.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # $WORKSPACE 3 | # $phpcmd: Path to the PHP CLI executable 4 | # $gitdir: Directory containing git repo 5 | # $gitbranch: Branch we are going to check 6 | 7 | # Let's go strict (exit on error) 8 | set -e 9 | 10 | # Verify everything is set 11 | required="WORKSPACE phpcmd gitdir gitbranch" 12 | for var in $required; do 13 | if [ -z "${!var}" ]; then 14 | echo "Error: ${var} environment variable is not defined. See the script comments." 15 | exit 1 16 | fi 17 | done 18 | 19 | # file where results will be sent 20 | resultfile=$WORKSPACE/check_upgrade_savepoints_${gitbranch}.txt 21 | echo -n > "$resultfile" 22 | 23 | # calculate some variables 24 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 25 | 26 | # checkout pristine copy of the configure branch 27 | cd $gitdir && git reset --hard $gitbranch 28 | 29 | # copy the checker to the gitdir 30 | cp $mydir/check_upgrade_savepoints.php $gitdir/ 31 | 32 | # Run the savpoints checker utility, saving results to file 33 | ${phpcmd} $gitdir/check_upgrade_savepoints.php > "$resultfile" 34 | 35 | # remove the checker from gitdir 36 | rm -fr $gitdir/check_upgrade_savepoints.php 37 | 38 | # Look for ERROR or WARN in the resultsfile 39 | count=`grep -P "ERROR|WARN" "$resultfile" | wc -l` 40 | # Check if there are problems 41 | if (($count > 0)) 42 | then 43 | exit 1 44 | fi 45 | exit 0 46 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "moodlehq/moodle-local_ci", 3 | "description": "Stuff run by Moodle CI integration servers.", 4 | "keywords": ["moodle", "ci", "integration", "jira", "jenkins", "automations"], 5 | "license": "GPL-3.0-or-later", 6 | "require": { 7 | "moodlehq/moodle-cs": "^3.4.10", 8 | "mustache/mustache": "^2.14.2", 9 | "phpcompatibility/php-compatibility": "dev-develop#96072c30" 10 | }, 11 | "config": { 12 | "allow-plugins": { 13 | "dealerdirect/phpcodesniffer-composer-installer": true 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /git_garbage_collector/git_garbage_collector.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # $gitcmd: Path to git executable. 3 | # $gitdir: Directory containing git repo. 4 | # $gcinterval: Number of runs before performing a manual gc of the repo. Defaults to 25. 0 means disabled. 5 | # $gcaggressiveinterval: Number of runs before performing an aggressive gc of the repo. Defaults to 900. 0 means disabled. 6 | 7 | # Want exit on error. 8 | set -e 9 | 10 | # Apply some defaults 11 | gcinterval=${gcinterval:-25} 12 | gcaggressiveinterval=${gcaggressiveinterval:-900} 13 | 14 | # Verify everything is set 15 | required="gitcmd gitdir" 16 | for var in ${required}; do 17 | if [ -z "${!var}" ]; then 18 | echo "Error: ${var} environment variable is not defined. See the script comments." 19 | exit 1 20 | fi 21 | done 22 | 23 | # Calculate some variables 24 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 25 | 26 | # Verify we are under a git repo. 27 | if [[ ! -d "${gitdir}/.git" ]]; then 28 | echo "Error: Incorrect or non-git gitdir passed. Please fix it." 29 | exit 1 30 | fi 31 | 32 | cd "${gitdir}" 33 | 34 | # Let's verify if a git gc is required. 35 | 36 | random=${RANDOM} 37 | if [[ -n "${BUILD_TAG}" ]]; then # Running jenkins, use build number. 38 | random=${BUILD_NUMBER} 39 | fi 40 | 41 | if [[ ${gcaggressiveinterval} -gt 0 ]] && [[ $((${random} % ${gcaggressiveinterval})) -eq 0 ]]; then 42 | echo "Info: Executing git gc --aggressive" 43 | ${gitcmd} gc --aggressive --quiet 44 | elif [[ ${gcinterval} -gt 0 ]] && [[ $((${random} % ${gcinterval})) -eq 0 ]]; then 45 | echo "Info: Executing git gc" 46 | ${gitcmd} gc --quiet 47 | fi 48 | -------------------------------------------------------------------------------- /git_sync_two_branches/lib.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Functions for git_sync_two_branches.sh 4 | 5 | # Let's go strict (exit on error) 6 | set -e 7 | 8 | # Apply some defaults in case nobody defined them. 9 | BUILD_NUMBER="${BUILD_NUMBER:-0}" 10 | BUILD_TIMESTAMP="$(date +'%Y-%m-%d_%H-%M-%S')" 11 | gitcmd="${gitcmd:-git}" 12 | logfile="${WORKSPACE}/git_sync_two_branches.log" 13 | 14 | # Utility function to check if a branch is an ancestor of another branch. 15 | # Returns 0 if $1 is an ancestor of $2, 1 otherwise. 16 | function is_ancestor() { 17 | local branch1=$1 18 | local branch2=$2 19 | if ${gitcmd} merge-base --is-ancestor "${branch1}" "${branch2}"; then 20 | return 0 21 | else 22 | return 1 23 | fi 24 | } 25 | 26 | # Utility function to output something both to stdout and to a log file, with some extra information. 27 | function log() { 28 | echo "$1" 29 | echo "$BUILD_NUMBER $BUILD_TIMESTAMP $1" >> "${logfile}" 30 | } 31 | -------------------------------------------------------------------------------- /groovyscripts/add_notification_webhook_to_all_jobs.groovy: -------------------------------------------------------------------------------- 1 | // You need to install the Notification plugin for this script to work! 2 | // https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin 3 | 4 | import com.tikal.hudson.plugins.notification.HudsonNotificationProperty 5 | import com.tikal.hudson.plugins.notification.Endpoint 6 | import com.tikal.hudson.plugins.notification.Protocol 7 | import com.tikal.hudson.plugins.notification.Format 8 | 9 | 10 | Boolean DRYRUN = true 11 | 12 | for (item in Hudson.instance.items) { 13 | // Decide how many log lines to send in notifications, note that the 14 | // last 2 are always related to the failure (and stripped by notification 15 | // recieved), so this is really 3 lines by defualt. 16 | Integer loglines = 5; 17 | String URL = "https://telegrambot.moodle.org/hubot/jenkinsnotify" 18 | 19 | if (item.name.contains('Precheck remote branch')) { 20 | // No notifications here :) 21 | continue; 22 | } else if (item.name.contains('phpunit')) { 23 | // Usually useful info about failure, give 24 | // a bit more context: 25 | loglines = 10; 26 | } else if (item.name.contains('behat')) { 27 | // Can't get useful summary out of behat. 28 | loglines = 0; 29 | } else if (item.name.contains('Check upgrade savepoints')) { 30 | // Doesn't provide a useful summary at the moment 31 | loglines = 0; 32 | } else if (item.name.contains('Rebase security branch')) { 33 | URL = "$URL?alwaysinform=1"; 34 | } else if (item.name.contains('Check marked as integrated')) { 35 | URL = "$URL?alwaysinform=1"; 36 | } 37 | 38 | // Remove existing notification configuration 39 | item.properties.each{ 40 | if (it.value instanceof com.tikal.hudson.plugins.notification.HudsonNotificationProperty) { 41 | if (DRYRUN) { 42 | println("WOULD remove existing notifier from $item.name"); 43 | } else { 44 | println("Removing existing notifier from $item.name") 45 | item.removeProperty(it.value); 46 | } 47 | } 48 | } 49 | 50 | // Add new notification configuration 51 | ArrayList es = new ArrayList() 52 | es.add(new Endpoint(Protocol.HTTP, URL, 'completed', Format.JSON, 30000, loglines)) 53 | JobProperty p = new HudsonNotificationProperty(es) 54 | assert(p != null) 55 | if (DRYRUN) { 56 | println("WOULD add notifier to $item.name with $loglines logliness"); 57 | } else { 58 | item.addProperty(p) 59 | println("Added notifier to $item.name with $loglines logliness"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /groovyscripts/remove_post_action_from_all_jobs.groovy: -------------------------------------------------------------------------------- 1 | // Iterate over all the Freeform jobs in a Jenkins server 2 | // deleting a given (full class name) post-build action (also called publisher) 3 | // The script will fail if the PUBLISHER_TO_KILL plugin/class is not installed 4 | import hudson.model.FreeStyleProject 5 | import hudson.model.Hudson 6 | import hudson.tasks.Publisher 7 | 8 | Boolean DRYRUN = true 9 | Class PUBLISHER_TO_KILL = hudson.plugins.jabber.im.transport.JabberPublisher 10 | 11 | for (item in Hudson.instance.items) { 12 | 13 | println("Job: $item.displayName") 14 | modified = false 15 | 16 | if (Hudson.instance.getJob(item.displayName).getClass() != FreeStyleProject ) { 17 | println("Skipped: $item.displayName") 18 | continue 19 | } 20 | 21 | FreeStyleProject project = Hudson.instance.getJob(item.displayName) 22 | List publishers = project.getPublishersList() 23 | 24 | for (publisher in publishers) { 25 | classname = publisher.getClass() 26 | if (classname.equals(PUBLISHER_TO_KILL)) { 27 | if (DRYRUN) { 28 | println(" - $PUBLISHER_TO_KILL.name WOULD be deleted (DRYRUN enabled)") 29 | } else { 30 | publishers.remove(publisher) 31 | println(" - $PUBLISHER_TO_KILL.name DELETED") 32 | } 33 | modified = true 34 | } 35 | } 36 | if (!DRYRUN && modified) { 37 | project.save() 38 | println(" - Job saved") 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moodlehq/moodle-local_ci/2eb3ec567831a04aff01da95135714f70d11e0e1/index.html -------------------------------------------------------------------------------- /jenkins_cli/jenkins-cli.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moodlehq/moodle-local_ci/2eb3ec567831a04aff01da95135714f70d11e0e1/jenkins_cli/jenkins-cli.jar -------------------------------------------------------------------------------- /jira.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file contains the standard configuration relating to all queries used for tracker automations. 4 | # Any use of numeric custom fields or filters should be defined here. 5 | # This file should be sourced by any script that needs to use the tracker. 6 | 7 | set -e 8 | 9 | customfield_automatedTestResults=17112 10 | customfield_componentLeadReview=15810 11 | customfield_currentlyInIntegration=10211 12 | customfield_integrationDate=10210 13 | customfield_integrationPriority=12210 14 | customfield_integrator=10110 15 | customfield_pullFromRepository=10100 16 | customfield_tester=10011 17 | 18 | filter_candidatesForCLR="Weekly: Candidates for CLR (not held)" 19 | filter_candidatesForIntegration="Weekly: Candidates for Integration (not held)" 20 | filter_integrationCLRDecision="Weekly: Issues to decide between IR/CLR" 21 | filter_issuesHeldUntilAfterRelease="Issues agreed to be after release" 22 | filter_issuesVotedToUnhold="Issues that have been voted for unhold" 23 | filter_issuesWaitingForReviewOrInProgress="Integration: Current queue for issues waiting for peer review or review in progress" 24 | filter_mustFixIssues="All \"must-fix\" issues" 25 | 26 | # Verify everything is set 27 | required="jiraclicmd jiraserver jirauser jirapass" 28 | for var in $required; do 29 | if [ -z "${!var}" ]; then 30 | echo "Error: ${var} environment variable is not defined. See the script comments." 31 | exit 1 32 | fi 33 | done 34 | 35 | # Set the base request command. 36 | basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}" 37 | -------------------------------------------------------------------------------- /lang/en/local_ci.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * CI scripts lang strings 19 | * 20 | * @package local_ci 21 | * @copyright 2012 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die; 26 | 27 | $string['pluginname'] = 'CI scripts'; 28 | -------------------------------------------------------------------------------- /list_changed_files/list_changed_files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # $gitcmd: Path to the git CLI executable 3 | # $gitdir: Directory containing git repo 4 | # $initialcommit: hash of the initial commit 5 | # $finalcommit: hash of the final commit 6 | 7 | # List the modified files in a git repository between 2 commits. 8 | # (relative to the root dir of the git repository) 9 | 10 | # Don't be strict. Script has own error control handle 11 | set +e 12 | 13 | difffilter=${1:-"ACDMRTUXB"} 14 | 15 | # Verify everything is set 16 | required="gitcmd gitdir initialcommit finalcommit" 17 | for var in $required; do 18 | if [ -z "${!var}" ]; then 19 | echo "Error: ${var} environment variable is not defined. See the script comments." 20 | exit 1 21 | fi 22 | done 23 | 24 | # calculate some variables 25 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 26 | 27 | cd ${gitdir} 28 | 29 | # verify initial commit exists 30 | ${gitcmd} rev-parse --quiet --verify ${initialcommit} > /dev/null 31 | if [[ ${PIPESTATUS[0]} -ne 0 ]]; then 32 | echo "Error: initial commit does not exist (${initialcommit})" 33 | exit 1 34 | fi 35 | 36 | # verify final commit exists 37 | ${gitcmd} rev-parse --quiet --verify ${finalcommit} > /dev/null 38 | if [[ ${PIPESTATUS[0]} -ne 0 ]]; then 39 | echo "Error: final commit does not exist (${finalcommit})" 40 | exit 1 41 | fi 42 | 43 | # verify initial commit is ancestor of final commit 44 | ${gitcmd} merge-base --is-ancestor ${initialcommit} ${finalcommit} > /dev/null 2>&1 45 | if [[ ${PIPESTATUS[0]} -ne 0 ]]; then 46 | echo "Error: unrelated commits are not comparable (${initialcommit} and ${finalcommit})" 47 | exit 1 48 | fi 49 | 50 | # get all the files changed between both commits (no matter the diffs are empty) 51 | git log --diff-filter=${difffilter} --find-renames=100% --name-only --pretty=oneline --full-index ${initialcommit}..${finalcommit} | \ 52 | grep -vE '^[0-9a-f]{40} ' | sort | uniq 53 | -------------------------------------------------------------------------------- /mustache_lint/mustache_lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # $gitcmd: Path to the git CLI executable 3 | # $gitdir: Directory containing git repo 4 | # $phpcmd: Path to php CLI exectuable 5 | # $validator: (optional) url for validator - defaults to https://html5.validator.nu 6 | # 7 | # Based on GIT_PREVIOUS_COMMIT and GIT_COMMIT will list all changed php 8 | # files and run lint on them. 9 | # 10 | set -e 11 | 12 | # Verify everything is set 13 | required="gitcmd gitdir phpcmd GIT_PREVIOUS_COMMIT GIT_COMMIT" 14 | for var in $required; do 15 | if [ -z "${!var}" ]; then 16 | echo "Error: ${var} environment variable is not defined. See the script comments." 17 | exit 1 18 | fi 19 | done 20 | 21 | # calculate some variables 22 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 23 | 24 | validator=${validator:-"https://html5.validator.nu"} 25 | if [ -f "$mydir/../node_modules/vnu-jar/build/dist/vnu.jar" ] 26 | then 27 | if java -version 2>&1 >/dev/null | grep -Eq "(java|openjdk) version" 28 | then 29 | # Extract major and minor digits of version and compare it as float 30 | # numbers. Not error proof, but sufficient to ensure it is >= 1.8 31 | javaversion=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/') 32 | if [ $( echo "${javaversion} >= 1.8" | bc ) == 1 ] 33 | then 34 | echo "NPM installed validator found." 35 | validator="$( cd $mydir/../node_modules/ && pwd)/vnu-jar/build/dist/vnu.jar" 36 | else 37 | echo "NPM installed validator available, but java version too low: $javaversion" 38 | fi 39 | else 40 | echo "NPM installed validator available, but java not found in path" 41 | fi 42 | fi 43 | 44 | echo "Validating using $validator" 45 | 46 | 47 | export initialcommit=${GIT_PREVIOUS_COMMIT} 48 | export finalcommit=${GIT_COMMIT} 49 | # Fetch all files, excluding files which are renames. 50 | # There is no need to check renames. 51 | if mfiles=$(${mydir}/../list_changed_files/list_changed_files.sh r) 52 | then 53 | echo "Running mustache lint from $initialcommit to $finalcommit:" 54 | else 55 | echo "Problems getting the list of changed files." 56 | exit 1; 57 | fi 58 | 59 | # Verify all the changed files. 60 | errorfound=0 61 | for mfile in ${mfiles} ; do 62 | # Only run on mustache files. 63 | if [[ "${mfile}" =~ ".mustache" ]] ; then 64 | fullpath=$gitdir/$mfile 65 | 66 | if [ -e $fullpath ] ; then 67 | if ! $phpcmd $mydir/mustache_lint.php --filename=$fullpath --validator=$validator --basename=$gitdir 68 | then 69 | errorfound=1 70 | fi 71 | else 72 | # This is a bit of a hack, we should really be using git to 73 | # get actual file contents from the latest commit to avoid 74 | # this situation. But in the end we are checking against the 75 | # current state of the codebase, so its no bad thing.. 76 | echo "$fullpath - SKIPPED (file no longer exists)" 77 | fi 78 | fi 79 | done 80 | 81 | if [[ ${errorfound} -eq 0 ]]; then 82 | # No syntax errors found, all good. 83 | echo "No mustache problems found" 84 | exit 0 85 | fi 86 | 87 | echo "Mustache lint problems found" 88 | exit 1 89 | -------------------------------------------------------------------------------- /mustache_lint/running_validator.txt: -------------------------------------------------------------------------------- 1 | Running a local instance of the validator for more reliability.. 2 | 3 | 4 | 1/ npm install 5 | 2/ The mustache_lint.sh script should use the npm-installed version of validator automatically. 6 | -------------------------------------------------------------------------------- /mustache_lint/simple_core_component_mustache_loader.php: -------------------------------------------------------------------------------- 1 | = 8.1 warnings. 11 | $this->theme = $theme; 12 | } 13 | 14 | /** 15 | * Helper function for getting a Mustache template file name. 16 | * Uses the leading component to restrict us specific directories. 17 | * 18 | * @param string $name 19 | * @return string Template file name 20 | */ 21 | protected function getFileName($name) { 22 | if (strpos($name, '/') === false) { 23 | // Silently ignore. 24 | return false; 25 | } 26 | 27 | list($component, $templatename) = explode('/', $name, 2); 28 | 29 | if ($this->theme) { 30 | // The real mustache loader handles theme parents - we don't here for simplicity. 31 | $themedir = core_component::get_plugin_directory('theme', $this->theme); 32 | 33 | $themetemplate = $themedir . '/templates/' . $component . '/'. $templatename . '.mustache'; 34 | if (file_exists($themetemplate)) { 35 | return $themetemplate; 36 | } 37 | } 38 | 39 | $compdirectory = core_component::get_component_directory($component); 40 | $path = $compdirectory . '/templates/' . $templatename . '.mustache'; 41 | if (!file_exists($path)) { 42 | return false; 43 | } 44 | 45 | return $path; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "moodle-local_ci", 3 | "version": "0.0.1", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "moodle-local_ci", 9 | "version": "0.0.1", 10 | "dependencies": { 11 | "vnu-jar": "23.4.11" 12 | } 13 | }, 14 | "node_modules/vnu-jar": { 15 | "version": "23.4.11", 16 | "resolved": "https://registry.npmjs.org/vnu-jar/-/vnu-jar-23.4.11.tgz", 17 | "integrity": "sha512-lI5dzBYXtxhilNI7EeQ5iUduYnNBq7YWx4UjfBVLXfBQHnXYZSf3y3bpM0bSyDU6jy/+OyKV7nw4tzpR5lXSZg==", 18 | "engines": { 19 | "node": ">=0.10" 20 | } 21 | } 22 | }, 23 | "dependencies": { 24 | "vnu-jar": { 25 | "version": "23.4.11", 26 | "resolved": "https://registry.npmjs.org/vnu-jar/-/vnu-jar-23.4.11.tgz", 27 | "integrity": "sha512-lI5dzBYXtxhilNI7EeQ5iUduYnNBq7YWx4UjfBVLXfBQHnXYZSf3y3bpM0bSyDU6jy/+OyKV7nw4tzpR5lXSZg==" 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "moodle-local_ci", 3 | "version": "0.0.1", 4 | "description": "Tools for CI with Moodle", 5 | "private": true, 6 | "dependencies": { 7 | "vnu-jar": "23.4.11" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /php_lint/php_lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # $gitcmd: Path to the git CLI executable 3 | # $gitdir: Directory containing git repo 4 | # $phpcmd: Path to php CLI exectuable 5 | # 6 | # Based on GIT_PREVIOUS_COMMIT and GIT_COMMIT will list all changed php 7 | # files and run lint on them. 8 | # 9 | set -e 10 | 11 | # Verify everything is set 12 | required="gitcmd gitdir phpcmd" 13 | for var in $required; do 14 | if [ -z "${!var}" ]; then 15 | echo "Error: ${var} environment variable is not defined. See the script comments." 16 | exit 1 17 | fi 18 | done 19 | 20 | # calculate some variables 21 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 22 | 23 | fulllint=0 24 | 25 | echo "Using $($phpcmd -v | grep '^PHP')" 26 | 27 | if [[ -z "${GIT_PREVIOUS_COMMIT}" ]] || [[ -z "${GIT_COMMIT}" ]] ; then 28 | # No git diff information. Lint all php files. 29 | fulllint=1 30 | fi 31 | 32 | if [[ ${fulllint} -ne 1 ]]; then 33 | # We don't need to do a full lint create the variables required by 34 | # list_changed_files.sh and invoke it 35 | export initialcommit=${GIT_PREVIOUS_COMMIT} 36 | export finalcommit=${GIT_COMMIT} 37 | if mfiles=$(${mydir}/../list_changed_files/list_changed_files.sh) 38 | then 39 | echo "Running php syntax check from $initialcommit to $finalcommit:" 40 | else 41 | echo "Problems getting the list of changed files. Defaulting to full lint" 42 | fulllint=1 43 | fi 44 | fi 45 | 46 | if [[ ${fulllint} -eq 1 ]]; then 47 | mfiles=$(find $gitdir/ -name \*.php | sed "s|$gitdir/||") 48 | echo "Running php syntax check on all files:" 49 | fi 50 | 51 | # Verify all the changed files. 52 | errorfound=0 53 | for mfile in ${mfiles} ; do 54 | 55 | # Exclude any /vendor/ stuff. Always, no matter this is a full or commit run. 56 | if [[ "${mfile}" =~ (^|/)vendor/ ]]; then 57 | continue 58 | fi 59 | 60 | # Only run on php files. 61 | if [[ "${mfile}" =~ .php$ ]] ; then 62 | fullpath=$gitdir/$mfile 63 | 64 | if [ -e $fullpath ] ; then 65 | # We have to ensure that error_log is not set because it makes the 66 | # CLI to add blank lines to output. Crazy but true. 67 | if LINTERRORS=$(($phpcmd -d error_log= -l $fullpath >/dev/null) 2>&1) 68 | then 69 | echo "$fullpath - OK" 70 | else 71 | errorfound=1 72 | # Filter out the paths from errors: 73 | ERRORS=$(echo $LINTERRORS | sed "s#$gitdir##") 74 | echo "$fullpath - ERROR: $ERRORS" 75 | fi 76 | if grep -q $'\xEF\xBB\xBF' $fullpath 77 | then 78 | echo "$fullpath - ERROR: BOM character found" 79 | errorfound=1 80 | fi 81 | else 82 | # This is a bit of a hack, we should really be using git to 83 | # get actual file contents from the latest commit to avoid 84 | # this situation. But in the end we are checking against the 85 | # current state of the codebase, so its no bad thing.. 86 | echo "$fullpath - SKIPPED (file no longer exists)" 87 | fi 88 | fi 89 | done 90 | 91 | if [[ ${errorfound} -eq 0 ]]; then 92 | # No syntax errors found, all good. 93 | echo "No PHP syntax errors found" 94 | exit 0 95 | fi 96 | 97 | echo "PHP syntax errors found." 98 | exit 1 99 | -------------------------------------------------------------------------------- /prepare_composer_stuff/prepare_composer_stuff.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # $phpcmd: Path to the PHP CLI executable 3 | # $composercmd: Path to the composer (usually installed globally in the CI server) executable 4 | # $composerdirbase: Path to the directory where composer will be installed (--working-dir). branch name will be automatically added. 5 | # $gitdir: Directory containing git repo 6 | # $gitbranch: Branch we are going to install the DB 7 | # $githuboauthtoken: Token for accessing gitub without limits. 8 | 9 | # Let's be strict. Any problem will abort execution. 10 | set -e 11 | 12 | # Set the composer env variable so it always use the correct php when multiple are installed. 13 | export PATH=$(dirname ${phpcmd}):${PATH} 14 | 15 | # Verify everything is set 16 | required="phpcmd composercmd composerdirbase gitdir gitbranch githuboauthtoken" 17 | for var in $required; do 18 | if [ -z "${!var}" ]; then 19 | echo "Error: ${var} environment variable is not defined. See the script comments." 20 | exit 1 21 | fi 22 | done 23 | 24 | # Calculate composer working directory and create it if needed. 25 | composerdir=${composerdirbase}/${gitbranch} 26 | mkdir -p ${composerdir} 27 | 28 | # Copy composer.json and composer.lock files to composer directory. 29 | cp ${gitdir}/composer.json ${composerdir} 30 | if [[ -f ${gitdir}/composer.lock ]]; then 31 | cp ${gitdir}/composer.lock ${composerdir} 32 | fi 33 | 34 | # Unconditionally run composer install (to observe 100% .lock versions) 35 | echo "Installing composer packages @ ${composerdir}" 36 | ${composercmd} config --global github-oauth.github.com ${githuboauthtoken} 37 | ${composercmd} install --working-dir=${composerdir} --prefer-dist 38 | 39 | # Optimize autoloader of installed stuff. 40 | echo "Optimizing composer autoload @ ${composerdir}" 41 | ${composercmd} dump-autoload --optimize --working-dir=${composerdir} 42 | 43 | # Add the bin directory to the PATH, so it can be used 44 | export PATH=${composerdir}/vendor/bin:${PATH} 45 | 46 | # And link it to dirroot/vendor as far as we have dependencies in tool_phpunit 47 | # requiring vendor to be there, grrr. 48 | echo "Linking ${composerdir}/vendor from ${gitdir}/vendor" 49 | if [[ -L ${gitdir}/vendor ]]; then 50 | rm -f ${gitdir}/vendor 51 | fi 52 | ln -nfs ${composerdir}/vendor ${gitdir}/vendor 53 | -------------------------------------------------------------------------------- /project_size_report/project_size_report.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # $gitdir: Directory containing git repo 3 | # $gitbranch: Branch we are going to check 4 | # $pearpath: Path where the pear executables are available 5 | # $phpcmd: php cli executable 6 | 7 | # file where results will be sent 8 | resultfile=${WORKSPACE}/project_size_report.csv 9 | 10 | # add the PEAR path 11 | PATH="$PATH:/opt/local/bin/:$pearpath"; export PATH 12 | 13 | # calculate some variables 14 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 15 | 16 | # list of excluded dirs 17 | . ${mydir}/../define_excluded/define_excluded.sh 18 | 19 | # checkout pristine copy of the configure branch 20 | cd ${gitdir} && git checkout ${gitbranch} && git fetch && git reset --hard origin/${gitbranch} 21 | 22 | # Run phploc against the whole codebase 23 | phploc ${excluded_list} --count-tests --log-csv "${resultfile}" ${gitdir} 24 | -------------------------------------------------------------------------------- /run_phpunittests/config.php.template: -------------------------------------------------------------------------------- 1 | wwwroot = 'http://localhost'; 9 | $CFG->admin = 'admin'; 10 | $CFG->directorypermissions = 00777; 11 | $CFG->dataroot='%%DATADIR%%'; 12 | 13 | // DB settings 14 | $CFG->dblibrary='%%DBLIBRARY%%'; 15 | $CFG->dbtype='%%DBTYPE%%'; 16 | $CFG->dbhost='%%DBHOST%%'; 17 | $CFG->dbuser='%%DBUSER%%'; 18 | $CFG->dbpass='%%DBPASS%%'; 19 | $CFG->dbname='%%DBNAME%%'; 20 | $CFG->dboptions=array(); 21 | 22 | // PHPUNIT settings 23 | $CFG->phpunit_prefix='p_'; 24 | $CFG->phpunit_dataroot='%%DATADIRPHPUNIT%%'; 25 | 26 | // Set correct server timezone 27 | date_default_timezone_set('Europe/Madrid'); 28 | 29 | // Debugging and performance footer 30 | $CFG->debug = E_ALL | E_STRICT; 31 | $CFG->xmlstrictheaders = false; 32 | $CFG->debugdisplay = true; 33 | $CFG->perfdebug = 15; 34 | define('MDL_PERFDB' , true); 35 | $CFG->upgradeshowsql = true; 36 | $CFG->debugpageinfo = true; 37 | 38 | // Early profiling 39 | $CFG->earlyprofilingenabled = true; 40 | $CFG->profilingautofrec = 10; 41 | $CFG->profilingincluded = '/*view.php,/*index.php'; 42 | $CFG->profilingallowme = true; 43 | $CFG->profilingallowall = true; 44 | 45 | // Disable lang cache to get immediate changes 46 | $CFG->langstringcache = false; 47 | 48 | // STOP any mailout 49 | $CFG->noemailever = true; 50 | 51 | // Ensure some stuff is always enabled 52 | $CFG->enablecompletion = true; 53 | $CFG->enableavailability = true; 54 | $CFG->usetags = true; 55 | $CFG->enableoutcomes = true; 56 | $CFG->usecomments = true; 57 | 58 | // Extra settings 59 | %%EXTRACONFIG%% 60 | 61 | require_once(dirname(__FILE__) . '/lib/setup.php'); 62 | // MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES, 63 | // RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE. 64 | -------------------------------------------------------------------------------- /tests/checkstyle_manipulations.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load libs/shared_setup 4 | 5 | # Helper to assert checkstyle converts 6 | # usage: assert_checkstyle phpscript fixturefilename expectedfilename 7 | assert_checkstyle() { 8 | phpscript=$1 9 | fixture=$BATS_TEST_DIRNAME/fixtures/checkstyle/$2 10 | expected=$BATS_TEST_DIRNAME/fixtures/checkstyle/$3 11 | 12 | xmlfile=$BATS_TMPDIR/out.xml 13 | 14 | ci_run_php "$phpscript < $fixture > $xmlfile" 15 | assert_success 16 | assert_files_same $expected $xmlfile 17 | rm $xmlfile 18 | } 19 | 20 | @test "check_upgrade_savepoints/savepoints2checkstyle.php" { 21 | assert_checkstyle check_upgrade_savepoints/savepoints2checkstyle.php savepoints.txt savepoints.xml 22 | } 23 | 24 | @test "verify_commit_messages/commits2checkstyle.php" { 25 | assert_checkstyle verify_commit_messages/commits2checkstyle.php commits.txt commits.xml 26 | } 27 | 28 | @test "verify_commit_messages/commits2checkstyle.php info only " { 29 | assert_checkstyle verify_commit_messages/commits2checkstyle.php commits-info.txt commits-info.xml 30 | } 31 | 32 | @test "remote_branch_checker/checkstyle_converter.php: phplint" { 33 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=phplint' phplint.txt phplint.xml 34 | } 35 | 36 | @test "remote_branch_checker/checkstyle_converter.php: thirdparty" { 37 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=thirdparty' thirdparty.txt thirdparty.xml 38 | } 39 | 40 | @test "remote_branch_checker/checkstyle_converter.php: grunt" { 41 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=gruntdiff' grunt.txt grunt.xml 42 | } 43 | 44 | @test "remote_branch_checker/checkstyle_converter.php: grunt build failed" { 45 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=gruntdiff' grunt-build-failed.txt grunt-build-failed.xml 46 | } 47 | 48 | @test "remote_branch_checker/checkstyle_converter.php: shifter" { 49 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=shifter' grunt-errors.txt shifter.xml 50 | } 51 | 52 | @test "remote_branch_checker/checkstyle_converter.php: mustachelint" { 53 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=mustachelint' mustachelint.txt mustachelint.xml 54 | } 55 | 56 | @test "remote_branch_checker/checkstyle_converter.php: gherkinlint ok" { 57 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=gherkinlint' gherkinlint_ok.txt gherkinlint_ok.xml 58 | } 59 | 60 | @test "remote_branch_checker/checkstyle_converter.php: gherkinlint err" { 61 | assert_checkstyle 'remote_branch_checker/checkstyle_converter.php --format=gherkinlint' gherkinlint_err.txt gherkinlint_err.xml 62 | } 63 | -------------------------------------------------------------------------------- /tests/define_excluded.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load libs/shared_setup 4 | 5 | setup () { 6 | create_git_branch MOODLE_31_STABLE v3.1.0 7 | } 8 | 9 | # Helper for repetitive excluded asserions on all the formats 10 | # usage: assert_define_excluded format 11 | assert_define_excluded_format () { 12 | export format=$1 13 | expected=$BATS_TEST_DIRNAME/fixtures/define_excluded/format-$format-expected.txt 14 | 15 | ci_run define_excluded/define_excluded.sh 16 | assert_success 17 | # Don't want full paths ever 18 | refute_output --partial "$(dirname $gitdir)" 19 | 20 | # Verify all expectations in fixture are in results. 21 | while read -r expectation; do 22 | [[ "$expectation" =~ ^#.*$ ]] && continue # Skip comments. 23 | assert_output --partial "$expectation" 24 | done < "$expected" 25 | } 26 | 27 | @test "define_excluded: generates results correctly for all formats" { 28 | formats=('excluded' 'excluded_comma' 'excluded_comma_wildchars' \ 29 | 'excluded_grep' 'excluded_list' 'excluded_list_wildchars') 30 | for format in "${formats[@]}"; do 31 | assert_define_excluded_format $format 32 | done 33 | } 34 | 35 | @test "define_excluded: is immune to trailing slashes in gitdir" { 36 | export gitdir=$gitdir//// 37 | assert_define_excluded_format excluded 38 | } 39 | -------------------------------------------------------------------------------- /tests/detect_conflicts.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load libs/shared_setup 4 | 5 | setup () { 6 | create_git_branch MOODLE_31_STABLE v3.1.1 7 | # Restore workspace if not first test. 8 | first_test || restore_workspace 9 | } 10 | 11 | teardown () { 12 | # Store workspace if not last test. 13 | last_test || store_workspace 14 | } 15 | 16 | @test "detect_conflicts: first run OK" { 17 | # On first run, there are no results to compare to so should always 18 | # pass. 19 | ci_run detect_conflicts/detect_conflicts.sh 20 | assert_success 21 | assert_output --partial "current count: 0" 22 | # The 'no previously recorded value' number is 999999 23 | assert_output --partial "previous count: 999999" 24 | assert_output --partial "best count: 999999" 25 | assert_output --partial "got best results ever, yay!" 26 | } 27 | 28 | @test "detect_conflicts: normal state OK" { 29 | # On second run, should still pass with same results 30 | ci_run detect_conflicts/detect_conflicts.sh 31 | assert_success 32 | assert_output --partial "current count: 0" 33 | assert_output --partial "previous count: 0" 34 | assert_output --partial "best count: 0" 35 | assert_output --partial "continue in best results ever" 36 | } 37 | 38 | @test "detect_conflicts: failure reported when merge conflict detected" { 39 | git_apply_fixture 31-merge-conflict.patch 40 | 41 | ci_run detect_conflicts/detect_conflicts.sh 42 | assert_failure 43 | assert_output --partial "current count: 3" 44 | assert_output --partial "previous count: 0" 45 | assert_output --partial "best count: 0" 46 | assert_output --partial "worse results than previous counter" 47 | } 48 | -------------------------------------------------------------------------------- /tests/diff_extract_changes.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load libs/shared_setup 4 | 5 | # Helper to assert diff_extract_changes output 6 | # usage: pssert_diff_extract_changes format fixturefilename expectedfilename 7 | assert_diff_extract_changes() { 8 | format=$1 9 | fixture=$BATS_TEST_DIRNAME/fixtures/diff_extract_changes/$2 10 | expected=$BATS_TEST_DIRNAME/fixtures/diff_extract_changes/$3 11 | 12 | out=$BATS_TMPDIR/diff_extract_changes-out 13 | 14 | ci_run_php "diff_extract_changes/diff_extract_changes.php --diff=$fixture --output=$format > $out" 15 | assert_success 16 | assert_files_same $expected $out 17 | rm $out 18 | } 19 | 20 | @test "diff_extract_changes (normal): xml" { 21 | assert_diff_extract_changes xml diff_extract_changes-normal-input.patch diff_extract_changes-normal-expected.xml 22 | } 23 | 24 | @test "diff_extract_changes (normal): txt" { 25 | assert_diff_extract_changes txt diff_extract_changes-normal-input.patch diff_extract_changes-normal-expected.txt 26 | } 27 | 28 | @test "diff_extract_changes (edge): xml" { 29 | assert_diff_extract_changes xml diff_extract_changes-edge-input.patch diff_extract_changes-edge-expected.xml 30 | } 31 | 32 | @test "diff_extract_changes (edge): txt" { 33 | assert_diff_extract_changes txt diff_extract_changes-edge-input.patch diff_extract_changes-edge-expected.txt 34 | } 35 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-full-html-body.patch: -------------------------------------------------------------------------------- 1 | From d7f48a533d3d1bf7bff0e48d5ad6930b4d0838e7 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 2 Nov 2016 10:41:20 +0000 4 | Subject: [PATCH 1/1] MDL-12345 mustache: fixture for full html 5 | 6 | --- 7 | lib/templates/full-html-page.mustache | 19 +++++++++++++++++++ 8 | 1 file changed, 19 insertions(+) 9 | create mode 100644 lib/templates/full-html-page.mustache 10 | 11 | diff --git a/lib/templates/full-html-page.mustache b/lib/templates/full-html-page.mustache 12 | new file mode 100644 13 | index 0000000..386ffb0 14 | --- /dev/null 15 | +++ b/lib/templates/full-html-page.mustache 16 | @@ -0,0 +1,19 @@ 17 | +{{! 18 | + @template core/full-html-page 19 | + 20 | + Full HTML page test. 21 | + 22 | + Example context (json): 23 | + { 24 | + "message": "Hello world!" 25 | + } 26 | +}} 27 | + 28 | + 29 | + 30 | +Test page 31 | + 32 | + 33 | +

{{message}}

34 | + 35 | + 36 | -- 37 | 2.10.0 38 | 39 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-html-validator-fail.patch: -------------------------------------------------------------------------------- 1 | From 1ca6835c73a3e48bebc75fef1b97cf5122cc624a Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 12 Oct 2016 20:33:08 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4770 test file mustache_linter 5 | 6 | --- 7 | lib/templates/linting.mustache | 35 +++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 35 insertions(+) 9 | create mode 100644 lib/templates/linting.mustache 10 | 11 | diff --git a/lib/templates/linting.mustache b/lib/templates/linting.mustache 12 | new file mode 100644 13 | index 0000000..70978a6 14 | --- /dev/null 15 | +++ b/lib/templates/linting.mustache 16 | @@ -0,0 +1,35 @@ 17 | +{{! 18 | + This file is part of Moodle - http://moodle.org/ 19 | + 20 | + Moodle is free software: you can redistribute it and/or modify 21 | + it under the terms of the GNU General Public License as published by 22 | + the Free Software Foundation, either version 3 of the License, or 23 | + (at your option) any later version. 24 | + 25 | + Moodle is distributed in the hope that it will be useful, 26 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | + GNU General Public License for more details. 29 | + 30 | + You should have received a copy of the GNU General Public License 31 | + along with Moodle. If not, see . 32 | +}} 33 | +{{! 34 | + @template core/linting 35 | + 36 | + A test for for mustache linting tests. 37 | + 38 | + Classes required for JS: 39 | + * none 40 | + 41 | + Data attributes required for JS: 42 | + * none 43 | + 44 | + Context variables required for this template: 45 | + * none 46 | + 47 | + Example context (json): 48 | + { 49 | + } 50 | +}} 51 | +

Hello World

52 | -- 53 | 2.10.0 54 | 55 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-invalid-json.patch: -------------------------------------------------------------------------------- 1 | From b4fb15ef887945fffde94488b98b2a17e95d87bf Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 12 Oct 2016 20:33:08 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4770 test file mustache_linter 5 | 6 | --- 7 | lib/templates/linting.mustache | 50 ++++++++++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 50 insertions(+) 9 | create mode 100644 lib/templates/linting.mustache 10 | 11 | diff --git a/lib/templates/linting.mustache b/lib/templates/linting.mustache 12 | new file mode 100644 13 | index 0000000..8155daf 14 | --- /dev/null 15 | +++ b/lib/templates/linting.mustache 16 | @@ -0,0 +1,50 @@ 17 | +{{! 18 | + This file is part of Moodle - http://moodle.org/ 19 | + 20 | + Moodle is free software: you can redistribute it and/or modify 21 | + it under the terms of the GNU General Public License as published by 22 | + the Free Software Foundation, either version 3 of the License, or 23 | + (at your option) any later version. 24 | + 25 | + Moodle is distributed in the hope that it will be useful, 26 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | + GNU General Public License for more details. 29 | + 30 | + You should have received a copy of the GNU General Public License 31 | + along with Moodle. If not, see . 32 | +}} 33 | +{{! 34 | + @template core/linting_ok 35 | + 36 | + A test for for mustache linting tests. 37 | + 38 | + Classes required for JS: 39 | + * none 40 | + 41 | + Data attributes required for JS: 42 | + * none 43 | + 44 | + Context variables required for this template: 45 | + * message A cleaned string (use clean_text()) to display. 46 | + * extraclasses Additional classes to apply to the notification. 47 | + * closebutton Whether a close button should be displayed to dismiss the message. 48 | + * announce Whether the notification should be announced to screen readers. 49 | + 50 | + Example context (json): 51 | + { 52 | + "message": "Your pants are on fire!", "closebutton": 1, "announce": 1, "extraclasses": "foo bar", 53 | + } 54 | +}} 55 | + 61 | +{{# js }} 62 | +require(['jquery', 'theme_bootstrapbase/bootstrap'], function($) { 63 | + // Setup closing of bootstrap alerts. 64 | + $().alert(); 65 | +}); 66 | +{{/ js }} 67 | -- 68 | 2.10.0 69 | 70 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-js_test.patch: -------------------------------------------------------------------------------- 1 | From 8fea79e251e80b79067c4caee9db54049409d266 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Fri, 4 Nov 2016 12:07:47 +0000 4 | Subject: [PATCH 1/1] MDL-12345 mustache: fixture for js problem detection 5 | 6 | --- 7 | lib/templates/js_test.mustache | 16 ++++++++++++++++ 8 | 1 file changed, 16 insertions(+) 9 | create mode 100644 lib/templates/js_test.mustache 10 | 11 | diff --git a/lib/templates/js_test.mustache b/lib/templates/js_test.mustache 12 | new file mode 100644 13 | index 0000000..4cc8914 14 | --- /dev/null 15 | +++ b/lib/templates/js_test.mustache 16 | @@ -0,0 +1,16 @@ 17 | +{{! 18 | + @template core/js_test 19 | + 20 | + Fixture for detecting eslint problems. 21 | + 22 | + Example context (json): 23 | + { 24 | + "text": "World!" 25 | + } 26 | + 27 | +}} 28 | +

Hello {{text}}

29 | +{{#js}} 30 | + var my_message = 'Hello {{text}}'; 31 | + alert(my_message); 32 | +{{/js}} 33 | -- 34 | 2.10.0 35 | 36 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-js_token_test.patch: -------------------------------------------------------------------------------- 1 | From 7c4ad58c7f7a462e39577959a6c4e05a868cc610 Mon Sep 17 00:00:00 2001 2 | From: Andrew Nicols 3 | Date: Mon, 8 Aug 2022 15:07:36 +0800 4 | Subject: [PATCH 1/1] MDL-12345 mustache: fixture for js parsing failure 5 | detection 6 | 7 | --- 8 | lib/templates/js_token_test.mustache | 14 ++++++++++++++ 9 | 1 file changed, 14 insertions(+) 10 | create mode 100644 lib/templates/js_token_test.mustache 11 | 12 | diff --git a/lib/templates/js_token_test.mustache b/lib/templates/js_token_test.mustache 13 | new file mode 100644 14 | index 0000000000..022896ea27 15 | --- /dev/null 16 | +++ b/lib/templates/js_token_test.mustache 17 | @@ -0,0 +1,14 @@ 18 | +{{! 19 | + @template core/js_token_test 20 | + 21 | + Fixture for testing eslint parsing errors. 22 | + 23 | + Example context (json): 24 | + { 25 | + "text": "World!" 26 | + } 27 | +}} 28 | +

Hello {{text}}

29 | +{{#js}} 30 | + var foo bar baz = 'bum'; 31 | +{{/js}} 32 | -- 33 | 2.37.0 34 | 35 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-mustache-syntax-error.patch: -------------------------------------------------------------------------------- 1 | From 9034289ac1a8606321699bffb15b766fa51e2ff7 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 12 Oct 2016 20:33:08 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4770 test file mustache_linter 5 | 6 | --- 7 | lib/templates/linting.mustache | 40 ++++++++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 40 insertions(+) 9 | create mode 100644 lib/templates/linting.mustache 10 | 11 | diff --git a/lib/templates/linting.mustache b/lib/templates/linting.mustache 12 | new file mode 100644 13 | index 0000000..9a2d6e6 14 | --- /dev/null 15 | +++ b/lib/templates/linting.mustache 16 | @@ -0,0 +1,40 @@ 17 | +{{! 18 | + This file is part of Moodle - http://moodle.org/ 19 | + 20 | + Moodle is free software: you can redistribute it and/or modify 21 | + it under the terms of the GNU General Public License as published by 22 | + the Free Software Foundation, either version 3 of the License, or 23 | + (at your option) any later version. 24 | + 25 | + Moodle is distributed in the hope that it will be useful, 26 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | + GNU General Public License for more details. 29 | + 30 | + You should have received a copy of the GNU General Public License 31 | + along with Moodle. If not, see . 32 | +}} 33 | +{{! 34 | + @template core/linting 35 | + 36 | + A test for for mustache linting tests. 37 | + 38 | + Classes required for JS: 39 | + * none 40 | + 41 | + Data attributes required for JS: 42 | + * none 43 | + 44 | + Context variables required for this template: 45 | + * message A cleaned string (use clean_text()) to display. 46 | + * extraclasses Additional classes to apply to the notification. 47 | + * closebutton Whether a close button should be displayed to dismiss the message. 48 | + * announce Whether the notification should be announced to screen readers. 49 | + 50 | + Example context (json): 51 | + { 52 | + "test": false 53 | + } 54 | +}} 55 | +{{#test }} 56 | +Hello World 57 | -- 58 | 2.10.0 59 | 60 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-no-content.patch: -------------------------------------------------------------------------------- 1 | From c4f6722772ada3d1b02dc78ec35e27015e04e6cf Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 12 Oct 2016 20:33:08 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4770 test file mustache_linter 5 | 6 | --- 7 | lib/templates/linting.mustache | 38 ++++++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 38 insertions(+) 9 | create mode 100644 lib/templates/linting.mustache 10 | 11 | diff --git a/lib/templates/linting.mustache b/lib/templates/linting.mustache 12 | new file mode 100644 13 | index 0000000..2028285 14 | --- /dev/null 15 | +++ b/lib/templates/linting.mustache 16 | @@ -0,0 +1,38 @@ 17 | +{{! 18 | + This file is part of Moodle - http://moodle.org/ 19 | + 20 | + Moodle is free software: you can redistribute it and/or modify 21 | + it under the terms of the GNU General Public License as published by 22 | + the Free Software Foundation, either version 3 of the License, or 23 | + (at your option) any later version. 24 | + 25 | + Moodle is distributed in the hope that it will be useful, 26 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | + GNU General Public License for more details. 29 | + 30 | + You should have received a copy of the GNU General Public License 31 | + along with Moodle. If not, see . 32 | +}} 33 | +{{! 34 | + @template core/linting 35 | + 36 | + A test for for mustache linting tests. 37 | + 38 | + Classes required for JS: 39 | + * none 40 | + 41 | + Data attributes required for JS: 42 | + * none 43 | + 44 | + Context variables required for this template: 45 | + * message A cleaned string (use clean_text()) to display. 46 | + * extraclasses Additional classes to apply to the notification. 47 | + * closebutton Whether a close button should be displayed to dismiss the message. 48 | + * announce Whether the notification should be announced to screen readers. 49 | + 50 | + Example context (json): 51 | + { 52 | + "message": "Your pants are on fire!", "closebutton": 1, "announce": 1, "extraclasses": "foo bar" 53 | + } 54 | +}} 55 | -- 56 | 2.10.0 57 | 58 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-no-example.patch: -------------------------------------------------------------------------------- 1 | From c6aec2f45b4bce2f6b7182a137474f9a83360508 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 12 Oct 2016 20:33:08 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4770 test file mustache_linter 5 | 6 | --- 7 | lib/templates/linting.mustache | 45 ++++++++++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 45 insertions(+) 9 | create mode 100644 lib/templates/linting.mustache 10 | 11 | diff --git a/lib/templates/linting.mustache b/lib/templates/linting.mustache 12 | new file mode 100644 13 | index 0000000..a8d078c 14 | --- /dev/null 15 | +++ b/lib/templates/linting.mustache 16 | @@ -0,0 +1,45 @@ 17 | +{{! 18 | + This file is part of Moodle - http://moodle.org/ 19 | + 20 | + Moodle is free software: you can redistribute it and/or modify 21 | + it under the terms of the GNU General Public License as published by 22 | + the Free Software Foundation, either version 3 of the License, or 23 | + (at your option) any later version. 24 | + 25 | + Moodle is distributed in the hope that it will be useful, 26 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | + GNU General Public License for more details. 29 | + 30 | + You should have received a copy of the GNU General Public License 31 | + along with Moodle. If not, see . 32 | +}} 33 | +{{! 34 | + @template core/linting_ok 35 | + 36 | + A test for for mustache linting tests. 37 | + 38 | + Classes required for JS: 39 | + * none 40 | + 41 | + Data attributes required for JS: 42 | + * none 43 | + 44 | + Context variables required for this template: 45 | + * message A cleaned string (use clean_text()) to display. 46 | + * extraclasses Additional classes to apply to the notification. 47 | + * closebutton Whether a close button should be displayed to dismiss the message. 48 | + * announce Whether the notification should be announced to screen readers. 49 | +}} 50 | + 56 | +{{# js }} 57 | +require(['jquery', 'theme_bootstrapbase/bootstrap'], function($) { 58 | + // Setup closing of bootstrap alerts. 59 | + $().alert(); 60 | +}); 61 | +{{/ js }} 62 | -- 63 | 2.10.0 64 | 65 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-ok.patch: -------------------------------------------------------------------------------- 1 | From ef072d57c41f6f9740f5d1805ab5e393af2b9dce Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 12 Oct 2016 20:33:08 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4770 test file mustache_linter 5 | 6 | --- 7 | lib/templates/linting_ok.mustache | 53 +++++++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 53 insertions(+) 9 | create mode 100644 lib/templates/linting_ok.mustache 10 | 11 | diff --git a/lib/templates/linting_ok.mustache b/lib/templates/linting_ok.mustache 12 | new file mode 100644 13 | index 0000000..a5cfa3a 14 | --- /dev/null 15 | +++ b/lib/templates/linting_ok.mustache 16 | @@ -0,0 +1,53 @@ 17 | +{{! 18 | + This file is part of Moodle - http://moodle.org/ 19 | + 20 | + Moodle is free software: you can redistribute it and/or modify 21 | + it under the terms of the GNU General Public License as published by 22 | + the Free Software Foundation, either version 3 of the License, or 23 | + (at your option) any later version. 24 | + 25 | + Moodle is distributed in the hope that it will be useful, 26 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | + GNU General Public License for more details. 29 | + 30 | + You should have received a copy of the GNU General Public License 31 | + along with Moodle. If not, see . 32 | +}} 33 | +{{! 34 | + @template core/linting_ok 35 | + 36 | + A test for for mustache linting tests. 37 | + 38 | + Classes required for JS: 39 | + * none 40 | + 41 | + Data attributes required for JS: 42 | + * none 43 | + 44 | + Context variables required for this template: 45 | + * message A cleaned string (use clean_text()) to display. 46 | + * extraclasses Additional classes to apply to the notification. 47 | + * closebutton Whether a close button should be displayed to dismiss the message. 48 | + * announce Whether the notification should be announced to screen readers. 49 | + 50 | + Example context (json): 51 | + { 52 | + "message": "Your pants are on fire!", 53 | + "closebutton": 1, 54 | + "announce": 1, 55 | + "extraclasses": "foo bar" 56 | + } 57 | +}} 58 | + 64 | +{{# js }} 65 | +require(['jquery', 'theme_bootstrapbase/bootstrap'], function($) { 66 | + // Setup closing of bootstrap alerts. 67 | + $().alert(); 68 | +}); 69 | +{{/ js }} 70 | -- 71 | 2.10.0 72 | 73 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-partials-loaded.patch: -------------------------------------------------------------------------------- 1 | From e5c0e94dde233f5bcf627980ef1afbe91f975a65 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Fri, 14 Oct 2016 12:25:22 +0100 4 | Subject: [PATCH] MDLSITE-4770 - A template to check that partial loading is 5 | working. 6 | 7 | --- 8 | .../templates/test_partial_loading.mustache | 22 +++++++++++++++++++ 9 | 1 file changed, 22 insertions(+) 10 | create mode 100644 blocks/lp/templates/test_partial_loading.mustache 11 | 12 | diff --git a/blocks/lp/templates/test_partial_loading.mustache b/blocks/lp/templates/test_partial_loading.mustache 13 | new file mode 100644 14 | index 00000000000..853d13ea79a 15 | --- /dev/null 16 | +++ b/blocks/lp/templates/test_partial_loading.mustache 17 | @@ -0,0 +1,22 @@ 18 | +{{! 19 | + @template block_lp/test_partial_loading 20 | + 21 | + A template for our lint test to check that partial loading is working. 22 | + 23 | + Classes required for JS: 24 | + * None 25 | + 26 | + Data attibutes required for JS: 27 | + * None 28 | + 29 | + Context variables required for this template: 30 | + * None 31 | + 32 | + Example context (json): { 33 | + "message": "Your pants are on fire!", 34 | + "closebutton": 1, 35 | + "announce": 1, 36 | + "extraclasses": "foo bar" 37 | + } 38 | +}} 39 | +{{> core/notification_info}} 40 | -- 41 | 2.40.0 42 | 43 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-quote_and_uniq.patch: -------------------------------------------------------------------------------- 1 | From 102f9eaa8ba06e42222291a0f7ab10d70d91e7db Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 2 Nov 2016 19:09:18 +0000 4 | Subject: [PATCH 1/1] MDL-12345: test quote helpers 5 | 6 | --- 7 | lib/templates/test_uniq_and_quote.mustache | 13 +++++++++++++ 8 | 1 file changed, 13 insertions(+) 9 | create mode 100644 lib/templates/test_uniq_and_quote.mustache 10 | 11 | diff --git a/lib/templates/test_uniq_and_quote.mustache b/lib/templates/test_uniq_and_quote.mustache 12 | new file mode 100644 13 | index 0000000..d157d8a 14 | --- /dev/null 15 | +++ b/lib/templates/test_uniq_and_quote.mustache 16 | @@ -0,0 +1,13 @@ 17 | +{{! 18 | + @template core/test_uniq_and_quote 19 | + 20 | + Example context (json): 21 | + { 22 | + "trickycontent": "Some content with \" in it" 23 | + } 24 | + 25 | +}} 26 | +
27 | + 28 | + 29 | +
30 | -- 31 | 2.10.0 32 | 33 | -------------------------------------------------------------------------------- /tests/fixtures/31-mustache_lint-theme_loading.patch: -------------------------------------------------------------------------------- 1 | From 05e34a539f00c89f9dc94bb695af4839b73b1f35 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 2 Nov 2016 12:17:41 +0000 4 | Subject: [PATCH 1/1] MDL-12345 mustache: fixture for theme loading 5 | 6 | --- 7 | .../bootstrapbase/templates/core_output/div-start.mustache | 1 + 8 | theme/bootstrapbase/templates/test-theme-loading.mustache | 13 +++++++++++++ 9 | 2 files changed, 14 insertions(+) 10 | create mode 100644 theme/bootstrapbase/templates/core_output/div-start.mustache 11 | create mode 100644 theme/bootstrapbase/templates/test-theme-loading.mustache 12 | 13 | diff --git a/theme/bootstrapbase/templates/core_output/div-start.mustache b/theme/bootstrapbase/templates/core_output/div-start.mustache 14 | new file mode 100644 15 | index 0000000..e54a273 16 | --- /dev/null 17 | +++ b/theme/bootstrapbase/templates/core_output/div-start.mustache 18 | @@ -0,0 +1 @@ 19 | +
20 | diff --git a/theme/bootstrapbase/templates/test-theme-loading.mustache b/theme/bootstrapbase/templates/test-theme-loading.mustache 21 | new file mode 100644 22 | index 0000000..57fd9f0 23 | --- /dev/null 24 | +++ b/theme/bootstrapbase/templates/test-theme-loading.mustache 25 | @@ -0,0 +1,13 @@ 26 | +{{! 27 | + @template theme_bootstrapbase/test.mustache 28 | + 29 | + A bit of a silly template to test that theme partials are being loaded. 30 | + 31 | + The partial 'core_output/div-start' doesn't exist in at 3.1.2, so this template 32 | + will only validate when we load from theme_bootstrapbase. 33 | + 34 | + Example context (json): {} 35 | +}} 36 | +{{> core_output/div-start}} 37 | +Hello World! 38 | +
39 | -- 40 | 2.10.0 41 | 42 | -------------------------------------------------------------------------------- /tests/fixtures/31-thirdparty-edgecase.patch: -------------------------------------------------------------------------------- 1 | From 195ecddb57a7d3ecdfade8eca852b188f8297e14 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Thu, 20 Jul 2017 12:57:30 +0100 4 | Subject: [PATCH 1/1] Test modification to non-thirdparty file 5 | 6 | --- 7 | lib/requirejs.php | 1 + 8 | 1 file changed, 1 insertion(+) 9 | 10 | diff --git a/lib/requirejs.php b/lib/requirejs.php 11 | index 7cc8d0f64c..53e372cb20 100644 12 | --- a/lib/requirejs.php 13 | +++ b/lib/requirejs.php 14 | @@ -21,6 +21,7 @@ 15 | * @copyright 2015 Damyon Wiese 16 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 17 | */ 18 | +// Test modification to non-thirdparty file 19 | 20 | // Disable moodle specific debug messages and any errors in output, 21 | // comment out when debugging or better look into error log! 22 | -- 23 | 2.13.3 24 | 25 | -------------------------------------------------------------------------------- /tests/fixtures/31-thirdparty-error.patch: -------------------------------------------------------------------------------- 1 | From 096f3a432dcc478a7277889dee49f46f833c39b5 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 15 Jun 2016 23:21:24 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4211 fixture: for thirdparty check 5 | 6 | This should be applied on top of v3.1.0 7 | --- 8 | lib/amd/src/mustache.js | 7 ------- 9 | 1 file changed, 7 deletions(-) 10 | 11 | diff --git a/lib/amd/src/mustache.js b/lib/amd/src/mustache.js 12 | index a3ce19e..1075fad 100644 13 | --- a/lib/amd/src/mustache.js 14 | +++ b/lib/amd/src/mustache.js 15 | @@ -25,13 +25,6 @@ 16 | // 17 | 18 | // Description of import into Moodle: 19 | -// Checkout from https://github.com/moodle/custom-mustache.js 20 | -// Rebase onto latest release tag from https://github.com/janl/mustache.js 21 | -// Copy mustache.js into lib/amd/src/ in Moodle folder. 22 | -// Add the license as a comment to the file and these instructions. 23 | -// Add jshint tags so this file is not linted. 24 | -// Remove the "global define:" comment (hint for linter) 25 | -// Make sure that you have not removed the custom code for '$' and '<'. 26 | 27 | /*! 28 | * mustache.js - Logic-less {{mustache}} templates with JavaScript 29 | -- 30 | 2.8.1 31 | 32 | -------------------------------------------------------------------------------- /tests/fixtures/31-thirdparty-ok.patch: -------------------------------------------------------------------------------- 1 | From c0805275c6a79422632d0fb10bd7fa9f518929a8 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 15 Jun 2016 23:21:24 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4211 fixture: OK thirdparty check 5 | 6 | This should be applied on top of v3.1.0 7 | --- 8 | lib/amd/src/mustache.js | 7 ------- 9 | lib/thirdpartylibs.xml | 2 +- 10 | 2 files changed, 1 insertion(+), 8 deletions(-) 11 | 12 | diff --git a/lib/amd/src/mustache.js b/lib/amd/src/mustache.js 13 | index a3ce19e..1075fad 100644 14 | --- a/lib/amd/src/mustache.js 15 | +++ b/lib/amd/src/mustache.js 16 | @@ -25,13 +25,6 @@ 17 | // 18 | 19 | // Description of import into Moodle: 20 | -// Checkout from https://github.com/moodle/custom-mustache.js 21 | -// Rebase onto latest release tag from https://github.com/janl/mustache.js 22 | -// Copy mustache.js into lib/amd/src/ in Moodle folder. 23 | -// Add the license as a comment to the file and these instructions. 24 | -// Add jshint tags so this file is not linted. 25 | -// Remove the "global define:" comment (hint for linter) 26 | -// Make sure that you have not removed the custom code for '$' and '<'. 27 | 28 | /*! 29 | * mustache.js - Logic-less {{mustache}} templates with JavaScript 30 | diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml 31 | index 6440a73..2779103 100644 32 | --- a/lib/thirdpartylibs.xml 33 | +++ b/lib/thirdpartylibs.xml 34 | @@ -261,7 +261,7 @@ 35 | amd/src/mustache.js 36 | Mustache.js 37 | MIT 38 | - 2.2.1 39 | + 2.2.2 40 | 41 | 42 | graphlib.php 43 | -- 44 | 2.8.1 45 | 46 | -------------------------------------------------------------------------------- /tests/fixtures/31-whitespace-error.patch: -------------------------------------------------------------------------------- 1 | From e85a153c0a41fdf85c1a8f2a4467647eabfc87d6 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 13 Jul 2016 17:25:47 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4685 whitespace: intoduce error 5 | 6 | Should be applied on top of v3.1.1 7 | --- 8 | config-dist.php | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/config-dist.php b/config-dist.php 12 | index 30d8c15..7be9f53 100644 13 | --- a/config-dist.php 14 | +++ b/config-dist.php 15 | @@ -28,7 +28,7 @@ 16 | // // 17 | /////////////////////////////////////////////////////////////////////////// 18 | unset($CFG); // Ignore this line 19 | -global $CFG; // This is necessary here for PHPUnit execution 20 | +global $CFG; // This is necessary here for PHPUnit execution 21 | $CFG = new stdClass(); 22 | 23 | //========================================================================= 24 | -- 25 | 2.9.0 26 | 27 | -------------------------------------------------------------------------------- /tests/fixtures/31-whitespace-upgradenotes.patch: -------------------------------------------------------------------------------- 1 | From d6a28ff1970f63efe4720a81c8feda8b22bdab0b Mon Sep 17 00:00:00 2001 2 | From: Andrew Nicols 3 | Date: Thu, 3 Oct 2024 23:35:55 +0800 4 | Subject: [PATCH 1/1] Ignore whitespace issues in upgradenotes 5 | 6 | --- 7 | .upgradenotes/MDL-81675-2024052916042539.yml | 13 +++++++++++++ 8 | 1 file changed, 13 insertions(+) 9 | create mode 100644 .upgradenotes/MDL-81675-2024052916042539.yml 10 | 11 | diff --git a/.upgradenotes/MDL-81675-2024052916042539.yml b/.upgradenotes/MDL-81675-2024052916042539.yml 12 | new file mode 100644 13 | index 0000000000..ed29757e0c 14 | --- /dev/null 15 | +++ b/.upgradenotes/MDL-81675-2024052916042539.yml 16 | @@ -0,0 +1,13 @@ 17 | +issueNumber: MDL-81675 18 | +notes: 19 | + core_course: 20 | + - message: >+ 21 | + - New optional `sectionNum` parameter has been added to `activitychooser` 22 | + AMD module initializer. 23 | + 24 | + - New option `sectionnum` parameter has been added to 25 | + `get_course_content_items()` external function. 26 | + 27 | + - New optional `sectionnum` parameter has been added to 28 | + `get_content_items_for_user_in_course()` function. 29 | + type: improved 30 | -- 31 | 2.42.0 32 | 33 | -------------------------------------------------------------------------------- /tests/fixtures/311-upgrade_external_backup-all-wrong.patch: -------------------------------------------------------------------------------- 1 | From ec9e0ca9392379c1ec7b4246fa354b20f1189278 Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Sun, 14 Nov 2021 16:47:31 +0100 4 | Subject: [PATCH] NOBUG fixture: ALL WRONG upgrade_external_backup check 5 | 6 | --- 7 | mod/forum/db/install.xml | 1 + 8 | mod/forum/db/upgrade.php | 14 ++++++++++++++ 9 | mod/forum/version.php | 2 +- 10 | 3 files changed, 16 insertions(+), 1 deletion(-) 11 | 12 | diff --git a/mod/forum/db/install.xml b/mod/forum/db/install.xml 13 | index bbda97aba99..666a3923ecf 100644 14 | --- a/mod/forum/db/install.xml 15 | +++ b/mod/forum/db/install.xml 16 | @@ -7,6 +7,7 @@ 17 | 18 | 19 | 20 | + 21 | 22 | 23 | 24 | diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php 25 | index 505be0aaf52..8a51613e0dd 100644 26 | --- a/mod/forum/db/upgrade.php 27 | +++ b/mod/forum/db/upgrade.php 28 | @@ -257,6 +257,20 @@ function xmldb_forum_upgrade($oldversion) { 29 | 30 | // Automatically generated Moodle v3.10.0 release upgrade line. 31 | // Put any upgrade step following this. 32 | + // 33 | + if ($oldversion < 2021051701) { 34 | + 35 | + // Define field bats to be added to forum. 36 | + $table = new xmldb_table('forum'); 37 | + $field = new xmldb_field('bats', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'bats', 'id'); 38 | + 39 | + // Conditionally launch add field wordcount. 40 | + if (!$dbman->field_exists($table, $field)) { 41 | + $dbman->add_field($table, $field); 42 | + } 43 | + 44 | + upgrade_mod_savepoint(true, 2021051701, 'forum'); 45 | + } 46 | 47 | return true; 48 | } 49 | diff --git a/mod/forum/version.php b/mod/forum/version.php 50 | index 44579728cc6..2ed37326f54 100644 51 | --- a/mod/forum/version.php 52 | +++ b/mod/forum/version.php 53 | @@ -24,6 +24,6 @@ 54 | 55 | defined('MOODLE_INTERNAL') || die(); 56 | 57 | -$plugin->version = 2021051700; // The current module version (Date: YYYYMMDDXX). 58 | +$plugin->version = 2021051701; // The current module version (Date: YYYYMMDDXX). 59 | $plugin->requires = 2021051100; // Requires this Moodle version. 60 | $plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics) 61 | -- 62 | 2.33.1 63 | 64 | -------------------------------------------------------------------------------- /tests/fixtures/35-thirdparty-lib-added.patch: -------------------------------------------------------------------------------- 1 | From 96ec9462a7d7a05f39af044020b63e371831ab05 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Tue, 12 Jul 2016 11:23:56 +0100 4 | Subject: [PATCH] MDLSITE-4678 fixture: adding third party lib 5 | 6 | --- 7 | lib/thirdpartylibs.xml | 6 ++++++ 8 | 1 file changed, 6 insertions(+) 9 | 10 | diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml 11 | index c14a3e01d4..ba719b5f84 100644 12 | --- a/lib/thirdpartylibs.xml 13 | +++ b/lib/thirdpartylibs.xml 14 | @@ -323,4 +323,10 @@ 15 | MIT 16 | 1.1.1 17 | 18 | + 19 | + integrationtest 20 | + Moodle Integration test for MDLSITE-4678 21 | + GPL 22 | + 2.3.0 23 | + 24 | 25 | -- 26 | 2.39.1 27 | 28 | -------------------------------------------------------------------------------- /tests/fixtures/39-grunt-js-unbuilt.patch: -------------------------------------------------------------------------------- 1 | From 7999a12d1839d17ab9ddaae20cf672ead09bd8bf Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Thu, 29 Sep 2022 09:40:38 +0200 4 | Subject: [PATCH] NOBUG fixture: unbuilt js change for grunt 5 | 6 | --- 7 | lib/amd/src/url.js | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/lib/amd/src/url.js b/lib/amd/src/url.js 11 | index 61dd56b85e8..0150c1dbfa4 100644 12 | --- a/lib/amd/src/url.js 13 | +++ b/lib/amd/src/url.js 14 | @@ -38,7 +38,7 @@ define(['jquery', 'core/config'], function($, config) { 15 | */ 16 | fileUrl: function(relativeScript, slashArg) { 17 | 18 | - var url = config.wwwroot + relativeScript; 19 | + var url = config.wwwroot + relativeScript + 'hey!'; 20 | 21 | // Force a / 22 | if (slashArg.charAt(0) != '/') { 23 | -- 24 | 2.37.2 25 | 26 | -------------------------------------------------------------------------------- /tests/fixtures/39-grunt-scss-unbuilt.patch: -------------------------------------------------------------------------------- 1 | From 4f1772815048e2177f8df4fd543db01babdc2a86 Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Thu, 29 Sep 2022 09:34:02 +0200 4 | Subject: [PATCH] NOBUG fixture: scss unbuilt for grunt tests 5 | 6 | --- 7 | theme/boost/scss/moodle/reports.scss | 3 +++ 8 | 1 file changed, 3 insertions(+) 9 | 10 | diff --git a/theme/boost/scss/moodle/reports.scss b/theme/boost/scss/moodle/reports.scss 11 | index 79289a17eee..edb83053744 100644 12 | --- a/theme/boost/scss/moodle/reports.scss 13 | +++ b/theme/boost/scss/moodle/reports.scss 14 | @@ -3,6 +3,9 @@ 15 | // The home for small tweaks to reports that don't require 16 | // changes drastic enough to pull in the full module css 17 | // and replace it completely. 18 | +.integrationcsschange { 19 | + display: none; 20 | +} 21 | 22 | #page-report-participation-index .participationselectform div label { // Using 'div' here to override the report styles.css 23 | display: inline-block; 24 | -- 25 | 2.37.2 26 | 27 | -------------------------------------------------------------------------------- /tests/fixtures/39-mustache_lint_plugins-ignores.patch: -------------------------------------------------------------------------------- 1 | From 02c7c121afe0cec8dacdb36ec5dd821ed92a15dc Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?David=20Mudr=C3=A1k?= 3 | Date: Mon, 7 Sep 2020 15:50:28 +0200 4 | Subject: [PATCH 2/2] Add .mustachelintignore to exclude files from HTML 5 | validation 6 | 7 | --- 8 | local/test/templates/.mustachelintignore | 2 ++ 9 | local/test/templates/local/mobile/.mustachelintignore | 3 +++ 10 | 2 files changed, 5 insertions(+) 11 | create mode 100644 local/test/templates/.mustachelintignore 12 | create mode 100644 local/test/templates/local/mobile/.mustachelintignore 13 | 14 | diff --git a/local/test/templates/.mustachelintignore b/local/test/templates/.mustachelintignore 15 | new file mode 100644 16 | index 0000000000..f2d6f7d6b4 17 | --- /dev/null 18 | +++ b/local/test/templates/.mustachelintignore 19 | @@ -0,0 +1,2 @@ 20 | +# Ignore all the mobile app templates. 21 | +mobile_*.mustache 22 | diff --git a/local/test/templates/local/mobile/.mustachelintignore b/local/test/templates/local/mobile/.mustachelintignore 23 | new file mode 100644 24 | index 0000000000..379d827608 25 | --- /dev/null 26 | +++ b/local/test/templates/local/mobile/.mustachelintignore 27 | @@ -0,0 +1,3 @@ 28 | +# Ignore all the templates here. 29 | + 30 | +*.mustache 31 | -- 32 | 2.26.2 33 | 34 | -------------------------------------------------------------------------------- /tests/fixtures/402-mustache_lint-str.patch: -------------------------------------------------------------------------------- 1 | From d64cf216e6f0cdfed617b538fde5b4e193e7da88 Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Tue, 11 Jul 2023 15:16:18 +0200 4 | Subject: [PATCH] MDL-12345: test str helper 5 | 6 | --- 7 | lib/templates/test_str.mustache | 11 +++++++++++ 8 | 1 file changed, 11 insertions(+) 9 | create mode 100644 lib/templates/test_str.mustache 10 | 11 | diff --git a/lib/templates/test_str.mustache b/lib/templates/test_str.mustache 12 | new file mode 100644 13 | index 00000000000..cb7a906deb9 14 | --- /dev/null 15 | +++ b/lib/templates/test_str.mustache 16 | @@ -0,0 +1,11 @@ 17 | +{{! 18 | + @template core/test_str 19 | + 20 | + Example context (json): 21 | + { 22 | + } 23 | + 24 | +}} 25 | +

{{#str}} string, component {{/str}}

26 | + 27 | +Link 28 | -- 29 | 2.40.0 30 | 31 | -------------------------------------------------------------------------------- /tests/fixtures/402-php_lint-bad.patch: -------------------------------------------------------------------------------- 1 | From dbe6c7fffdbb08918094540289bf6c1365f161cc Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Fri, 4 Aug 2023 08:28:39 +0200 4 | Subject: [PATCH] MDLSITE-4211 fixture: for php_lint tests 5 | 6 | This should be applied on top of v4.1.0 7 | --- 8 | lib/moodlelib.php | 1 + 9 | 1 file changed, 1 insertion(+) 10 | 11 | diff --git a/lib/moodlelib.php b/lib/moodlelib.php 12 | index 7b7e462219..56ffe31218 100644 13 | --- a/lib/moodlelib.php 14 | +++ b/lib/moodlelib.php 15 | @@ -10882,6 +10882,7 @@ class lang_string { 16 | $this->forcedstring = true; 17 | return array('forcedstring', 'string', 'lang'); 18 | } 19 | +die('oh this is gonna be a problem! 20 | 21 | /** 22 | * Returns the identifier. 23 | -- 24 | 2.40.0 25 | 26 | -------------------------------------------------------------------------------- /tests/fixtures/402-php_lint-ok.patch: -------------------------------------------------------------------------------- 1 | From c6385705362f492fab3dc90cf5317e372fef60c8 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Wed, 15 Jun 2016 22:51:00 +0100 4 | Subject: [PATCH 1/1] MDLSITE-4211 OK fixture: for php_lint tests 5 | 6 | This should be applied on top of v4.1.0 7 | --- 8 | lib/moodlelib.php | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/lib/moodlelib.php b/lib/moodlelib.php 12 | index 8160f89..c7cadf2 100644 13 | --- a/lib/moodlelib.php 14 | +++ b/lib/moodlelib.php 15 | @@ -9321,7 +9321,7 @@ function object_array_unique($array, $keepkeyassoc = true) { 16 | * @return boolean 17 | */ 18 | function is_primary_admin($userid) { 19 | - $primaryadmin = get_admin(); 20 | + $primaryadmin = get_admin(); 21 | 22 | if ($userid == $primaryadmin->id) { 23 | return true; 24 | -- 25 | 2.8.1 26 | 27 | -------------------------------------------------------------------------------- /tests/fixtures/402-php_lint-vendor.patch: -------------------------------------------------------------------------------- 1 | From d453b3f9d588c8d8355cfcc25a843c68d2afea0a Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Thu, 24 Sep 2020 13:10:01 +0200 4 | Subject: [PATCH] Fixture for php_lint vendor tests 5 | 6 | --- 7 | lib/vendor/test.php | 3 +++ 8 | vendor/test.php | 3 +++ 9 | 2 files changed, 6 insertions(+) 10 | create mode 100644 lib/vendor/test.php 11 | create mode 100644 vendor/test.php 12 | 13 | diff --git a/lib/vendor/test.php b/lib/vendor/test.php 14 | new file mode 100644 15 | index 0000000000..d075f480b6 16 | --- /dev/null 17 | +++ b/lib/vendor/test.php 18 | @@ -0,0 +1,3 @@ 19 | + 3 | Date: Sat, 30 Jul 2016 20:34:13 +0100 4 | Subject: [PATCH 1/1] blank upgrade file 5 | 6 | --- 7 | admin/tool/messageinbound/db/upgrade.php | 4 ++++ 8 | 1 file changed, 4 insertions(+) 9 | create mode 100644 admin/tool/messageinbound/db/upgrade.php 10 | 11 | diff --git a/admin/tool/messageinbound/db/upgrade.php b/admin/tool/messageinbound/db/upgrade.php 12 | new file mode 100644 13 | index 0000000..c768782 14 | --- /dev/null 15 | +++ b/admin/tool/messageinbound/db/upgrade.php 16 | @@ -0,0 +1,4 @@ 17 | + 3 | Date: Sat, 30 Jul 2016 20:54:30 +0100 4 | Subject: [PATCH 1/1] if without savepoint 5 | 6 | --- 7 | lib/db/upgrade.php | 2 -- 8 | 1 file changed, 2 deletions(-) 9 | 10 | diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php 11 | index ee468b6..1512804 100644 12 | --- a/lib/db/upgrade.php 13 | +++ b/lib/db/upgrade.php 14 | @@ -2049,8 +2049,6 @@ function xmldb_main_upgrade($oldversion) { 15 | // Add a default competency rating scale. 16 | make_competence_scale(); 17 | 18 | - // Savepoint reached. 19 | - upgrade_main_savepoint(true, 2016051300.00); 20 | } 21 | 22 | if ($oldversion < 2016051700.01) { 23 | -- 24 | 2.9.0 25 | 26 | -------------------------------------------------------------------------------- /tests/fixtures/check_upgrade_savepoints/multiple_return.patch: -------------------------------------------------------------------------------- 1 | From 6015aacb1810c0066bbca35913d264919854b20e Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Sat, 30 Jul 2016 20:50:55 +0100 4 | Subject: [PATCH 1/1] multiple return statements 5 | 6 | --- 7 | portfolio/googledocs/db/upgrade.php | 1 + 8 | 1 file changed, 1 insertion(+) 9 | 10 | diff --git a/portfolio/googledocs/db/upgrade.php b/portfolio/googledocs/db/upgrade.php 11 | index c02c769..93402d4 100644 12 | --- a/portfolio/googledocs/db/upgrade.php 13 | +++ b/portfolio/googledocs/db/upgrade.php 14 | @@ -23,6 +23,7 @@ defined('MOODLE_INTERNAL') || die(); 15 | function xmldb_portfolio_googledocs_upgrade($oldversion) { 16 | global $CFG; 17 | 18 | + return true; 19 | // Moodle v2.8.0 release upgrade line. 20 | // Put any upgrade step following this. 21 | 22 | -- 23 | 2.9.0 24 | 25 | -------------------------------------------------------------------------------- /tests/fixtures/check_upgrade_savepoints/no_return_statement.patch: -------------------------------------------------------------------------------- 1 | From b11edea305738091fdd5a4468585d7f87dc69185 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Sat, 30 Jul 2016 20:46:05 +0100 4 | Subject: [PATCH 1/1] no return statement 5 | 6 | --- 7 | mod/quiz/db/upgrade.php | 1 - 8 | 1 file changed, 1 deletion(-) 9 | 10 | diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php 11 | index f42c007..42765c2 100644 12 | --- a/mod/quiz/db/upgrade.php 13 | +++ b/mod/quiz/db/upgrade.php 14 | @@ -193,5 +193,4 @@ function xmldb_quiz_upgrade($oldversion) { 15 | // Moodle v3.1.0 release upgrade line. 16 | // Put any upgrade step following this. 17 | 18 | - return true; 19 | } 20 | -- 21 | 2.9.0 22 | 23 | -------------------------------------------------------------------------------- /tests/fixtures/check_upgrade_savepoints/out_of_order.patch: -------------------------------------------------------------------------------- 1 | From ff426281a36654a6b5b60dfe7726bed41bb77100 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Sat, 30 Jul 2016 20:59:34 +0100 4 | Subject: [PATCH 1/1] Out of order savepoints 5 | 6 | --- 7 | mod/assign/db/upgrade.php | 19 ++++++++++--------- 8 | 1 file changed, 10 insertions(+), 9 deletions(-) 9 | 10 | diff --git a/mod/assign/db/upgrade.php b/mod/assign/db/upgrade.php 11 | index c0935c5..921b0f6 100644 12 | --- a/mod/assign/db/upgrade.php 13 | +++ b/mod/assign/db/upgrade.php 14 | @@ -34,15 +34,6 @@ function xmldb_assign_upgrade($oldversion) { 15 | 16 | $dbman = $DB->get_manager(); 17 | 18 | - if ($oldversion < 2014051201) { 19 | - 20 | - // Cleanup bad database records where assignid is missing. 21 | - 22 | - $DB->delete_records('assign_user_mapping', array('assignment'=>0)); 23 | - // Assign savepoint reached. 24 | - upgrade_mod_savepoint(true, 2014051201, 'assign'); 25 | - } 26 | - 27 | if ($oldversion < 2014072400) { 28 | 29 | // Add "latest" column to submissions table to mark the latest attempt. 30 | @@ -57,6 +48,16 @@ function xmldb_assign_upgrade($oldversion) { 31 | // Assign savepoint reached. 32 | upgrade_mod_savepoint(true, 2014072400, 'assign'); 33 | } 34 | + 35 | + if ($oldversion < 2014051201) { 36 | + 37 | + // Cleanup bad database records where assignid is missing. 38 | + 39 | + $DB->delete_records('assign_user_mapping', array('assignment'=>0)); 40 | + // Assign savepoint reached. 41 | + upgrade_mod_savepoint(true, 2014051201, 'assign'); 42 | + } 43 | + 44 | if ($oldversion < 2014072401) { 45 | 46 | // Define index latestattempt (not unique) to be added to assign_submission. 47 | -- 48 | 2.9.0 49 | 50 | -------------------------------------------------------------------------------- /tests/fixtures/check_upgrade_savepoints/repeated_savepoint.patch: -------------------------------------------------------------------------------- 1 | From 9c2d7f3f29d70392b53d067d0397df4e6c6a4d31 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Sat, 30 Jul 2016 20:31:14 +0100 4 | Subject: [PATCH 1/1] Repeated savepoint call 5 | 6 | --- 7 | lib/db/upgrade.php | 1 + 8 | 1 file changed, 1 insertion(+) 9 | 10 | diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php 11 | index ee468b6..a6ddf67 100644 12 | --- a/lib/db/upgrade.php 13 | +++ b/lib/db/upgrade.php 14 | @@ -2067,6 +2067,7 @@ function xmldb_main_upgrade($oldversion) { 15 | } 16 | // Main savepoint reached. 17 | upgrade_main_savepoint(true, 2016051700.01); 18 | + upgrade_main_savepoint(true, 2016051700.01); 19 | } 20 | 21 | // Moodle v3.1.0 release upgrade line. 22 | -- 23 | 2.9.0 24 | 25 | -------------------------------------------------------------------------------- /tests/fixtures/check_upgrade_savepoints/returning_bool.patch: -------------------------------------------------------------------------------- 1 | From 2316d2cae62f8f8e63fe4be5bebdc8a15f5045d5 Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Wed, 13 Jan 2021 17:21:41 +0100 4 | Subject: [PATCH] Return type hint in xmldb upgrade functions 5 | 6 | --- 7 | lib/db/upgrade.php | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php 11 | index 685de9e34da..73493473b6e 100644 12 | --- a/lib/db/upgrade.php 13 | +++ b/lib/db/upgrade.php 14 | @@ -84,7 +84,7 @@ defined('MOODLE_INTERNAL') || die(); 15 | * @param int $oldversion 16 | * @return bool always true 17 | */ 18 | -function xmldb_main_upgrade($oldversion) { 19 | +function xmldb_main_upgrade($oldversion): bool { 20 | global $CFG, $DB; 21 | 22 | require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions. 23 | -- 24 | 2.30.0 25 | 26 | -------------------------------------------------------------------------------- /tests/fixtures/check_upgrade_savepoints/too_high_savepoint.patch: -------------------------------------------------------------------------------- 1 | From 759377f2f8e235ee37c71f8ac789a4a88444e0c0 Mon Sep 17 00:00:00 2001 2 | From: "Eloy Lafuente (stronk7)" 3 | Date: Fri, 29 Sep 2017 00:56:54 +0200 4 | Subject: [PATCH] Too high versions in savepoints 5 | 6 | --- 7 | mod/assign/db/upgrade.php | 8 ++++++++ 8 | 1 file changed, 8 insertions(+) 9 | 10 | diff --git a/mod/assign/db/upgrade.php b/mod/assign/db/upgrade.php 11 | index c0935c5a21..72c5f823ba 100644 12 | --- a/mod/assign/db/upgrade.php 13 | +++ b/mod/assign/db/upgrade.php 14 | @@ -200,5 +200,13 @@ function xmldb_assign_upgrade($oldversion) { 15 | // Moodle v3.1.0 release upgrade line. 16 | // Put any upgrade step following this. 17 | 18 | + if ($oldversion < 2017022300) { 19 | + 20 | + // v3.1.1 is 2016052300, hardly can accept anything higher than that 21 | + 22 | + // Assign savepoint reached. 23 | + upgrade_mod_savepoint(true, 2017022300, 'assign'); 24 | + } 25 | + 26 | return true; 27 | } 28 | -- 29 | 2.14.1 30 | 31 | -------------------------------------------------------------------------------- /tests/fixtures/check_upgrade_savepoints/wrong_savepoint_version.patch: -------------------------------------------------------------------------------- 1 | From d2e570acddbf7d9270fb12f60df455e6d95e1f60 Mon Sep 17 00:00:00 2001 2 | From: Dan Poltawski 3 | Date: Sat, 30 Jul 2016 20:56:34 +0100 4 | Subject: [PATCH 1/1] incorrect savepoint version 5 | 6 | --- 7 | mod/lesson/db/upgrade.php | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/mod/lesson/db/upgrade.php b/mod/lesson/db/upgrade.php 11 | index ca0e48b..7342f5b 100644 12 | --- a/mod/lesson/db/upgrade.php 13 | +++ b/mod/lesson/db/upgrade.php 14 | @@ -382,7 +382,7 @@ function xmldb_lesson_upgrade($oldversion) { 15 | } 16 | 17 | // Lesson savepoint reached. 18 | - upgrade_mod_savepoint(true, 2016012800, 'lesson'); 19 | + upgrade_mod_savepoint(true, 2016011800, 'lesson'); 20 | } 21 | // Moodle v3.1.0 release upgrade line. 22 | // Put any upgrade step following this. 23 | -- 24 | 2.9.0 25 | 26 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/commits-info.txt: -------------------------------------------------------------------------------- 1 | b21c515*info*AMOS - String to be copied: searchengine/admin to type_search/plugin 2 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/commits-info.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/commits.txt: -------------------------------------------------------------------------------- 1 | 6733d12*error*The commit message does not begin with the expected issue code MDL-[0-9]{3,6} and a space. 2 | 6733d12*error*The commit message does not contain the expected issue code MDL-55061 and a space. 3 | ee73cbd*warning*The commit message does not define a code area ending with a colon and a space after the issue code. 4 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/commits.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/gherkinlint_err.txt: -------------------------------------------------------------------------------- 1 | [{"filePath":"/admin/tool/behat/tests/fixtures/core/test_2.feature","errors":[]},{"filePath":"/admin/tool/behat/tests/fixtures/theme/withfeatures/theme_test_1.feature","errors":[{"message":"Wrong indentation for \"given\", expected indentation level of 4, but got 6","rule":"indentation","line":9},{"message":"Wrong indentation for \"given\", expected indentation level of 4, but got 6","rule":"indentation","line":10}]},{"filePath":"/admin/tool/behat/tests/fixtures/theme/withfeatures/theme_test_2.feature","errors":[{"message":"Feature name is already used in: admin/tool/behat/tests/fixtures/core/test_2.feature","rule":"no-dupe-feature-names","line":2}]},{"filePath":"/admin/tool/capability/tests/behat/show_capabilies.feature","errors":[]},{"filePath":"/admin/tool/task/tests/behat/clear_fail_delay.feature","errors":[{"message":"Multiple empty lines are not allowed","rule":"no-multiple-empty-lines","line":26}]},{"filePath":"/admin/tool/task/tests/behat/manage_tasks.feature","errors":[]}] 2 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/gherkinlint_err.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/gherkinlint_ok.txt: -------------------------------------------------------------------------------- 1 | [{"filePath":"/mod/glossary/tests/behat/categories.feature","errors":[]},{"filePath":"/mod/glossary/tests/behat/edit_tags.feature","errors":[]},{"filePath":"/mod/glossary/tests/behat/entries_always_editable.feature","errors":[]},{"filePath":"/mod/glossary/tests/behat/entries_require_approval.feature","errors":[]},{"filePath":"/mod/glossary/tests/behat/import_entries.feature","errors":[]},{"filePath":"/mod/glossary/tests/behat/prevent_duplicate_entries.feature","errors":[]},{"filePath":"/mod/glossary/tests/behat/print_friendly_version.feature","errors":[]},{"filePath":"/mod/glossary/tests/behat/search_entries.feature","errors":[]}] 2 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/gherkinlint_ok.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/grunt-build-failed.txt: -------------------------------------------------------------------------------- 1 | Running "startup" task 2 | 3 | Running "stylelint:scss" (stylelint) task 4 | >> Linted 117 files without errors 5 | 6 | Running "stylelint:less" (stylelint) task 7 | >> theme/bootstrapbase/less/moodle/modules.less 8 | >> 15:1 ✖ Expected indentation of 4 spaces indentation 9 | Warning: Task "stylelint:less" failed. Use --force to continue. 10 | 11 | Aborted due to warnings. 12 | ERROR: Problems running grunt 13 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/grunt-build-failed.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/grunt-errors.txt: -------------------------------------------------------------------------------- 1 | shifter [err] /var/lib/jenkins/git_repositories/prechecker/lib/editor/atto/plugins/image/yui/src/button/js/button.js contains 2 lint errors 2 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/grunt.txt: -------------------------------------------------------------------------------- 1 | Running "startup" task 2 | 3 | Running "less:bootstrapbase" (less) task 4 | >> 2 stylesheets created. 5 | 6 | Running "eslint:amd" (eslint) task 7 | 8 | Running "uglify:amd" (uglify) task 9 | >> 90 files created. 10 | 11 | Running "eslint:yui" (eslint) task 12 | 13 | Running "shifter" task 14 | >> Running shifter on /var/lib/jenkins/git_repositories/prechecker 15 | shifter [info] racing to find the closest .shifter.json file 16 | shifter [info] woohoo, found a config here: /var/lib/jenkins/git_repositories/prechecker/.shifter.json 17 | shifter [info] override config found for coverage 18 | shifter [info] override config found for lint 19 | shifter [info] override config found for clean 20 | shifter [info] revving up 21 | shifter [info] racing the directories 22 | shifter [info] found 105 modules to race, let's do this 23 | shifter [warn] this will be quiet, only status will be emitted for speed. failed builds will print after 24 | ......................................................................................................... 25 | shifter [info] done racing, the gears are toast 26 | shifter [info] finished in 37.059 seconds, pretty fast huh? 27 | >> Shifter build complete. 28 | 29 | Running "ignorefiles" task 30 | 31 | Done. 32 | 33 | WARN: Some modules are not properly processed by grunt. Changes detected: 34 | 35 | GRUNT-CHANGE: /var/lib/jenkins/git_repositories/prechecker/lib/editor/atto/yui/build/editor/js/autosave.min.js 36 | GRUNT-CHANGE: /var/lib/jenkins/git_repositories/prechecker/lib/yui/build/event/js/event.min.js 37 | GRUNT-CHANGE: /var/lib/jenkins/git_repositories/prechecker/lib/yui/build/formchangechecker/js/formchangechecker.min.js 38 | GRUNT-CHANGE: /var/lib/jenkins/git_repositories/prechecker/mod/assign/amd/build/grading_panel.min.js 39 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/grunt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/fixtures/checkstyle/mustachelint.txt: -------------------------------------------------------------------------------- 1 | Running mustache lint from f54a16fc738153a0b1bf766e7440d3655321a821 to 6b5d0e976a85dfdc1d978ceb2800dc0cb3f9a58d: 2 | /Users/danp/www/im/message/output/popup/templates/message_popover.mustache - ERROR: Mustache syntax exception: Nesting error: core/popover_region (on line 2) vs. classes (on line 3) 3 | /Users/danp/www/im/message/templates/message_area_contacts.mustache - WARNING: Example context missing. 4 | /Users/danp/www/im/message/templates/message_area_contacts_area.mustache - WARNING: Example context missing. 5 | /Users/danp/www/im/message/templates/message_area_contacts_area.mustache - WARNING: HTML Validation error, line 15: An element with “role=tab” must be contained in, or owned by, an element with “role=tablist”. (abs">