15 |
16 |
17 |
--------------------------------------------------------------------------------
/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/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/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-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 |
--------------------------------------------------------------------------------
/tracker_automations/check_marked_as_integrated/util.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | # Checks if any commit from $2 issue is present in the specified major branch.
6 | # (since last roll happened, aka, since upstream last commit)
7 | function check_issue () {
8 | # Fetch the equivalent moodle.git branch (from where we are looking for existing commits).
9 | if ! $(${1} fetch -q git://git.moodle.org/moodle.git ${3#"origin/"}); then
10 | echo " WARNING: moodle.git ${3#"origin/"} fetching problems, cannot look for commits. Please check if that's correct."
11 | return 0
12 | fi
13 | if [[ -z $( ${1} log --grep "${2}" --pretty=oneline --abbrev-commit FETCH_HEAD...${3} ) ]]; then
14 | # If the 2 branch heads (moodle.git and integration.git are exactly the same... it means that
15 | # we have just rolled. In those cases, we give the integrator up to 60 minutes to proceed to
16 | # close the issues. After then, proceed normally, no commits found means error.
17 | if [[ "$( ${1} rev-parse FETCH_HEAD )" == "$( ${1} rev-parse ${3} )" ]]; then
18 | if [[ -n $( ${1} log --pretty=oneline --abbrev-commit --after='60 minutes ago' FETCH_HEAD ) ]]; then
19 | return 0
20 | fi
21 | fi
22 | # Arrived here, it's a problem, commit is missing.
23 | return 1
24 | fi
25 | return 0
26 | }
27 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/version.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * CI scripts version information
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 | $plugin->version = 2022093000;
28 | $plugin->requires = 2019111800; // Moodle 3.8.0 (Build 20191118) and upwards.
29 | $plugin->dependencies = array( // Also requires these plugins to be installed.
30 | 'local_moodlecheck' => '2012011000',
31 | );
32 | $plugin->component = 'local_ci';
33 | $plugin->release = '0.9.2';
34 | $plugin->maturity = MATURITY_BETA;
35 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tests/setup.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load libs/shared_setup
4 |
5 | @test "Git is setup for tests." {
6 | [ -d "$gitdir/.git" ];
7 | assert_success
8 | }
9 |
10 | @test "phpcs standard path is properly set" {
11 | run [ -f "$LOCAL_CI_TESTS_PHPCS_DIR/ruleset.xml" ];
12 | assert_success
13 | }
14 |
15 | @test "phpcs is properly installed" {
16 | phpcs=$BATS_TEST_DIRNAME/../vendor/bin/phpcs
17 |
18 | run [ -x $phpcs ]
19 | assert_success
20 |
21 | run $phpcs --version
22 | assert_output --regexp "PHP_CodeSniffer version [0-9]+\.[0-9]+\.[0-9]+ \(stable\) by Squiz and PHPCSStandards"
23 | }
24 |
25 | @test "GNU grep installed" {
26 | # Some scripts depend on grep -P
27 | echo 'test2' | grep -P '^(test\d|testing)$'
28 | assert_success
29 | }
30 |
31 | @test "GNU sed installed" {
32 | # Some scripts depend on sed -r
33 | echo 'test1' | sed -r 's/^test[0-9]$/replaced/'
34 | assert_success
35 | }
36 |
37 | @test "GNU wc installed" {
38 | # Some scripts depend on wc -l having no padding..
39 | run bash -c "echo '1' | wc -l"
40 | assert_success
41 | assert_output '1'
42 | }
43 |
44 | @test "GNU date installed" {
45 | # Some scripts depend on date -I for iso date
46 | run date -I
47 | assert_success
48 | }
49 |
50 | @test "moodle.git short sha length is expected one" {
51 | # Some scripts depend on it being 10
52 | run bash -c "cd $gitdir && git rev-list --all --abbrev=0 --abbrev-commit | wc -L"
53 | assert_success
54 | assert_output '10'
55 | }
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CI local plugin
2 |
3 | [](https://github.com/moodlehq/moodle-local_ci/actions/workflows/ci.yml) [](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 |
--------------------------------------------------------------------------------
/tests/fixtures/versions_check_set/short_array_syntax.patch:
--------------------------------------------------------------------------------
1 | From 96f06391aee02665b9aada9eabe43910d0f79063 Mon Sep 17 00:00:00 2001
2 | From: "Eloy Lafuente (stronk7)"
3 | Date: Fri, 22 Mar 2019 19:51:56 +0100
4 | Subject: [PATCH] Using short arrays syntax (1 and multiline)
5 |
6 | ---
7 | filter/data/version.php | 2 +-
8 | question/type/calculatedmulti/version.php | 4 ++--
9 | 2 files changed, 3 insertions(+), 3 deletions(-)
10 |
11 | diff --git a/filter/data/version.php b/filter/data/version.php
12 | index 6a662d442b..170a9c8a2d 100644
13 | --- a/filter/data/version.php
14 | +++ b/filter/data/version.php
15 | @@ -29,4 +29,4 @@ $plugin->version = 2016052300;
16 | $plugin->requires = 2016051900; // Requires this Moodle version.
17 | $plugin->component= 'filter_data';
18 |
19 | -$plugin->dependencies = array('mod_data' => 2016051900);
20 | +$plugin->dependencies = ['mod_data' => 2016051900];
21 | diff --git a/question/type/calculatedmulti/version.php b/question/type/calculatedmulti/version.php
22 | index 5d6ad23026..1449c9ae19 100644
23 | --- a/question/type/calculatedmulti/version.php
24 | +++ b/question/type/calculatedmulti/version.php
25 | @@ -29,10 +29,10 @@ $plugin->component = 'qtype_calculatedmulti';
26 | $plugin->version = 2016052300;
27 |
28 | $plugin->requires = 2016051900;
29 | -$plugin->dependencies = array(
30 | +$plugin->dependencies = [
31 | 'qtype_numerical' => 2016051900,
32 | 'qtype_calculated' => 2016051900,
33 | 'qtype_multichoice' => 2016051900,
34 | -);
35 | +];
36 |
37 | $plugin->maturity = MATURITY_STABLE;
38 | --
39 | 2.20.1
40 |
41 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tests/fixtures/remote_branch_reporter/MDL-54987/eslint.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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="Automated test results"
10 | customfield_componentLeadReview="Component Lead Review"
11 | customfield_currentlyInIntegration="Currently in integration"
12 | customfield_integrationDate="Integration date"
13 | customfield_integrationPriority="Integration priority"
14 | customfield_integrator="Integrator"
15 | customfield_pullFromRepository="Pull from Repository"
16 | customfield_tester="Tester"
17 |
18 |
19 | filter_candidatesForCLR="Weekly: Candidates for CLR (not held)"
20 | filter_candidatesForIntegration="Weekly: Candidates for Integration (not held)"
21 | filter_integrationCLRDecision="Weekly: Issues to decide between IR/CLR"
22 | filter_issuesHeldUntilAfterRelease="Issues agreed to be after release"
23 | filter_issuesVotedToUnhold="Issues that have been voted for unhold"
24 | filter_issuesWaitingForReviewOrInProgress="Integration: Current queue for issues waiting for review or review in progress"
25 | filter_mustFixIssues="All \"must-fix\" issues"
26 |
27 | # Verify everything is set
28 | required="jiraclicmd jiraserver jirauser jirapass"
29 | for var in $required; do
30 | if [ -z "${!var}" ]; then
31 | echo "Error: ${var} environment variable is not defined. See the script comments."
32 | exit 1
33 | fi
34 | done
35 |
36 | # Set the base request command.
37 | basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
38 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tracker_automations/bulk_precheck_issues/util.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 |
4 | # Generates tracker code for positive emotion
5 | function positive_tracker_emoticon() {
6 | local rand=$[ RANDOM % 2]
7 | # Only do fun stuff 1/3 of the time:
8 | if [[ $rand -eq 0 ]]
9 | then
10 | image=$(get_happy_image)
11 | echo "${image}"
12 | else
13 | echo '(y)'
14 | fi
15 | }
16 |
17 | # Generates tracker comment code for negative emotion
18 | function negative_tracker_emoticon() {
19 | local rand=$[ RANDOM % 5]
20 | # Only do fun stuff 1/6 of the time:
21 | if [[ $rand -eq 0 ]]
22 | then
23 | image=$(get_sad_image)
24 | echo "${image}"
25 | else
26 | echo '(n)'
27 | fi
28 | }
29 |
30 |
31 | function get_happy_image() {
32 | # smiling face with halo 😇
33 | images[0]='😇'
34 | # balloon🎈
35 | images[1]='🎈'
36 | # party popper 🎉
37 | images[2]='🎉'
38 | # clinking beer mugs 🍻
39 | images[3]='🍻'
40 | # cookie 🍪
41 | images[4]='🍪'
42 | # cake 🍰
43 | images[5]='🍰'
44 | # glowing star 🌟
45 | images[6]='🌟'
46 |
47 | index=$[$RANDOM % ${#images[@]}]
48 | echo ${images[$index]}
49 | }
50 |
51 | function get_sad_image() {
52 | # fire 🔥
53 | images[0]='🔥'
54 | # pile of poo 💩
55 | images[1]='💩'
56 | # speak-no-evil monkey 🙊
57 | images[2]='🙊'
58 | # bug 🐜
59 | images[3]='🐜'
60 | # face screaming in fear 😱
61 | images[4]='😱'
62 | # construction sign 🚧
63 | images[5]='🚧'
64 | # sos 🆘
65 | images[6]='🆘'
66 | # skull 💀
67 | images[7]='💀'
68 |
69 | index=$[$RANDOM % ${#images[@]}]
70 | echo ${images[$index]}
71 | }
72 |
--------------------------------------------------------------------------------
/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">
)
6 | /Users/danp/www/im/message/templates/message_area_contacts_area.mustache - WARNING: HTML Validation error, line 19: An element with “role=tab” must be contained in, or owned by, an element with “role=tablist”. (/div>
)
7 | /Users/danp/www/im/message/templates/message_area_messages_area.mustache - WARNING: Example context missing.
8 | /Users/danp/www/im/message/templates/message_area_profile.mustache - WARNING: Example context missing.
9 | /Users/danp/www/im/message/templates/message_area_profile.mustache - WARNING: HTML Validation error, line 9: Bad value “” for attribute “src” on element “img”: Must be non-empty. (> )
10 | Mustache lint problems found
11 |
--------------------------------------------------------------------------------
/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/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/remote_branch_checker/local_ci_fixture_stylelint.regex:
--------------------------------------------------------------------------------
1 | # Add here as many extended regular expressions (one by line)
2 | # that match the most relevant aspects of the test being executed
3 | # and its smurf.xml results.
4 |
5 | # For this, we are using full xml fragments (elements), but that's not
6 | # needed, in any case, the test uses all them as regex, line by line. Always.
7 |
8 | <\?xml version="1.0"\?>
9 |
10 |
11 |
12 | This section shows CSS problems detected by stylelint
14 |
15 |
16 | Expected "#EEE" to be "#eee" \(color-hex-case\)
17 | Expected single space after ":" with a single-line declaration \(declaration-colon-space-after\)
18 | Expected newline before "}" \(block-closing-brace-newline-before\)
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tests/thirdparty_check.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 | @test "thirdparty_check: thirdpartyfile modified OK" {
10 | git_apply_fixture 31-thirdparty-ok.patch
11 | export initialcommit=$FIXTURE_HASH_BEFORE
12 | export finalcommit=$FIXTURE_HASH_AFTER
13 |
14 | ci_run thirdparty_check/thirdparty_check.sh
15 | assert_success
16 | assert_output --partial "INFO: Checking for third party modifications from $initialcommit to $finalcommit"
17 | assert_output --partial "INFO: Detected third party modification in lib/amd/src/mustache.js"
18 | assert_output --partial "INFO: OK lib/thirdpartylibs.xml modified"
19 | refute_output --partial "WARN:"
20 | }
21 |
22 | @test "thirdparty_check: thirdpartyfile modified without update" {
23 | git_apply_fixture 31-thirdparty-error.patch
24 | export initialcommit=$FIXTURE_HASH_BEFORE
25 | export finalcommit=$FIXTURE_HASH_AFTER
26 |
27 | ci_run thirdparty_check/thirdparty_check.sh
28 | assert_success # TODO, this should be fixed!
29 | assert_output --partial "INFO: Checking for third party modifications from $initialcommit to $finalcommit"
30 | assert_output --partial "INFO: Detected third party modification in lib/amd/src/mustache.js"
31 | assert_output --partial "WARN: modification to third party library (lib/amd/src/mustache.js) without update to lib/thirdpartylibs.xml or lib/amd/src/readme_moodle.txt"
32 | }
33 |
34 | @test "thirdparty_check: lib/requirejs.php edgecase" {
35 | # Test case for lib/requirejs.php which isn't in folder lib/requirejs/
36 | git_apply_fixture 31-thirdparty-edgecase.patch
37 | export initialcommit=$FIXTURE_HASH_BEFORE
38 | export finalcommit=$FIXTURE_HASH_AFTER
39 |
40 | ci_run thirdparty_check/thirdparty_check.sh
41 | assert_success
42 | refute_output --partial "WARN:"
43 | assert_output "INFO: Checking for third party modifications from $initialcommit to $finalcommit"
44 | }
45 |
--------------------------------------------------------------------------------
/tracker_automations/remove_ci_label_from_wip/remove_ci_label_from_wip.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Look all reopened or under development issues and remove the ci label from them.
3 | #jiraclicmd: fill execution path of the jira cli
4 | #jiraserver: jira server url we are going to connect to
5 | #jirauser: user that will perform the execution
6 | #jirapass: password of the user
7 |
8 | # Let's go strict (exit on error)
9 | set -e
10 |
11 | # Verify everything is set
12 | required="WORKSPACE"
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 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21 |
22 | # Load Jira Configuration.
23 | source "${mydir}/../../jira.sh"
24 |
25 | # file where results will be sent
26 | resultfile=$WORKSPACE/remove_ci_label_from_wip.csv
27 | echo -n > "${resultfile}"
28 |
29 | # file where updated entries will be logged
30 | logfile=$WORKSPACE/remove_ci_label_from_wip.log
31 |
32 | # Calculate some variables
33 | BUILD_TIMESTAMP="$(date +'%Y-%m-%d_%H-%M-%S')"
34 |
35 | # Note this could be done by one unique "runFromIssueList" action, but we are splitting
36 | # the search and the update in order to log all the reopenend issues within jenkins ($logfile)
37 |
38 | # Let's search all the issues having the "ci" label that have been sent back to development (form peer review or integration)
39 | ${basereq} --action getIssueList \
40 | --jql "project = 'Moodle' \
41 | AND labels IN ('ci') \
42 | AND status IN ('Development in progress', 'Reopened')" \
43 | --file "${resultfile}"
44 |
45 | # Iterate over found issues and remove the "ci" label from them
46 | for issue in $( sed -n 's/^"\(MDL-[0-9]*\)".*/\1/p' "${resultfile}" ); do
47 | echo "Processing ${issue}"
48 | ${basereq} --action removeLabels \
49 | --issue ${issue} \
50 | --labels "ci"
51 | echo "$BUILD_NUMBER $BUILD_TIMESTAMP ${issue}" >> "${logfile}"
52 | done
53 |
54 | # Remove the resultfile. We don't want to disclose those details.
55 | rm -fr "${resultfile}"
56 |
--------------------------------------------------------------------------------
/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/remote_branch_reporter.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load libs/shared_setup
4 |
5 | teardown() {
6 | clean_workspace_directory
7 | }
8 |
9 | # Helper to assert remote branch reporter info
10 | # usage: assert_checkstyle fixturename format repo hash
11 | assert_remote_branch_reporter() {
12 | template=$BATS_TEST_DIRNAME/fixtures/remote_branch_reporter/$1/
13 | fixture=$WORKSPACE/$1
14 | format=$2
15 | repo=$3
16 | hash=$4
17 | expected=$BATS_TEST_DIRNAME/fixtures/remote_branch_reporter/$1/smurf.$format
18 |
19 | # Slightly horrible rewriting of paths, else the diff filtering will not
20 | # work correctly.
21 | cp -R $template $fixture
22 | for i in $fixture/*.xml;
23 | do
24 | sed -i.bak "s#/var/lib/jenkins/git_repositories/prechecker#$WORKSPACE#g" $i
25 | done
26 |
27 | testresult=$WORKSPACE/remote_branch_reporter.out
28 |
29 | ci_run_php "remote_branch_checker/remote_branch_reporter.php --directory=$fixture --format=$format --patchset=patchset.xml --repository=$repo --githash=$hash > $testresult"
30 | assert_success
31 | assert_files_same $expected $testresult
32 | }
33 |
34 | # https://integration.moodle.org/job/Precheck%20remote%20branch/25738/
35 | @test "remote_branch_checker/remote_branch_reporter.php: MDL-55322 no problems html" {
36 | assert_remote_branch_reporter MDL-55322 html https://github.com/snake/moodle.git 1326e8dca17e49d5749f559bbb03cc81012b6a90
37 | }
38 | @test "remote_branch_checker/remote_branch_reporter.php: MDL-55322 no problems xml" {
39 | assert_remote_branch_reporter MDL-55322 xml https://github.com/snake/moodle.git 1326e8dca17e49d5749f559bbb03cc81012b6a90
40 | }
41 |
42 | # Replicating https://integration.moodle.org/job/Precheck%20remote%20branch/25634/
43 | @test "remote_branch_checker/remote_branch_reporter.php: MDL-54987 (56 errors/8 warnings) html" {
44 | assert_remote_branch_reporter MDL-54987 html https://github.com/FMCorz/moodle.git 1869439cb1a12d82ea5bfc22a49527299f9c9620
45 | }
46 | @test "remote_branch_checker/remote_branch_reporter.php: MDL-54987 (56 errors/8 warnings) xml" {
47 | assert_remote_branch_reporter MDL-54987 xml https://github.com/FMCorz/moodle.git 1869439cb1a12d82ea5bfc22a49527299f9c9620
48 | }
49 |
--------------------------------------------------------------------------------
/tests/php_lint.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load libs/shared_setup
4 |
5 | setup () {
6 | create_git_branch MOODLE_402_STABLE v4.2.1
7 | }
8 |
9 | @test "php_lint: lib/moodlelib.php lint free" {
10 | # Set up.
11 | git_apply_fixture 402-php_lint-ok.patch
12 | export GIT_PREVIOUS_COMMIT=$FIXTURE_HASH_BEFORE
13 | export GIT_COMMIT=$FIXTURE_HASH_AFTER
14 |
15 | ci_run php_lint/php_lint.sh
16 |
17 | # Assert result
18 | assert_success
19 | assert_output --partial "Running php syntax check from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
20 | assert_output --partial "lib/moodlelib.php - OK"
21 | assert_output --partial "No PHP syntax errors found"
22 | }
23 |
24 | @test "php_lint: lib/moodlelib.php lint error detected" {
25 | # Set up.
26 | git_apply_fixture 402-php_lint-bad.patch
27 | export GIT_PREVIOUS_COMMIT=$FIXTURE_HASH_BEFORE
28 | export GIT_COMMIT=$FIXTURE_HASH_AFTER
29 |
30 | ci_run php_lint/php_lint.sh
31 |
32 | # Assert result
33 | assert_failure
34 | assert_output --partial "Running php syntax check from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
35 | assert_output --partial "lib/moodlelib.php - ERROR:"
36 | assert_output --regexp "PHP syntax errors found."
37 | }
38 |
39 | @test "php_lint: Ensure vendor directories aren't checked ever" {
40 | # Set up.
41 | git_apply_fixture 402-php_lint-vendor.patch
42 | export GIT_PREVIOUS_COMMIT=$FIXTURE_HASH_BEFORE
43 | export GIT_COMMIT=$FIXTURE_HASH_AFTER
44 |
45 | ci_run php_lint/php_lint.sh
46 |
47 | # Assert result
48 | assert_success
49 | assert_output --partial "Running php syntax check from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
50 | assert_output --partial "No PHP syntax errors found"
51 | refute_output --partial "vendor"
52 | }
53 |
54 | @test "php_lint: shows the php version being used" {
55 | # Set up.
56 | git_apply_fixture 402-php_lint-ok.patch
57 | export GIT_PREVIOUS_COMMIT=$FIXTURE_HASH_BEFORE
58 | export GIT_COMMIT=$FIXTURE_HASH_AFTER
59 |
60 | ci_run php_lint/php_lint.sh
61 |
62 | # Assert result
63 | assert_success
64 | assert_output --regexp "^Using PHP [0-9]+\.[0-9]+\.[0-9]+"
65 | assert_output --partial "Running php syntax check from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
66 | }
67 |
--------------------------------------------------------------------------------
/tests/mustache_lint_plugins.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load libs/shared_setup
4 |
5 | setup () {
6 | create_git_branch MOODLE_39_STABLE v3.9.1
7 | }
8 |
9 | @test "mustache_lint: Mustache files with Ionic3 syntax cause linting failure" {
10 | # Set up.
11 | git_apply_fixture 39-mustache_lint_plugins-templates.patch
12 | export GIT_PREVIOUS_COMMIT=$FIXTURE_HASH_BEFORE
13 | export GIT_COMMIT=$FIXTURE_HASH_AFTER
14 |
15 | ci_run mustache_lint/mustache_lint.sh
16 |
17 | # Assert result.
18 | assert_failure
19 | assert_output --partial "Running mustache lint from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
20 | assert_output --partial "local/test/templates/linting_ok.mustache - OK: Mustache rendered html succesfully"
21 | assert_output --partial "local/test/templates/local/mobile/view.mustache - INFO: HTML Validation info"
22 | assert_output --partial "local/test/templates/local/mobile/view.mustache - WARNING: HTML Validation error"
23 | assert_output --partial "local/test/templates/mobile_view.mustache - WARNING: HTML Validation error"
24 | assert_output --partial "Mustache lint problems found"
25 | }
26 |
27 | @test "mustache_lint: Mustache files can be excluded from linting" {
28 | # Set up.
29 | git_apply_fixture 39-mustache_lint_plugins-templates.patch
30 | export GIT_PREVIOUS_COMMIT=$FIXTURE_HASH_BEFORE
31 | git_apply_fixture 39-mustache_lint_plugins-ignores.patch
32 | export GIT_COMMIT=$FIXTURE_HASH_AFTER
33 |
34 | ci_run mustache_lint/mustache_lint.sh
35 |
36 | # Assert result
37 | assert_success
38 | assert_output --partial "Running mustache lint from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
39 | assert_output --partial "local/test/templates/linting_ok.mustache - OK: Mustache rendered html succesfully"
40 | assert_output --partial "local/test/templates/mobile_view.mustache - OK: Mustache rendered html succesfully"
41 | assert_output --partial "local/test/templates/local/mobile/view.mustache - OK: Mustache rendered html succesfully"
42 | assert_output --partial "local/test/templates/mobile_view.mustache - INFO: HTML validation skipped"
43 | assert_output --partial "local/test/templates/local/mobile/view.mustache - INFO: HTML validation skipped"
44 | assert_output --partial "No mustache problems found"
45 | }
46 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tests/fixtures/checkstyle/mustachelint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/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 | +