3434 ./configure
3535 make
3636
37+ - name : Validate extension
38+ run : |
39+ echo "=== Validating FastCSV extension ==="
40+
41+ # Test if extension loads
42+ php -m | grep fastcsv || (echo "Extension not loaded!" && exit 1)
43+
44+ # Test basic functionality
45+ php -r "
46+ if (!extension_loaded('fastcsv')) {
47+ echo 'Extension not loaded!' . PHP_EOL;
48+ exit(1);
49+ }
50+ echo 'FastCSV extension loaded successfully' . PHP_EOL;
51+
52+ // Test if classes are available
53+ if (class_exists('FastCSVReader')) {
54+ echo 'FastCSVReader class available' . PHP_EOL;
55+ } else {
56+ echo 'FastCSVReader class not found!' . PHP_EOL;
57+ exit(1);
58+ }
59+
60+ if (class_exists('FastCSVWriter')) {
61+ echo 'FastCSVWriter class available' . PHP_EOL;
62+ } else {
63+ echo 'FastCSVWriter class not found!' . PHP_EOL;
64+ exit(1);
65+ }
66+ "
67+
68+ echo "=== Extension validation passed ==="
69+
3770 - name : Create dist directory
3871 run : mkdir -p dist/releases/${{ github.ref_name }}/linux/php${{ matrix.php-version }}
3972
@@ -74,6 +107,39 @@ jobs:
74107 ./configure
75108 make
76109
110+ - name : Validate extension
111+ run : |
112+ echo "=== Validating FastCSV extension ==="
113+
114+ # Test if extension loads
115+ php -m | grep fastcsv || (echo "Extension not loaded!" && exit 1)
116+
117+ # Test basic functionality
118+ php -r "
119+ if (!extension_loaded('fastcsv')) {
120+ echo 'Extension not loaded!' . PHP_EOL;
121+ exit(1);
122+ }
123+ echo 'FastCSV extension loaded successfully' . PHP_EOL;
124+
125+ // Test if classes are available
126+ if (class_exists('FastCSVReader')) {
127+ echo 'FastCSVReader class available' . PHP_EOL;
128+ } else {
129+ echo 'FastCSVReader class not found!' . PHP_EOL;
130+ exit(1);
131+ }
132+
133+ if (class_exists('FastCSVWriter')) {
134+ echo 'FastCSVWriter class available' . PHP_EOL;
135+ } else {
136+ echo 'FastCSVWriter class not found!' . PHP_EOL;
137+ exit(1);
138+ }
139+ "
140+
141+ echo "=== Extension validation passed ==="
142+
77143 - name : Create dist directory
78144 run : mkdir -p dist/releases/${{ github.ref_name }}/macos/php${{ matrix.php-version }}
79145
@@ -91,8 +157,209 @@ jobs:
91157 overwrite : true
92158 include-hidden-files : false
93159
160+ get-extension-matrix :
161+ runs-on : ubuntu-latest
162+ outputs :
163+ matrix : ${{ steps.extension-matrix.outputs.matrix }}
164+ steps :
165+ - name : Checkout
166+ uses : actions/checkout@v4
167+ with :
168+ submodules : recursive
169+ - name : Get the extension matrix
170+ id : extension-matrix
171+ uses : php/php-windows-builder/extension-matrix@v1
172+
173+ build-windows :
174+ needs : get-extension-matrix
175+ runs-on : ${{ matrix.os }}
176+ strategy :
177+ matrix : ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
178+ steps :
179+ - name : Checkout
180+ uses : actions/checkout@v4
181+ with :
182+ submodules : recursive
183+ - name : Build the extension
184+ uses : php/php-windows-builder/extension@v1
185+ with :
186+ php-version : ${{ matrix.php-version }}
187+ arch : ${{ matrix.arch }}
188+ ts : ${{ matrix.ts }}
189+ - name : Create dist directory
190+ run : mkdir -p dist/releases/${{ github.ref_name }}/windows/php${{ matrix.php-version }}-${{ matrix.arch }}-${{ matrix.ts }}
191+ shell : bash
192+ - name : Copy Windows DLL
193+ run : |
194+ # Find the built DLL (the PHP Windows builder creates it with a specific naming pattern)
195+ if [ -f "php_fastcsv.dll" ]; then
196+ cp "php_fastcsv.dll" "dist/releases/${{ github.ref_name }}/windows/php${{ matrix.php-version }}-${{ matrix.arch }}-${{ matrix.ts }}/php_fastcsv.dll"
197+ elif [ -f "php_fastcsv-${{ matrix.php-version }}-${{ matrix.ts }}-vs16-${{ matrix.arch }}.dll" ]; then
198+ cp "php_fastcsv-${{ matrix.php-version }}-${{ matrix.ts }}-vs16-${{ matrix.arch }}.dll" "dist/releases/${{ github.ref_name }}/windows/php${{ matrix.php-version }}-${{ matrix.arch }}-${{ matrix.ts }}/php_fastcsv.dll"
199+ else
200+ echo "Looking for any DLL files..."
201+ find . -name "*.dll" -type f
202+ echo "ERROR: Could not find the built DLL file!"
203+ exit 1
204+ fi
205+ shell : bash
206+ - name : Upload Windows artifact
207+ uses : actions/upload-artifact@v4
208+ with :
209+ name : windows-builds-php${{ matrix.php-version }}-${{ matrix.arch }}-${{ matrix.ts }}
210+ path : dist/releases/${{ github.ref_name }}/windows/php${{ matrix.php-version }}-${{ matrix.arch }}-${{ matrix.ts }}
211+ if-no-files-found : warn
212+ compression-level : 6
213+ overwrite : true
214+ include-hidden-files : false
215+
216+ validate-release :
217+ needs : [build-linux, build-macos, build-windows]
218+ runs-on : ubuntu-latest
219+ steps :
220+ - uses : actions/checkout@v4
221+ with :
222+ submodules : true
223+ fetch-depth : 0
224+
225+ - name : Setup PHP for validation
226+ uses : shivammathur/setup-php@v2
227+ with :
228+ php-version : ' 8.2'
229+ tools : phpize
230+
231+ - name : Download all artifacts
232+ uses : actions/download-artifact@v4
233+ with :
234+ path : dist/releases/${{ github.ref_name }}
235+
236+ - name : Validate Linux builds
237+ run : |
238+ echo "=== Validating Linux builds ==="
239+
240+ # Find and validate Linux .so files
241+ for so_file in dist/releases/${{ github.ref_name }}/linux-builds-php*/fastcsv.so; do
242+ if [ -f "$so_file" ]; then
243+ echo "Validating: $so_file"
244+
245+ # Check file properties
246+ ls -la "$so_file"
247+ file "$so_file"
248+
249+ # Test if it's a valid shared object
250+ if ! file "$so_file" | grep -q "shared object"; then
251+ echo "ERROR: $so_file is not a valid shared object!"
252+ exit 1
253+ fi
254+
255+ echo "✓ $so_file is valid"
256+ fi
257+ done
258+
259+ - name : Validate macOS builds
260+ run : |
261+ echo "=== Validating macOS builds ==="
262+
263+ # Find and validate macOS .so files
264+ for so_file in dist/releases/${{ github.ref_name }}/macos-builds-php*/fastcsv.so; do
265+ if [ -f "$so_file" ]; then
266+ echo "Validating: $so_file"
267+
268+ # Check file properties
269+ ls -la "$so_file"
270+ file "$so_file"
271+
272+ # Test if it's a valid shared object
273+ if ! file "$so_file" | grep -q "shared object\|Mach-O"; then
274+ echo "ERROR: $so_file is not a valid shared object!"
275+ exit 1
276+ fi
277+
278+ echo "✓ $so_file is valid"
279+ fi
280+ done
281+
282+ - name : Validate Windows builds
283+ run : |
284+ echo "=== Validating Windows builds ==="
285+
286+ # Find and validate Windows .dll files
287+ for dll_file in dist/releases/${{ github.ref_name }}/windows-builds-php*/php_fastcsv.dll; do
288+ if [ -f "$dll_file" ]; then
289+ echo "Validating: $dll_file"
290+
291+ # Check file properties
292+ ls -la "$dll_file"
293+ file "$dll_file"
294+
295+ # Test if it's a valid DLL
296+ if ! file "$dll_file" | grep -q "PE32\|executable"; then
297+ echo "ERROR: $dll_file is not a valid Windows DLL!"
298+ exit 1
299+ fi
300+
301+ echo "✓ $dll_file is valid"
302+ fi
303+ done
304+
305+ - name : Run basic tests
306+ run : |
307+ echo "=== Running basic functionality tests ==="
308+
309+ # Create a temporary test file
310+ cat > test_fastcsv.php << 'EOF'
311+ <?php
312+ if (!extension_loaded('fastcsv')) {
313+ echo "ERROR: FastCSV extension not loaded!\n";
314+ exit(1);
315+ }
316+
317+ echo "✓ FastCSV extension loaded\n";
318+
319+ if (!class_exists('FastCSVReader')) {
320+ echo "ERROR: FastCSVReader class not found!\n";
321+ exit(1);
322+ }
323+
324+ echo "✓ FastCSVReader class available\n";
325+
326+ if (!class_exists('FastCSVWriter')) {
327+ echo "ERROR: FastCSVWriter class not found!\n";
328+ exit(1);
329+ }
330+
331+ echo "✓ FastCSVWriter class available\n";
332+
333+ // Test basic CSV operations
334+ try {
335+ $csv_data = "name,age,city\nJohn,25,New York\nJane,30,London";
336+ $temp_file = tempnam(sys_get_temp_dir(), 'test_csv');
337+ file_put_contents($temp_file, $csv_data);
338+
339+ $reader = new FastCSVReader($temp_file);
340+ $row = $reader->read();
341+
342+ if ($row && is_array($row) && count($row) === 3) {
343+ echo "✓ Basic CSV reading works\n";
344+ } else {
345+ echo "ERROR: Basic CSV reading failed!\n";
346+ exit(1);
347+ }
348+
349+ unlink($temp_file);
350+ echo "✓ All basic tests passed\n";
351+
352+ } catch (Exception $e) {
353+ echo "ERROR: Exception during testing: " . $e->getMessage() . "\n";
354+ exit(1);
355+ }
356+ EOF
357+
358+ # Run the test with PHP 8.2
359+ php test_fastcsv.php
360+
94361 create-release :
95- needs : [build-linux, build-macos ]
362+ needs : [validate-release ]
96363 runs-on : ubuntu-latest
97364 steps :
98365 - uses : actions/checkout@v4
0 commit comments