Skip to content

Commit 6367b7e

Browse files
committed
ci(windows): add workflow to test bcpowmod on Windows with PHP 8.4
1 parent 949fd0a commit 6367b7e

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Test bcpowmod on Windows PHP 8.4
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
test-bcpowmod:
10+
runs-on: windows-latest
11+
strategy:
12+
matrix:
13+
php: ['8.4']
14+
arch: ['x64', 'x86']
15+
16+
name: PHP ${{ matrix.php }} - ${{ matrix.arch }}
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php }}
26+
extensions: bcmath
27+
coverage: none
28+
architecture: ${{ matrix.arch }}
29+
30+
- name: Display environment info
31+
run: |
32+
echo "=== System Information ==="
33+
echo "OS: $env:OS"
34+
echo "PROCESSOR_ARCHITECTURE: $env:PROCESSOR_ARCHITECTURE"
35+
echo "PROCESSOR_ARCHITEW6432: $env:PROCESSOR_ARCHITEW6432"
36+
echo ""
37+
echo "=== PHP Information ==="
38+
php -v
39+
php -r "echo 'PHP_INT_SIZE: ' . PHP_INT_SIZE . ' (bytes)' . PHP_EOL;"
40+
php -r "echo 'PHP_INT_MAX: ' . PHP_INT_MAX . PHP_EOL;"
41+
php -r "echo 'Architecture: ' . php_uname('m') . PHP_EOL;"
42+
php -r "echo 'bcmath extension: ' . (extension_loaded('bcmath') ? 'Loaded' : 'Not loaded') . PHP_EOL;"
43+
44+
- name: Test bcpowmod with PHP
45+
run: |
46+
echo "=== Testing bcpowmod('-9', '1024', '123') ==="
47+
php -r "echo 'Result: ' . var_export(bcpowmod('-9', '1024', '123'), true) . PHP_EOL;"
48+
49+
# More detailed test
50+
php -r "
51+
\$result = bcpowmod('-9', '1024', '123');
52+
echo 'bcpowmod result type: ' . gettype(\$result) . PHP_EOL;
53+
echo 'bcpowmod result value: ' . \$result . PHP_EOL;
54+
echo 'Expected value: 42' . PHP_EOL;
55+
echo 'Test ' . (\$result === '42' ? 'PASSED' : 'FAILED') . PHP_EOL;
56+
"
57+
58+
- name: Setup Python
59+
uses: actions/setup-python@v4
60+
with:
61+
python-version: '3.x'
62+
architecture: ${{ matrix.arch }}
63+
64+
- name: Test with Python for comparison
65+
run: |
66+
echo "=== Testing with Python ==="
67+
python -c "import platform; print(f'Python version: {platform.python_version()}'); print(f'Python architecture: {platform.machine()}'); print(f'Python platform: {platform.platform()}'); print(); result = pow(-9, 1024, 123); print(f'Python pow(-9, 1024, 123) = {result}'); print(f'Expected value: 42'); print(f'Test {\"PASSED\" if result == 42 else \"FAILED\"}')"
68+
69+
- name: Compare results
70+
run: |
71+
echo "=== Summary ==="
72+
73+
$phpResult = php -r "echo bcpowmod('-9', '1024', '123');"
74+
$pythonResult = python -c "print(pow(-9, 1024, 123))"
75+
76+
echo "PHP bcpowmod result: $phpResult"
77+
echo "Python pow result: $pythonResult"
78+
echo "Expected result: 42"
79+
80+
if ($phpResult -eq "42") {
81+
echo "✅ PHP result is correct"
82+
} else {
83+
echo "❌ PHP result is incorrect (got $phpResult, expected 42)"
84+
}
85+
86+
if ($pythonResult -eq "42") {
87+
echo "✅ Python result is correct"
88+
} else {
89+
echo "❌ Python result is incorrect (got $pythonResult, expected 42)"
90+
}
91+
92+
if ($phpResult -ne $pythonResult) {
93+
echo "⚠️ PHP and Python results differ!"
94+
echo "This suggests a platform-specific issue with PHP's bcmath extension"
95+
}
96+
97+
- name: Additional debugging info
98+
if: always()
99+
run: |
100+
echo "=== Additional Debug Information ==="
101+
102+
# Check if running on 32-bit or 64-bit
103+
php -r "
104+
echo 'Is 32-bit PHP: ' . (PHP_INT_SIZE === 4 ? 'Yes' : 'No') . PHP_EOL;
105+
echo 'Is 64-bit PHP: ' . (PHP_INT_SIZE === 8 ? 'Yes' : 'No') . PHP_EOL;
106+
"
107+
108+
# Test a few more cases
109+
echo ""
110+
echo "=== Testing other bcpowmod cases ==="
111+
php -r "
112+
echo 'bcpowmod(\"9\", \"1024\", \"123\") = ' . bcpowmod('9', '1024', '123') . PHP_EOL;
113+
echo 'bcpowmod(\"-9\", \"2\", \"123\") = ' . bcpowmod('-9', '2', '123') . PHP_EOL;
114+
echo 'bcpowmod(\"-9\", \"4\", \"123\") = ' . bcpowmod('-9', '4', '123') . PHP_EOL;
115+
"

0 commit comments

Comments
 (0)