1+ name : Moodle Plugin CI
2+
3+ on : [push, pull_request]
4+
5+ jobs :
6+ static :
7+ runs-on : ubuntu-latest
8+
9+ strategy :
10+ matrix :
11+ php : ['7.4']
12+ moodle-branch : ['MOODLE_311_STABLE']
13+ database : ['pgsql']
14+
15+ steps :
16+ - name : Start PostgreSQL
17+ run : docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:9.6
18+
19+ - name : Check out repository code
20+ uses : actions/checkout@v2
21+ with :
22+ path : plugin
23+
24+ - name : Setup PHP ${{ matrix.php }}
25+ uses : shivammathur/setup-php@v2
26+ with :
27+ php-version : ${{ matrix.php }}
28+ coverage : none
29+
30+ - name : Get composer cache directory
31+ id : composer-cache
32+ run : echo "::set-output name=dir::$(composer config cache-files-dir)"
33+
34+ - name : Composer cache
35+ uses : actions/cache@v2
36+ with :
37+ path : ${{ steps.composer-cache.outputs.dir }}
38+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
39+ restore-keys : |
40+ ${{ runner.os }}-composer-
41+
42+ - name : npm cache
43+ uses : actions/cache@v2
44+ with :
45+ path : ~/.npm
46+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
47+ restore-keys : |
48+ ${{ runner.os }}-node-
49+
50+ - name : Initialise moodle-plugin-ci
51+ run : |
52+ composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
53+ echo $(cd ci/bin; pwd) >> $GITHUB_PATH
54+ echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
55+ sudo locale-gen en_AU.UTF-8
56+ echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
57+
58+ - name : Install moodle-plugin-ci
59+ run : |
60+ moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 --no-init
61+ env :
62+ DB : ${{ matrix.database }}
63+ MOODLE_BRANCH : ${{ matrix.moodle-branch }}
64+
65+ - name : PHP Lint
66+ if : ${{ always() }}
67+ run : moodle-plugin-ci phplint
68+
69+ - name : PHP Copy/Paste Detector
70+ if : ${{ always() }}
71+ run : moodle-plugin-ci phpcpd
72+
73+ - name : PHP Mess Detector
74+ if : ${{ always() }}
75+ run : moodle-plugin-ci phpmd
76+
77+ - name : Moodle Code Checker
78+ if : ${{ always() }}
79+ run : moodle-plugin-ci codechecker
80+
81+ - name : Moodle PHPDoc Checker
82+ if : ${{ always() }}
83+ run : moodle-plugin-ci phpdoc
84+ continue-on-error : true
85+
86+ - name : Validating
87+ if : ${{ always() }}
88+ run : moodle-plugin-ci validate
89+
90+ - name : Check upgrade savepoints
91+ if : ${{ always() }}
92+ run : moodle-plugin-ci savepoints
93+
94+ - name : Mustache Lint
95+ if : ${{ always() }}
96+ run : moodle-plugin-ci mustache
97+ continue-on-error : true
98+
99+ - name : Grunt
100+ if : ${{ always() }}
101+ run : moodle-plugin-ci grunt
102+
103+ test :
104+ runs-on : ubuntu-latest
105+ needs : static
106+
107+ strategy :
108+ fail-fast : false
109+ matrix :
110+ php : ['7.3', '7.4']
111+ moodle-branch : ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE']
112+ database : ['mariadb', 'pgsql']
113+
114+ steps :
115+ - name : Start MariaDB
116+ if : matrix.database == 'mariadb'
117+ run : docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10
118+
119+ - name : Start PostgreSQL
120+ if : matrix.database == 'pgsql'
121+ run : docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:9.6
122+
123+ - name : Check out repository code
124+ uses : actions/checkout@v2
125+ with :
126+ path : plugin
127+
128+ - name : Setup PHP ${{ matrix.php }}
129+ uses : shivammathur/setup-php@v2
130+ with :
131+ php-version : ${{ matrix.php }}
132+ coverage : none
133+
134+ - name : Get composer cache directory
135+ id : composer-cache
136+ run : echo "::set-output name=dir::$(composer config cache-files-dir)"
137+ - name : Composer cache
138+ uses : actions/cache@v2
139+ with :
140+ path : ${{ steps.composer-cache.outputs.dir }}
141+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
142+ restore-keys : |
143+ ${{ runner.os }}-composer-
144+ - name : npm cache
145+ uses : actions/cache@v2
146+ with :
147+ path : ~/.npm
148+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
149+ restore-keys : |
150+ ${{ runner.os }}-node-
151+
152+ - name : Initialise moodle-plugin-ci
153+ run : |
154+ composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
155+ echo $(cd ci/bin; pwd) >> $GITHUB_PATH
156+ echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
157+ sudo locale-gen en_AU.UTF-8
158+ echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
159+
160+ - name : Install moodle-plugin-ci
161+ run : |
162+ moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
163+ env :
164+ DB : ${{ matrix.database }}
165+ MOODLE_BRANCH : ${{ matrix.moodle-branch }}
166+
167+ - name : PHPUnit tests
168+ if : ${{ always() }}
169+ run : moodle-plugin-ci phpunit
170+
171+ - name : Behat features
172+ if : ${{ always() }}
173+ run : moodle-plugin-ci behat --profile chrome
0 commit comments