1441 |
ariadna |
1 |
name: Windows Testing
|
|
|
2 |
|
|
|
3 |
on:
|
|
|
4 |
workflow_dispatch:
|
|
|
5 |
inputs:
|
|
|
6 |
phpunit_extra_options:
|
|
|
7 |
description: Additional options to apply to PHPUnit
|
|
|
8 |
required: false
|
|
|
9 |
default: ''
|
|
|
10 |
env:
|
|
|
11 |
php: 8.4
|
|
|
12 |
|
|
|
13 |
jobs:
|
|
|
14 |
Grunt:
|
|
|
15 |
runs-on: windows-latest
|
|
|
16 |
|
|
|
17 |
steps:
|
|
|
18 |
- name: Set git to use LF
|
|
|
19 |
run: |
|
|
|
20 |
git config --global core.autocrlf false
|
|
|
21 |
git config --global core.eol lf
|
|
|
22 |
|
|
|
23 |
- name: Checking out code
|
|
|
24 |
uses: actions/checkout@v4
|
|
|
25 |
|
|
|
26 |
- name: Configuring node & npm
|
|
|
27 |
uses: actions/setup-node@v4
|
|
|
28 |
with:
|
|
|
29 |
node-version-file: '.nvmrc'
|
|
|
30 |
|
|
|
31 |
- name: Installing node stuff
|
|
|
32 |
run: npm ci
|
|
|
33 |
|
|
|
34 |
- name: Running grunt
|
|
|
35 |
run: npx grunt
|
|
|
36 |
|
|
|
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.
|
|
|
41 |
run: |
|
|
|
42 |
git add .
|
|
|
43 |
git reset -- npm-shrinkwrap.json
|
|
|
44 |
git diff --cached --exit-code
|
|
|
45 |
|
|
|
46 |
PHPUnit:
|
|
|
47 |
runs-on: ${{ matrix.os }}
|
|
|
48 |
|
|
|
49 |
strategy:
|
|
|
50 |
fail-fast: false
|
|
|
51 |
matrix:
|
|
|
52 |
include:
|
|
|
53 |
- os: windows-latest
|
|
|
54 |
php: 8.4
|
|
|
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.
|
|
|
58 |
# db: mysqli
|
|
|
59 |
db: pgsql
|
|
|
60 |
extensions: exif, fileinfo, gd, intl, pgsql, mysql, redis, soap, sodium, zip
|
|
|
61 |
- os: windows-latest
|
|
|
62 |
php: 8.2
|
|
|
63 |
db: pgsql
|
|
|
64 |
extensions: exif, fileinfo, gd, intl, pgsql, mysql, redis, soap, sodium, zip
|
|
|
65 |
|
|
|
66 |
steps:
|
|
|
67 |
- name: Setting up DB mysql
|
|
|
68 |
if: ${{ matrix.db == 'mysqli' }}
|
|
|
69 |
uses: shogo82148/actions-setup-mysql@v1
|
|
|
70 |
with:
|
|
|
71 |
mysql-version: 8.4
|
|
|
72 |
user: test
|
|
|
73 |
password: test
|
|
|
74 |
|
|
|
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;';
|
|
|
78 |
|
|
|
79 |
- name: Setting up DB pgsql
|
|
|
80 |
if: ${{ matrix.db == 'pgsql' }}
|
|
|
81 |
run: |
|
|
|
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"
|
|
|
95 |
|
|
|
96 |
- name: Creating DB pgsql
|
|
|
97 |
if: ${{ matrix.db == 'pgsql' }}
|
|
|
98 |
run: |
|
|
|
99 |
& $env:PGBIN\createdb --owner=test test
|
|
|
100 |
$env:PGPASSWORD = 'test'
|
|
|
101 |
& $env:PGBIN\psql --username=test --host=localhost --list test
|
|
|
102 |
|
|
|
103 |
- name: Configuring git vars
|
|
|
104 |
uses: rlespinasse/github-slug-action@v4
|
|
|
105 |
|
|
|
106 |
- name: Setting up PHP ${{ matrix.php }}
|
|
|
107 |
uses: shivammathur/setup-php@v2
|
|
|
108 |
with:
|
|
|
109 |
php-version: ${{ matrix.php }}
|
|
|
110 |
extensions: ${{ matrix.extensions }}
|
|
|
111 |
ini-values: max_input_vars=5000
|
|
|
112 |
coverage: none
|
|
|
113 |
|
|
|
114 |
- name: Set git to use LF
|
|
|
115 |
run: |
|
|
|
116 |
git config --global core.autocrlf false
|
|
|
117 |
git config --global core.eol lf
|
|
|
118 |
|
|
|
119 |
- name: Checking out code from ${{ env.GITHUB_REF_SLUG }}
|
|
|
120 |
uses: actions/checkout@v4
|
|
|
121 |
|
|
|
122 |
# Needs to be done after php is available, git configured and Moodle checkout has happened.
|
|
|
123 |
- name: Setting up moodle-exttests service
|
|
|
124 |
run: |
|
|
|
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
|
|
|
128 |
|
|
|
129 |
- name: Setting up redis service
|
|
|
130 |
run: |
|
|
|
131 |
choco install redis --version 5.0.7 --no-progress
|
|
|
132 |
nssm install redis redis-server
|
|
|
133 |
nssm start redis
|
|
|
134 |
|
|
|
135 |
- name: Setting up PHPUnit
|
|
|
136 |
env:
|
|
|
137 |
dbtype: ${{ matrix.db }}
|
|
|
138 |
shell: bash
|
|
|
139 |
run: |
|
|
|
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
|
|
|
142 |
mkdir ../moodledata
|
|
|
143 |
php admin/tool/phpunit/cli/init.php --no-composer-self-update
|
|
|
144 |
|
|
|
145 |
- name: Running PHPUnit tests
|
|
|
146 |
env:
|
|
|
147 |
dbtype: ${{ matrix.db }}
|
|
|
148 |
phpunit_options: ${{ secrets.phpunit_options }}
|
|
|
149 |
run: vendor/bin/phpunit $phpunit_options ${{ inputs.phpunit_extra_options }}
|