-
Notifications
You must be signed in to change notification settings - Fork 84
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
Updated .travis.yml to support Moodlerooms plugin #119
Conversation
Nice @mikemcgowan |
@ryansmith94 any word on getting this merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy for this to be merged once all of the code checker issues have been resolved and my code comments have been addressed 👍
- moodle-plugin-ci install | ||
|
||
script: | ||
# - moodle-plugin-ci phplint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for commenting out each of these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which? Specifically moodle-plugin-ci phpcpd
and moodle-plugin-ci phpmd
? I suppose, in the first instance, I wanted to get a smaller subset of the available Moodlerooms stuff passing - in particular moodle-plugin-ci codechecker
so the code lints to Moodle's own standard.
At a later date, once the Travis build is passing against the Moodlerooms plugins that are currently commented-in, some of the additional Moodlerooms plugins could also be commented in, and any issues then fixed. I think the phpcpd
(copy/paste detector) and phpmd
(mess detector) are probably very useful checks to include, in the long run, but as there's going to be a tonne of codechecker
failures to fix first, I suppose it's arguably better to do each plugin at a time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, this makes a lot of sense. Yeah we'll enable one bit at a time. I agree those bits should be useful.
.travis.yml
Outdated
# - moodle-plugin-ci phplint | ||
# - moodle-plugin-ci phpcpd | ||
# - moodle-plugin-ci phpmd | ||
- moodle-plugin-ci codechecker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to run these things locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as moodle-plugin-ci codechecker
goes, it's possible to run phpcs
locally against the Moodle coding style by following these instructions.
It's apparently possible to run a Travis build locally so that's possibly a way in which to run the other moodle-plugin-ci
items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. probably wouldn't want to run Travis builds locally though, seems a bit overkill. As long as we can run the code checker locally I'm happy.
env: | ||
global: | ||
- MOODLE_BRANCH=MOODLE_32_STABLE | ||
matrix: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably not needed. I'm fairly certain this exists so that the tests are ran against those DBs but since we test against memory to improve build times this isn't required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, the existing tests don't run in the context of Moodle's PHPUnit test framework and PHPUnit test database. I appreciate that the existing PHPUnits have been written in such a way that a test database isn't currently required, however, it's a Moodle plugin and its tests should really be executable as part of the Moodle PHPUnit test framework.
It's certainly possible that, in the future, test coverage of functionality that touches the database may benefit from being written (e.g. test coverage of the functionality that processes the queue of unsent statements in the logstore_xapi_log
table). In which case, the test database would end up being necessary anyway.
Finally, my guess (I haven't checked this) is that the Moodlerooms stuff relies on Moodle actually being installed, so my guess is that the above probably does have to be there (I've taken the .travis.yml
file from here so it's very close to the Moodlerooms distribution file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok in that case, let's comment one out for now, otherwise we're running 6 builds when we could be running 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Done.
I've pushed another commit which addresses the Moodle coding style everywhere but the I'll do the |
By the way, as part of this PR, Code Climate should be turned off, but I don't think I can do that myself? |
I've now done It's fairly time-consuming, though! |
@mikemcgowan awesome work!!! I imagine this is really time consuming, really appreciate you taking the time to get this done 👍 I will disable code climate. |
…ot tests passing under Moodle's PHPUnit test framework
@ryansmith94 I'm pretty sure I've done everything now:
Hopefully, all's good for getting this merged ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow @mikemcgowan, you're a legend, this is just awesome and I'm massively impressed! Just got one comment on the .gitignore, but I'm happy to approve this, just want to know where those ignored files are coming from.
@@ -26,10 +26,23 @@ If you've read the [plugin design](design.md) you should understand what each of | |||
- [Moodle to xAPI Translator](https://github.com/LearningLocker/Moodle-xAPI-Translator/blob/master/docs/readme.md#adding-events) | |||
- [xAPI Recipe Emitter](https://github.com/LearningLocker/xAPI-Recipe-Emitter/blob/master/docs/readme.md#adding-events) | |||
|
|||
##PHPUnit Test Filter | |||
All PHPUnit tests should pass, but if you'd like to only run the tests for specific events, add the 'filter' option. | |||
## PHPUnit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking 👍
.gitignore
Outdated
@@ -5,3 +5,4 @@ vendor | |||
classes/log/error_log.txt | |||
composer.phar | |||
.idea/ | |||
lib/*/docs/examples/*_test.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this ignored now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually what is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files get generated by some of the PHPUnits. Now that the .php
files with tests have been changed to the Moodle standard test filename (i.e. *_test.php
) the generated test files have different filenames.
The generation of these JSON files by the PHPUnits was already happening in master
, and those automatically generated files have already been committed, e.g. see 1139e3f
I wasn't brave enough to take the decision to remove the existing ones! I thought it was safer/cleaner to .gitignore
the new ones with the *_test.json
extension.
+$ git diff master | grep -Pi '\$exampleFile'
- $exampleFile = __DIR__.'/../docs/examples/'.$eventName.'.json';
- file_put_contents($exampleFile, json_encode($output, JSON_PRETTY_PRINT));
- $exampleFile = __DIR__.'/../docs/examples/'.$eventName.'.json';
- file_put_contents($exampleFile, json_encode($output, JSON_PRETTY_PRINT));
- $exampleFile = __DIR__.'/../docs/examples/'.$eventName.'.json';
- file_put_contents($exampleFile, json_encode($output, JSON_PRETTY_PRINT));
+ $examplefile = __DIR__ . '/../../../lib/emitter/docs/examples/' . $eventname . '.json';
+ file_put_contents($examplefile, json_encode($output, JSON_PRETTY_PRINT));
+ $examplefile = __DIR__ . '/../../../lib/expander/docs/examples/' . $eventname . '.json';
+ file_put_contents($examplefile, json_encode($output, JSON_PRETTY_PRINT));
+ $examplefile = __DIR__ . '/../../../lib/translator/docs/examples/' . $eventname . '.json';
+ file_put_contents($examplefile, json_encode($output, JSON_PRETTY_PRINT));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. You've highlighted a small issue, actually, with the generation of those JSON files. They're not actually supposed to have the _test
extension:
protected function create_example_file($output) {
$classarray = explode('\\', get_class($this));
$eventname = str_replace('Test', '', array_pop($classarray));
$examplefile = __DIR__ . '/../../../lib/emitter/docs/examples/' . $eventname . '.json';
file_put_contents($examplefile, json_encode($output, JSON_PRETTY_PRINT));
}
I should have changed the str_replace
line to take into consideration the change of filename.
I'll sort that out now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed another commit to address this issue.
- The change to
.gitignore
is no longer necessary so I've backed it out. - The automatic generation of the file name of the example event JSON files by the PHPUnit tests has been corrected (changed from replacing
Test
to replacing_test
). - Example event JSON files themselves (in
lib/*/docs/examples/
) have all been renamed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This is awesome! Thanks @mikemcgowan 👍
Have a quick check of this if you like @davidpesce, I think it's ready to merge. |
Wow, this looks like quite a bit of work. Thanks, @mikemcgowan ! After a quick look, this looks OK to me. I haven't done a full test, but if you are good with it, merge it. |
I have now updated the
.travis.yml
file to support the Moodlerooms Travis plugin.See #117
This wasn't straightforward because this plugin executes its own PHPUnits outside of the Moodle PHPUnit test environment. (This should probably be changed so that this plugin's PHPUnits are executable within the wider Moodle PHPUnit test environment. Then, the
moodle-plugin-ci phpunit
item can be commented-in in.travis.yml
and the$ORIG
hack removed - see below.)To avoid the Moodlerooms Travis plugin from linting the Composer packages required by this plugin, I had to cache the original working directory of the plugin (as
$ORIG
). As the very last item in the Travis build, after all the Moodlerooms stuff is finshed, this plugin's Composer packages are installed and then its PHPUnits ran (independently from the Moodle PHPUnit test environment).The build reaches the end successfully but of course, there are many errors because the code doesn't currently lint to the Moodle coding style.
However, the second two of these three items pass:
The plugin's own PHPUnits also pass, as previously (of which there are currently 71 tests, 2304 assertions).