Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDLSITE-4211 testing: add ci tests to local_ci #92

Merged
merged 4 commits into from
Jul 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: php
php:
- '7.0'
sudo: false
cache:
directories:
- $HOME/cachedir
install: git clone --depth 1 https://github.com/sstephenson/bats.git $HOME/bats
before_script:
- 'git config --global user.email "travis@localhost" && git config --global user.name "Travis CI"'
- "export LOCAL_CI_TESTS_CACHEDIR=$HOME/cachedir && mkdir -p $LOCAL_CI_TESTS_CACHEDIR"
- "export LOCAL_CI_TESTS_GITDIR=$HOME/gitdir && git clone git://github.com/moodle/moodle $LOCAL_CI_TESTS_GITDIR"
script:
- $HOME/bats/bin/bats tests

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CI local plugin

[![Build Status](https://travis-ci.org/moodlehq/moodle-local_ci.svg?branch=master)](https://travis-ci.org/moodlehq/moodle-local_ci)

This local_ci plugin contains all the scripts needed
by Moodle CI servers to automate checks while
integration happens.
Expand Down
9 changes: 9 additions & 0 deletions tests/00-setup.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bats

load libs/shared_setup

# This test is just used as some quick output because some tests are v.slow
@test "Git is setup for tests." {
[ -d "$gitdir/.git" ];
assert_success
}
40 changes: 40 additions & 0 deletions tests/01-php_lint.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bats

load libs/shared_setup

setup () {
create_git_branch MOODLE_31_STABLE v3.1.0

export extrapath=.
}

@test "php_lint: lib/moodlelib.php lint free" {
cd $gitdir
export GIT_PREVIOUS_COMMIT=$($gitcmd rev-parse HEAD)
$gitcmd am $BATS_TEST_DIRNAME/fixtures/31-php_lint-ok.patch
export GIT_COMMIT=$($gitcmd rev-parse HEAD)

cd $BATS_TEST_DIRNAME/../php_lint/
run ./php_lint.sh
assert_success
assert_output --partial "Running php syntax check from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
assert_output --partial "lib/moodlelib.php - OK"
assert_output --partial "No PHP syntax errors found"
}

@test "php_lint: lib/moodlelib.php lint error detected" {
cd $gitdir
export GIT_PREVIOUS_COMMIT=$($gitcmd rev-parse HEAD)
$gitcmd am $BATS_TEST_DIRNAME/fixtures/31-php_lint-bad.patch
export GIT_COMMIT=$($gitcmd rev-parse HEAD)

# Run test
cd $BATS_TEST_DIRNAME/../php_lint/
run ./php_lint.sh

# Assert result
assert_failure
assert_output --partial "Running php syntax check from $GIT_PREVIOUS_COMMIT to $GIT_COMMIT"
assert_output --partial "lib/moodlelib.php - ERROR:"
assert_output --regexp "PHP syntax errors found."
}
38 changes: 38 additions & 0 deletions tests/01-thirdparty_check.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bats

load libs/shared_setup

setup () {
create_git_branch MOODLE_31_STABLE v3.1.0

export extrapath=.
}

@test "thirdparty_check: thirdpartyfile modified OK" {
cd $gitdir
export initialcommit=$($gitcmd rev-parse HEAD)
$gitcmd am $BATS_TEST_DIRNAME/fixtures/31-thirdparty-ok.patch
export finalcommit=$($gitcmd rev-parse HEAD)

cd $BATS_TEST_DIRNAME/../thirdparty_check/
run ./thirdparty_check.sh
assert_success
assert_output --partial "INFO: Checking for third party modifications from $initialcommit to $finalcommit"
assert_output --partial "INFO: Detected third party modification in lib/amd/src/mustache.js"
assert_output --partial "INFO: OK lib/thirdpartylibs.xml modified"
refute_output --partial "WARN:"
}

@test "thirdparty_check: thirdpartyfile modified without update" {
cd $gitdir
export initialcommit=$($gitcmd rev-parse HEAD)
$gitcmd am $BATS_TEST_DIRNAME/fixtures/31-thirdparty-error.patch
export finalcommit=$($gitcmd rev-parse HEAD)

cd $BATS_TEST_DIRNAME/../thirdparty_check/
run ./thirdparty_check.sh
assert_success # TODO, this should be fixed!
assert_output --partial "INFO: Checking for third party modifications from $initialcommit to $finalcommit"
assert_output --partial "INFO: Detected third party modification in lib/amd/src/mustache.js"
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"
}
30 changes: 30 additions & 0 deletions tests/02-less_checker.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bats

load libs/shared_setup


setup () {
create_git_branch MOODLE_27_STABLE v2.7.14

export extrapath=.
# Setup recess base.
export recessbase=$LOCAL_CI_TESTS_CACHEDIR/recess
mkdir -p $recessbase
}

@test "less_checker: normal" {
cd $BATS_TEST_DIRNAME/../less_checker/
run ./less_checker.sh
assert_success
assert_output --partial "OK: All .less files are perfectly compiled and matching git contents"
}

@test "less_checker: uncommitted less change" {
cd $gitdir
$gitcmd am $BATS_TEST_DIRNAME/fixtures/27-less-unbuilt.patch
cd $BATS_TEST_DIRNAME/../less_checker/
run ./less_checker.sh
assert_failure
assert_output --partial "ERROR: Some .less files are not matching git contents. Changes detected:"
assert_output --partial "theme/bootstrapbase/style/moodle.css"
}
70 changes: 70 additions & 0 deletions tests/99-grunt_process.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bats

load libs/shared_setup


setup () {
create_git_branch MOODLE_31_STABLE v3.1.0

export extrapath=.
}

@test "grunt_process: normal" {
cd $BATS_TEST_DIRNAME/../grunt_process/
run ./grunt_process.sh
assert_success
assert_output --partial "Done, without errors."
assert_output --partial "OK: All modules are perfectly processed by grunt"
}

@test "grunt_process: Uncommited .less change" {
# Create css change.
cd $gitdir
$gitcmd am $BATS_TEST_DIRNAME/fixtures/31-grunt-less-unbuilt.patch

# Run test
cd $BATS_TEST_DIRNAME/../grunt_process/
run ./grunt_process.sh

# Assert result
assert_failure
assert_output --partial "Done, without errors." # Grunt shouldn't have an issue here.
assert_output --partial "ERROR: Some modules are not properly processed by grunt. Changes detected:"
assert_output --regexp "GRUNT-CHANGE: (.*)/theme/bootstrapbase/style/moodle.css"
}

@test "grunt_process: Uncommited .js change" {
# Create js change.
cd $gitdir
$gitcmd am $BATS_TEST_DIRNAME/fixtures/31-grunt-js-unbuilt.patch

# Run test
cd $BATS_TEST_DIRNAME/../grunt_process/
run ./grunt_process.sh

# Assert result
assert_failure
assert_output --partial "Done, without errors." # Grunt shouldn't have an issue here.
assert_output --partial "ERROR: Some modules are not properly processed by grunt. Changes detected:"
assert_output --regexp "GRUNT-CHANGE: (.*)/lib/amd/build/url.min.js"
}

@test "grunt_process: Uncommited ignorefiles change" {
# When a third party library is added, developers need to commit
# ignorefiles change since 3.2.

# Testing on in-dev 3.2dev
create_git_branch 32-dev 5a1728df39116fc701cc907e85a638aa7674f416
cd $gitdir
$gitcmd am $BATS_TEST_DIRNAME/fixtures/32-thirdparty-lib-added.patch

# Run test
cd $BATS_TEST_DIRNAME/../grunt_process/
run ./grunt_process.sh

# Assert result
assert_failure
assert_output --partial "ERROR: Some modules are not properly processed by grunt. Changes detected:"
assert_output --regexp "GRUNT-CHANGE: (.*)/.eslintignore"
}

29 changes: 29 additions & 0 deletions tests/99-shifter_walk.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bats

load libs/shared_setup

setup () {
create_git_branch MOODLE_27_STABLE v2.7.14

export extrapath=.
# setup shifter base.
export shifterbase=$LOCAL_CI_TESTS_CACHEDIR/shifter
mkdir -p $shifterbase
}

@test "shifter_walk: normal" {
cd $BATS_TEST_DIRNAME/../shifter_walk/
run ./shifter_walk.sh
assert_success
assert_output --partial "OK: All modules are perfectly shiftered"
}

@test "shifter_walk: Uncommitted .js change" {
cd $gitdir
$gitcmd am $BATS_TEST_DIRNAME/fixtures/27-shifter-unbuildjs.patch
cd $BATS_TEST_DIRNAME/../shifter_walk/
run ./shifter_walk.sh
assert_failure
assert_output --partial "ERROR: Some modules are not properly shiftered. Changes detected:"
assert_output --partial "lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js"
}
26 changes: 26 additions & 0 deletions tests/fixtures/27-less-unbuilt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 793df60c6b5d4733191ef7d2c2b19b940803c066 Mon Sep 17 00:00:00 2001
From: Dan Poltawski <[email protected]>
Date: Wed, 15 Jun 2016 22:35:27 +0100
Subject: [PATCH 1/1] MDLSITE-4211 fixture: for less tests

This should be applied on top of v2.7.14
---
theme/bootstrapbase/less/moodle/reports.less | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/theme/bootstrapbase/less/moodle/reports.less b/theme/bootstrapbase/less/moodle/reports.less
index 6c90a80..211c709 100644
--- a/theme/bootstrapbase/less/moodle/reports.less
+++ b/theme/bootstrapbase/less/moodle/reports.less
@@ -15,4 +15,6 @@

#page-report-participation-index.dir-rtl .participationselectform div label[for=menuinstanceid] {
margin-right: 0px; // No right margin for RTL.
-}
\ No newline at end of file
+}
+
+.integrationcsschange{display:none;}
--
2.8.1

