Skip to content

Commit f429495

Browse files
committed
add .github pipeline
1 parent 082bc5b commit f429495

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

.github/workflows/moodle-ci.yml

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

0 commit comments

Comments
 (0)