7 description: Additional options to apply to PHPUnit
15 runs-on: windows-latest
18 - name: Set git to use LF
20 git config --global core.autocrlf false
21 git config --global core.eol lf
23 - name: Checking out code
24 uses: actions/checkout@v4
26 - name: Configuring node & npm
27 uses: actions/setup-node@v4
29 node-version-file: '.nvmrc'
31 - name: Installing node stuff
37 - name: Looking for uncommitted changes
38 # Add all files to the git index and then run diff --cached to see all changes.
39 # This ensures that we get the status of all files, including new files.
40 # We ignore npm-shrinkwrap.json to make the tasks immune to npm changes.
43 git reset -- npm-shrinkwrap.json
44 git diff --cached --exit-code
47 runs-on: ${{ matrix.os }}
55 # Ideally we should use mysql/mariadb, but they are 4x slower without tweaks and configuration
56 # so let's run only postgres (1.5h vs 6h) only, If some day we want to improve the mysql runs,
57 # this is the place to enable them.
60 extensions: exif, fileinfo, gd, intl, pgsql, mysql, redis, soap, sodium, zip
64 extensions: exif, fileinfo, gd, intl, pgsql, mysql, redis, soap, sodium
67 - name: Setting up DB mysql
68 if: ${{ matrix.db == 'mysqli' }}
69 uses: shogo82148/actions-setup-mysql@v1
75 - name: Creating DB mysql
76 if: ${{ matrix.db == 'mysqli' }}
77 run: mysql --host 127.0.0.1 -utest -ptest -e 'CREATE DATABASE IF NOT EXISTS test COLLATE = utf8mb4_bin;';
79 - name: Setting up DB pgsql
80 if: ${{ matrix.db == 'pgsql' }}
82 # TODO: Remove these conf. modifications when php74 or php80 are lowest.
83 # Change to old md5 auth, because php73 does not support it.
84 # #password_encryption = scram-sha-256
85 (Get-Content "$env:PGDATA\postgresql.conf"). `
86 replace('#password_encryption = scram-sha-256', 'password_encryption = md5') | `
87 Set-Content "$env:PGDATA\postgresql.conf"
88 (Get-Content "$env:PGDATA\pg_hba.conf"). `
89 replace('scram-sha-256', 'md5') | `
90 Set-Content "$env:PGDATA\pg_hba.conf"
91 $pgService = Get-Service -Name postgresql*
92 Set-Service -InputObject $pgService -Status running -StartupType automatic
93 Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
94 & $env:PGBIN\psql --command="CREATE USER test PASSWORD 'test'" --command="\du"
96 - name: Creating DB pgsql
97 if: ${{ matrix.db == 'pgsql' }}
99 & $env:PGBIN\createdb --owner=test test
100 $env:PGPASSWORD = 'test'
101 & $env:PGBIN\psql --username=test --host=localhost --list test
103 - name: Configuring git vars
104 uses: rlespinasse/github-slug-action@v4
106 - name: Setting up PHP ${{ matrix.php }}
107 uses: shivammathur/setup-php@v2
109 php-version: ${{ matrix.php }}
110 extensions: ${{ matrix.extensions }}
111 ini-values: max_input_vars=5000
114 - name: Set git to use LF
116 git config --global core.autocrlf false
117 git config --global core.eol lf
119 - name: Checking out code from ${{ env.GITHUB_REF_SLUG }}
120 uses: actions/checkout@v4
122 # Needs to be done after php is available, git configured and Moodle checkout has happened.
123 - name: Setting up moodle-exttests service
125 git clone https://github.com/moodlehq/moodle-exttests.git
126 nssm install php-built-in C:\tools\php\php.exe -S localhost:8080 -t D:\a\moodle\moodle\moodle-exttests
127 nssm start php-built-in
129 - name: Setting up redis service
131 choco install redis-64 --version 3.0.503 --no-progress
132 nssm install redis redis-server
135 - name: Setting up PHPUnit
137 dbtype: ${{ matrix.db }}
140 echo "pathtophp=$(which php)" >> $GITHUB_ENV # Inject installed pathtophp to env. The template config needs it.
141 cp .github/workflows/config-template.php config.php
143 php admin/tool/phpunit/cli/init.php --no-composer-self-update
145 - name: Running PHPUnit tests
147 dbtype: ${{ matrix.db }}
148 phpunit_options: ${{ secrets.phpunit_options }}
149 run: vendor/bin/phpunit $phpunit_options ${{ inputs.phpunit_extra_options }}