26 changes: 26 additions & 0 deletions tests/fixtures/27-shifter-unbuildjs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From f2e278d056561d0d6fbce54be6d187a514640553 Mon Sep 17 00:00:00 2001
From: Dan Poltawski <[email protected]>
Date: Wed, 15 Jun 2016 22:20:00 +0100
Subject: [PATCH 1/1] MDLSITE-4211 fixture: for shifter tests

This should be applied on top of v2.7.14
---
lib/editor/atto/yui/src/editor/js/editor.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/editor/atto/yui/src/editor/js/editor.js b/lib/editor/atto/yui/src/editor/js/editor.js
index ca6ca55..5260475 100644
--- a/lib/editor/atto/yui/src/editor/js/editor.js
+++ b/lib/editor/atto/yui/src/editor/js/editor.js
@@ -363,7 +363,7 @@ Y.extend(Editor, Y.Base, {
},

_setPluginState: function(enable, plugin) {
- var target = 'disableButtons';
+ var target = 'disableButtons-dan-woz-ere';
if (enable) {
target = 'enableButtons';
}
--
2.8.1

26 changes: 26 additions & 0 deletions tests/fixtures/31-grunt-js-unbuilt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From ca0ff741dab36b760e20a37418fcdb139885eb79 Mon Sep 17 00:00:00 2001
From: Dan Poltawski <[email protected]>
Date: Wed, 15 Jun 2016 23:06:36 +0100
Subject: [PATCH 1/1] MDLSITE-4211 fixture: unbuilt js change for grunt

This should be applied on top of v3.1.0
---
lib/amd/src/url.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/amd/src/url.js b/lib/amd/src/url.js
index b3263ee..b6348de 100644
--- a/lib/amd/src/url.js
+++ b/lib/amd/src/url.js
@@ -61,7 +61,7 @@ define(['core/config'], function(config) {
relativeUrl: function(relativePath) {

if (relativePath.indexOf('http:') === 0 || relativePath.indexOf('https:') === 0 || relativePath.indexOf('://') >= 0) {
- throw new Error('relativeUrl function does not accept absolute urls');
+ throw new Error('relativeUrl function does not accept absolute urls. danp woz ere!');
}

// Fix non-relative paths;
--
2.8.1

26 changes: 26 additions & 0 deletions tests/fixtures/31-grunt-less-unbuilt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 205c355bc8ef7bfb52695cc42f2d98826759364b Mon Sep 17 00:00:00 2001
From: Dan Poltawski <[email protected]>
Date: Wed, 15 Jun 2016 22:35:27 +0100
Subject: [PATCH 1/1] MDLSITE-4211 fixture: less unbuilt for grunt tests

This should be applied on top of v3.1.0
---
theme/bootstrapbase/less/moodle/reports.less | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/theme/bootstrapbase/less/moodle/reports.less b/theme/bootstrapbase/less/moodle/reports.less
index 6c90a80..211c709 100644
--- a/theme/bootstrapbase/less/moodle/reports.less
+++ b/theme/bootstrapbase/less/moodle/reports.less
@@ -15,4 +15,6 @@

#page-report-participation-index.dir-rtl .participationselectform div label[for=menuinstanceid] {
margin-right: 0px; // No right margin for RTL.
-}
\ No newline at end of file
+}
+
+.integrationcsschange{display:none;}
--
2.8.1

22 changes: 22 additions & 0 deletions tests/fixtures/31-php_lint-bad.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From 7fd18b3698c14916bdfa83f502544ddd0eb65b20 Mon Sep 17 00:00:00 2001
From: Dan Poltawski <[email protected]>
Date: Wed, 15 Jun 2016 22:54:14 +0100
Subject: [PATCH 1/1] MDLSITE-4211 fixture: for php_lint tests

This should be applied on top of v3.1.0
---
lib/moodlelib.php | 1 +
1 file changed, 1 insertion(+)

diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 8160f89..f6c0fd7 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -9768,3 +9768,4 @@ class lang_string {
return array('forcedstring', 'string', 'lang');
}
}
+die('oh this is gonna be a problem!
--
2.8.1

Loading