MDL-70276 github actions: First cut, phpunit and grunt checks
[moodle.git] / .github / workflows / push.yml
1 name: Core
3 on: [push]
5 env:
6   php: 7.4
8 jobs:
9   Grunt:
10     runs-on: ubuntu-18.04
12     steps:
13       - name: Checking out code
14         uses: actions/checkout@v2
16       - name: Configuring node & npm
17         shell: bash -l {0}
18         run: nvm install
20       - name: Installing node stuff
21         run: npm install
23       - name: Running grunt
24         run: npx grunt
26       - name: Looking for uncommitted changes
27         # Add all files to the git index and then run diff --cached to see all changes.
28         # This ensures that we get the status of all files, including new files.
29         # We ignore npm-shrinkwrap.json to make the tasks immune to npm changes.
30         run: |
31           git add .
32           git reset -- npm-shrinkwrap.json
33           git diff --cached --exit-code
35   PHPUnit:
36     runs-on: ${{ matrix.os }}
37     services:
38       exttests:
39         image: moodlehq/moodle-exttests
40         ports:
41           - 8080:80
42       redis:
43         image: redis
44         ports:
45           - 6379:6379
46     strategy:
47       fail-fast: false
48       matrix:
49         include:
50           - os: ubuntu-18.04
51             php: 7.2
52             db: mysqli
53           - os: ubuntu-18.04
54             php: 7.4
55             db: pgsql
57     steps:
58       - name: Setting up DB mysql
59         if: ${{ matrix.db == 'mysqli' }}
60         uses: johanmeiring/mysql-action@tmpfs-patch
61         with:
62           collation server: utf8mb4_bin
63           mysql version: 5.7
64           mysql database: test
65           mysql user: test
66           mysql password: test
67           use tmpfs: true
69       - name: Setting up DB pgsql
70         if: ${{ matrix.db == 'pgsql' }}
71         uses: m4nu56/postgresql-action@v1
72         with:
73           postgresql version: 9.6
74           postgresql db: test
75           postgresql user: test
76           postgresql password: test
78       - name: Configuring git vars
79         uses: rlespinasse/github-slug-action@v3.x
81       - name: Setting up PHP ${{ matrix.php }}
82         uses: shivammathur/setup-php@v2
83         with:
84           php-version: ${{ matrix.php }}
85           coverage: none
87       - name: Checking out code from ${{ env.GITHUB_REF_SLUG }}
88         uses: actions/checkout@v2
90       - name: Setting up PHPUnit
91         env:
92           dbtype: ${{ matrix.db }}
93         run: |
94           echo "pathtophp=$(which php)" >> $GITHUB_ENV # Inject installed pathtophp to env. The template config needs it.
95           cp .github/workflows/config-template.php config.php
96           mkdir ../moodledata
97           sudo locale-gen en_AU.UTF-8
98           php admin/tool/phpunit/cli/init.php --no-composer-self-update
100       - name: Running PHPUnit tests
101         env:
102           dbtype: ${{ matrix.db }}
103         run: vendor/bin/phpunit -v