Skip to content

Commit 499b898

Browse files
committed
QUAL: Add HURL test integration for Windows CI
- Add HURL test runner to Windows CI workflow - Include environment variables for test configuration - Update test execution step to run HURL tests when enabled
1 parent c54d911 commit 499b898

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

.github/workflows/windows-ci.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ env:
2222
DOLIBARR_LOG: documents/dolibarr.log
2323
PHPSERVER_LOG: phpserver.log
2424
PHPSERVER_DOMAIN_PORT: 127.0.0.1:8000 # could be 127.0.0.1:8000 if config modified
25+
DOLIPORT: 8000
26+
DOLIHOST: 127.0.0.1
27+
DOLIUSERNAME: admin
28+
DOLIPASSWORD: admin
29+
COOKIEJAR: "C:\\TEMP\\hurl_cookie${{ github.run_id }}.jar"
30+
RUN_HURL_TESTS: ${{ github.event_name == 'workflow_dispatch' || github.repository != 'Dolibarr/dolibarr' }}
2531
CACHE_KEY_PART: ${{ ( inputs.gh_event == 'pull_request' || github.event_name == 'pull_request' ) && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }}
2632
PHP_INI_SCAN_DIR: C:\myphpini
2733
CKEY: win-ci-2
@@ -38,6 +44,7 @@ jobs:
3844
steps:
3945
- name: Checkout code
4046
uses: actions/checkout@v5
47+
4148
- name: Setup PHP
4249
uses: shivammathur/setup-php@v2
4350
with:
@@ -82,6 +89,12 @@ jobs:
8289
# mariadb-version: ${{ matrix.mariadb-version }}
8390
database: travis # Specify your database name
8491

92+
- uses: gacts/install-hurl@v1
93+
if: ${{ env.RUN_HURL_TESTS == 'true' }}
94+
#with:
95+
# disable-cache: true # disable cache usage
96+
# version: 1.2.0 # `latest` by default, but you can set a specific version to install
97+
8598
- name: Create local php.ini with open_basedir restrictions
8699
shell: cmd
87100
# Objective: separate step, and before database initialisation to verify open_basedir restrictions
@@ -113,6 +126,8 @@ jobs:
113126
php -r "$d=__DIR__.'\documents/mytest';echo 'TEST PATH IS SHOWN: '.$d.PHP_EOL;"
114127
php -r "$d=__DIR__.'\documents/mytest';echo 'IS_DIR '.$d.' '.((int) is_dir($d)).PHP_EOL;"
115128
ECHO "The above should show 2 successful tests"
129+
REM SETTING FOR HURL
130+
116131
117132
- name: Run Bash script that Initialises the database
118133
# Note this is bash (MSYS) on Windows
@@ -153,21 +168,25 @@ jobs:
153168
cat htdocs/conf/conf.php
154169
ECHO "#[endgroup]"
155170
ECHO "==== START PHP server"
156-
start /B php -S %PHPSERVER_DOMAIN_PORT% -t htdocs >> %PHPSERVER_LOG% 2>&1
171+
start /B php -S %PHPSERVER_DOMAIN_PORT% -t htdocs > %PHPSERVER_LOG% 2>&1
157172
ECHO "#[group]==== Output from curl on PHP server"
158173
curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}"
159174
ECHO "#[endgroup]"
160175
ECHO "==== START PHPUNIT TESTS"
161176
REM 'DOSKEY' USED to recover error code (no pipefile equivalent in windows?)
162177
( php "%PHPROOT%\phpunit" -d memory_limit=-1 -c %CD%\test\phpunit\phpunittest.xml "test\phpunit\AllTests.php" --exclude-group WindowsWaitingForFix & call doskey /exename=err err=%%^^errorlevel%% ) | "${{ env.TEE }}" "${{ env.PHPUNIT_LOG }}"
178+
IF "${{ env.RUN_HURL_TESTS }}" == "true" (
179+
ECHO "==== START HURL TESTS (${{ env.COOKIEJAR }})"
180+
"C:\Program Files\Git\bin\bash.EXE" --noprofile --norc -e -o pipefail -c " export DOLIPORT='${{ env.DOLIPORT }}' ; export DOLIHOST='${{ env.DOLIHOST }}' ; export DOLIUSERNAME='${{ env.DOLIUSERNAME }}' ; export DOLIPASSWORD='${{ env.DOLIPASSWORD }}' ; export COOKIEJAR='${{ env.COOKIEJAR }}' ; test/hurl/run.sh" 2>&1 | "${{ env.TEE }}" -a "${{ env.PHPUNIT_LOG }}"
181+
)
163182
echo ""
164183
echo "Ensure that PHPUNIT completed (no early exit from code)"
165184
"${{ env.TAIL }}" -5 "${{ env.PHPUNIT_LOG }}" | "${{ env.GREP }}" -qE "(OK .*[0-9]+ tests.*[0-9]+ assertions|Tests: [0-9]+)" || EXIT /B 1
166185
echo "PHPUNIT seems to have completed with a test result, reuse the exit code"
167186
for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A
168187
169188
- name: Convert Raw Log to Annotations
170-
uses: mdeweerd/logToCheckStyle@v2025.1.1
189+
uses: mdeweerd/logToCheckStyle@v2025.11.2
171190
if: ${{ failure() }}
172191
with:
173192
in: ${{ env.PHPUNIT_LOG }}

