Skip to content

Commit 46d30b1

Browse files
authored
Merge pull request #245 from kabalin/local-run
Add docs section about running in local dev environment
2 parents ee2c559 + 2932ec0 commit 46d30b1

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

docs/index.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,84 @@ remove anything that is not needed. See this [help document](TravisFileExplaine
8282
contents of the this file. Once you have added the `.travis.yml` file, commit and push up to GitHub, to trigger a
8383
Travis CI build. Navigate back to [Travis CI](https://travis-ci.com) to see if your build passes or fails.
8484

85+
### Using in a Local Dev Environment
86+
87+
It is possible to use `moodle-plugin-ci` locally. It needs to be installed outside
88+
Moodle directory, so if you are within Moodle repo, execute:
89+
90+
```
91+
$ php composer.phar create-project moodlehq/moodle-plugin-ci ../moodle-plugin-ci ^4
92+
```
93+
94+
Once installed, you can run most of its commands to validate your code, e.g.
95+
96+
```
97+
$ ../moodlepluginci/bin/moodle-plugin-ci mustache ./mod/forum/
98+
RUN Mustache Lint on mod_forum
99+
/home/ruslan/git/moodledev/mod/forum/templates/quick_search_form.mustache - OK: Mustache rendered html succesfully
100+
/home/ruslan/git/moodledev/mod/forum/templates/single_discussion_list.mustache - OK: Mustache rendered html succesfully
101+
...
102+
```
103+
104+
Alternatively, one can use phar package obtained from the release page, this can
105+
be downloaded safely to Moodle directory (it is in Moodle's `.gitignore`):
106+
107+
```
108+
$ wget https://github.com/moodlehq/moodle-plugin-ci/releases/download/4.1.6/moodle-plugin-ci.phar
109+
```
110+
111+
Execute it in this case as follows:
112+
113+
```
114+
$ php moodle-plugin-ci.phar mustache ./mod/forum/
115+
RUN Mustache Lint on mod_forum
116+
/home/ruslan/git/moodledev/mod/forum/templates/quick_search_form.mustache - OK: Mustache rendered html succesfully
117+
/home/ruslan/git/moodledev/mod/forum/templates/single_discussion_list.mustache - OK: Mustache rendered html succesfull
118+
```
119+
120+
Notice that using this approach allows you running CI commands on plugins only.
121+
122+
#### Using PHP CodeSniffer and PHP Code Beautifier and Fixer
123+
124+
It is possible to use CodeSniffer from the package on individual files and directories, they don't have to be a part of plugin in this case. You need to have it installed using composer approach.
125+
126+
```
127+
$ ../moodle-plugin-ci/vendor/bin/phpcs ./index.php
128+
129+
FILE: /home/ruslan/git/moodledev/index.php
130+
-------------------------------------------------------------------------------------------------------------
131+
FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
132+
-------------------------------------------------------------------------------------------------------------
133+
25 | ERROR | [ ] Expected MOODLE_INTERNAL check or config.php inclusion. Change in global state detected.
134+
36 | WARNING | [x] Short array syntax must be used to define arrays
135+
58 | ERROR | [ ] Logical operator "and" is prohibited; use "&&" instead
136+
86 | WARNING | [x] Short array syntax must be used to define arrays
137+
92 | WARNING | [x] Short array syntax must be used to define arrays
138+
-------------------------------------------------------------------------------------------------------------
139+
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
140+
-------------------------------------------------------------------------------------------------------------
141+
142+
Time: 197ms; Memory: 16MB
143+
```
144+
145+
From the example above, PHP Code Beautifier and Fixer may address 3 violations
146+
automatically, saving developer time:
147+
148+
```
149+
$ ../moodle-plugin-ci/vendor/bin/phpcbf ./index.php
150+
151+
PHPCBF RESULT SUMMARY
152+
----------------------------------------------------------------------
153+
FILE FIXED REMAINING
154+
----------------------------------------------------------------------
155+
/home/ruslan/git/moodledev/index.php 3 2
156+
----------------------------------------------------------------------
157+
A TOTAL OF 3 ERRORS WERE FIXED IN 1 FILE
158+
----------------------------------------------------------------------
159+
160+
Time: 328ms; Memory: 16MB
161+
```
162+
85163
### Getting more of CI
86164

87165
Next steps on your continuous build journey may include:

0 commit comments

Comments
 (0)