Skip to content

Commit 683a031

Browse files
authored
Add moodle ci GHA
1 parent 1cabdb7 commit 683a031

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

.github/workflows/moodle-ci.yml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Moodle Plugin CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-22.04
8+
9+
services:
10+
postgres:
11+
image: postgres:13
12+
env:
13+
POSTGRES_USER: 'postgres'
14+
POSTGRES_HOST_AUTH_METHOD: 'trust'
15+
ports:
16+
- 5432:5432
17+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
18+
19+
mariadb:
20+
image: mariadb:10
21+
env:
22+
MYSQL_USER: 'root'
23+
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
24+
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
25+
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
26+
ports:
27+
- 3306:3306
28+
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
29+
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- php: '8.3'
35+
moodle-branch: 'main'
36+
database: 'mariadb'
37+
- php: '8.3'
38+
moodle-branch: 'main'
39+
database: 'pgsql'
40+
- php: '8.2'
41+
moodle-branch: 'main'
42+
database: 'mariadb'
43+
- php: '8.2'
44+
moodle-branch: 'main'
45+
database: 'pgsql'
46+
- php: '8.1'
47+
moodle-branch: 'MOODLE_404_STABLE'
48+
database: 'mariadb'
49+
- php: '8.1'
50+
moodle-branch: 'MOODLE_403_STABLE'
51+
database: 'mariadb'
52+
- php: '8.0'
53+
moodle-branch: 'MOODLE_401_STABLE'
54+
database: 'mariadb'
55+
56+
steps:
57+
- name: Check out repository code
58+
uses: actions/checkout@v4
59+
with:
60+
path: plugin
61+
62+
- name: Setup PHP ${{ matrix.php }}
63+
uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: ${{ matrix.php }}
66+
extensions: ${{ matrix.extensions }}
67+
ini-values: max_input_vars=5000
68+
# If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
69+
# If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
70+
coverage: none
71+
72+
- name: Initialise moodle-plugin-ci
73+
run: |
74+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
75+
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
76+
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
77+
sudo locale-gen en_AU.UTF-8
78+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
79+
80+
- name: Install moodle-plugin-ci
81+
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
82+
env:
83+
DB: ${{ matrix.database }}
84+
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
85+
# Uncomment this to run Behat tests using the Moodle App.
86+
# MOODLE_APP: 'true'
87+
88+
- name: PHP Lint
89+
if: ${{ !cancelled() }}
90+
run: moodle-plugin-ci phplint
91+
92+
- name: PHP Mess Detector
93+
continue-on-error: true # This step will show errors but will not fail
94+
if: ${{ !cancelled() }}
95+
run: moodle-plugin-ci phpmd
96+
97+
- name: Moodle Code Checker
98+
if: ${{ !cancelled() }}
99+
run: moodle-plugin-ci phpcs --max-warnings 0
100+
101+
- name: Moodle PHPDoc Checker
102+
if: ${{ !cancelled() }}
103+
run: moodle-plugin-ci phpdoc --max-warnings 0
104+
105+
- name: Validating
106+
if: ${{ !cancelled() }}
107+
run: moodle-plugin-ci validate
108+
109+
- name: Check upgrade savepoints
110+
if: ${{ !cancelled() }}
111+
run: moodle-plugin-ci savepoints
112+
113+
- name: Mustache Lint
114+
if: ${{ !cancelled() }}
115+
run: moodle-plugin-ci mustache
116+
117+
- name: Grunt
118+
if: ${{ !cancelled() }}
119+
run: moodle-plugin-ci grunt --max-lint-warnings 0
120+
121+
- name: PHPUnit tests
122+
if: ${{ !cancelled() }}
123+
run: moodle-plugin-ci phpunit --fail-on-warning
124+
125+
- name: Behat features
126+
id: behat
127+
if: ${{ !cancelled() }}
128+
run: moodle-plugin-ci behat --profile chrome
129+
130+
- name: Upload Behat Faildump
131+
if: ${{ failure() && steps.behat.outcome == 'failure' }}
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: Behat Faildump (${{ join(matrix.*, ', ') }})
135+
path: ${{ github.workspace }}/moodledata/behat_dump
136+
retention-days: 7
137+
if-no-files-found: ignore
138+
139+
- name: Mark cancelled jobs as failed.
140+
if: ${{ cancelled() }}
141+
run: exit 1

0 commit comments

Comments
 (0)