test/hurl/run.sh

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,28 @@ exclude_patterns=()
5353
for arg in "$@"; do
5454
case "$arg" in
5555
--cookiefile=*)
56-
COOKIEJAR="${arg#--cookiefile=}"
56+
export COOKIEJAR="${arg#--cookiefile=}"
5757
;;
5858
--port=*)
59-
DOLIPORT="${arg#--port=}"
59+
export DOLIPORT="${arg#--port=}"
6060
;;
6161
--host=*)
62-
DOLIHOST="${arg#--host=}"
62+
export DOLIHOST="${arg#--host=}"
6363
;;
6464
--user=*)
65-
DOLIUSERNAME="${arg#--user=}"
65+
export DOLIUSERNAME="${arg#--user=}"
6666
;;
6767
--pass=*)
68-
DOLIPASSWORD="${arg#--pass=}"
68+
export DOLIPASSWORD="${arg#--pass=}"
6969
;;
7070
--apikey=*)
71-
DOLAPIKEY="${arg#--apikey=}"
71+
export DOLAPIKEY="${arg#--apikey=}"
7272
if [[ "${DOLAPIKEY}" != *": "* ]]; then
7373
DOLAPIKEY="DOLAPIKEY: ${DOLAPIKEY}"
7474
fi
7575
;;
7676
--suburl=*)
77-
DOLISUBURL="${arg#--suburl=}"
77+
export DOLISUBURL="${arg#--suburl=}"
7878
;;
7979
--exclude=*)
8080
exclude_patterns+=("${arg#--exclude=}")
@@ -299,11 +299,27 @@ else
299299
fi
300300
fi
301301

302-
./save_login_cookie.sh
303302
if [[ -z ${COOKIEJAR+x} ]]; then
304-
COOKIEJAR=/tmp/cookie.jar
303+
export COOKIEJAR
304+
COOKIEJAR=$(mktemp /tmp/hurltest_cookieXXXXXX.jar)
305+
fi
306+
307+
# Convert to Windows path if running on Windows (Git Bash/Cygwin)
308+
if command -v cygpath >/dev/null 2>&1; then
309+
COOKIEJAR=$(cygpath -w "$COOKIEJAR")
305310
fi
306311

312+
# Cleanup on exit
313+
cleanup() {
314+
rm -f "$COOKIEJAR"
315+
}
316+
trap cleanup EXIT
317+
318+
319+
# Login and save the cookie to $COOKIEJAR
320+
./save_login_cookie.sh
321+
322+
307323
# Build the find command for the GUI tests that do require authentication
308324
find_args=("gui/" "-type" "f" "-iwholename" "*/10*.hurl" "-not" "-iwholename" "save_login_cookie.hurl" "-not" "-iwholename" "*/00*.hurl")
309325
if [[ -n "${test_filters[*]}" ]]; then
@@ -332,4 +348,3 @@ print_info "2.b. Running GUI tests that do require authentication"
332348
if ! find "${find_args[@]}" -exec hurl --variable "hostnport=${hostnport}" --cookie "${COOKIEJAR}" --test "{}" +; then
333349
print_warning "2.b. No tests found or failed to run GUI tests that do require authentication."
334350
fi
335-
rm -rf "${COOKIEJAR}"

test/hurl/save_login_cookie.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
2-
# Copyright (C) 2025 MDW <[email protected].github.com>
3-
2+
# Copyright (C) 2025 Jon Bendtsen <jon.bendtsen.github@jonb.dk>
3+
# Copyright (C) 2025 MDW <[email protected]>
44

55
if [[ -z ${DOLIHOST+x} ]]; then
66
DOLIHOST="localhost"

0 commit comments

Comments
 (0)