Skip to content

Commit f38e1da

Browse files
authored
PCBC-859: configure Github Actions for Windows (#164)
Also fixes tests failures reported in PCBC-980
1 parent 486383d commit f38e1da

23 files changed

+553
-123
lines changed

.github/workflows/tests.yml

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,111 @@ jobs:
302302
require_tests: true
303303
annotate_only: true
304304

305+
server_linux_x86_64:
306+
needs:
307+
- source
308+
- build_linux_x86_64
309+
runs-on: ubuntu-22.04
310+
strategy:
311+
fail-fast: false
312+
matrix:
313+
php:
314+
- '8.3'
315+
ts:
316+
- nts
317+
- zts
318+
server:
319+
- 7.6.0
320+
- 7.2.4
321+
- 7.1.6
322+
- 7.0.5
323+
steps:
324+
- name: Setup PHP
325+
uses: shivammathur/setup-php@v2
326+
with:
327+
php-version: ${{ matrix.php }}
328+
extensions: json, mbstring, intl
329+
env:
330+
phpts: ${{ matrix.ts }}
331+
- name: Install cbdinocluster
332+
run: |
333+
mkdir -p "$HOME/bin"
334+
curl -L -o "$HOME/bin/cbdinocluster" https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.35/cbdinocluster-linux
335+
chmod a+x "$HOME/bin/cbdinocluster"
336+
echo "$HOME/bin" >> $GITHUB_PATH
337+
- name: Initialize cbdinocluster
338+
run: |
339+
cbdinocluster -v init --auto
340+
- name: Start couchbase cluster
341+
env:
342+
CLUSTERCONFIG: |
343+
nodes:
344+
- count: 2
345+
version: ${{ matrix.server }}
346+
services:
347+
- kv
348+
- n1ql
349+
- index
350+
- count: 1
351+
version: ${{ matrix.server }}
352+
services:
353+
- kv
354+
- fts
355+
- cbas
356+
docker:
357+
kv-memory: 1600
358+
run: |
359+
CLUSTER_ID=$(cbdinocluster -v allocate --def="${CLUSTERCONFIG}")
360+
CONNECTION_STRING=$(cbdinocluster -v connstr "${CLUSTER_ID}")
361+
cbdinocluster -v buckets add ${CLUSTER_ID} default --ram-quota-mb=100 --flush-enabled=true
362+
cbdinocluster -v buckets load-sample ${CLUSTER_ID} travel-sample
363+
echo "CLUSTER_ID=${CLUSTER_ID}" >> "$GITHUB_ENV"
364+
echo "TEST_CONNECTION_STRING=${CONNECTION_STRING}?dump_configuration=true" >> "$GITHUB_ENV"
365+
- uses: actions/download-artifact@v4
366+
with:
367+
name: couchbase-${{ needs.source.outputs.extension_version }}
368+
- uses: actions/download-artifact@v4
369+
with:
370+
name: scripts-${{ needs.source.outputs.extension_version }}
371+
- uses: actions/download-artifact@v4
372+
with:
373+
path: tests
374+
name: tests-${{ needs.source.outputs.extension_version }}
375+
- uses: actions/download-artifact@v4
376+
with:
377+
name: couchbase-${{ needs.source.outputs.extension_version }}-php${{ matrix.php }}-${{ matrix.ts }}-linux-x86_64
378+
- name: Test
379+
timeout-minutes: 60
380+
env:
381+
TEST_SERVER_VERSION: "${{ matrix.server }}"
382+
TEST_LOG_LEVEL: trace
383+
TEST_BUCKET: default
384+
TEST_USE_WAN_DEVELOPMENT_PROFILE: true
385+
OTHER_TEST_BUCKET: secBucket
386+
run: |
387+
tar xf couchbase-*-linux-x86_64.tgz
388+
ruby ./bin/test.rb
389+
- name: Publish Test Report
390+
uses: mikepenz/action-junit-report@v4.1.0
391+
if: always()
392+
with:
393+
check_name: 🐧server, php-${{ matrix.php }}-${{ matrix.ts }}
394+
report_paths: results.xml
395+
require_tests: true
396+
annotate_only: true
397+
- name: Collect server logs
398+
timeout-minutes: 15
399+
if: failure()
400+
run: |
401+
cbdinocluster -v collect-logs $CLUSTER_ID ./logs
402+
- name: Upload logs
403+
if: failure()
404+
uses: actions/upload-artifact@v4
405+
with:
406+
name: ${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.server }}-logs
407+
path: |
408+
logs/*
409+
305410
build_macos_x86_64:
306411
needs: source
307412
runs-on: macos-13
@@ -509,3 +614,126 @@ jobs:
509614
report_paths: results.xml
510615
require_tests: true
511616
annotate_only: true
617+
618+
build_windows:
619+
needs: source
620+
runs-on: windows-2019
621+
strategy:
622+
fail-fast: false
623+
matrix:
624+
php:
625+
- '8.3.4'
626+
- '8.2.17'
627+
- '8.1.27'
628+
ts:
629+
- nts
630+
- zts
631+
arch:
632+
- x64
633+
- x86
634+
steps:
635+
- name: Install dependencies
636+
shell: cmd
637+
run: |
638+
# winget install Git.Git
639+
# winget install Kitware.CMake
640+
# winget install NASM.NASM
641+
choco install nasm
642+
git clone --no-progress https://github.com/php/php-sdk-binary-tools.git c:\php\php-sdk
643+
git clone --no-progress --depth 1 --branch php-${{ matrix.php }} https://github.com/php/php-src.git c:\php\php-src
644+
- uses: actions/download-artifact@v4
645+
with:
646+
path: c:\php
647+
name: couchbase-${{ needs.source.outputs.extension_version }}
648+
- uses: actions/download-artifact@v4
649+
with:
650+
path: c:\php
651+
name: scripts-${{ needs.source.outputs.extension_version }}
652+
- name: Build
653+
working-directory: c:\php
654+
shell: cmd
655+
run: |
656+
7z x couchbase-${{ needs.source.outputs.extension_version }}.tgz -so | 7z x -aoa -si -ttar
657+
cd c:\php\php-src
658+
echo call buildconf.bat --add-modules-dir=c:\php > task.bat
659+
echo call configure.bat --disable-all --enable-cli ${{ matrix.ts == 'nts' && '--disable-zts' || '' }} --enable-couchbase >> task.bat
660+
echo nmake >> task.bat
661+
call c:\php\php-sdk\phpsdk-vs16-${{ matrix.arch }}.bat -t task.bat
662+
exit /b %ERRORLEVEL%
663+
- name: Package
664+
id: package
665+
working-directory: c:\php
666+
run: |
667+
$PhpVersion = ("${{ matrix.php }}" -split '\.')[0..1] -join '.'
668+
Add-Content -Path $env:GITHUB_OUTPUT -Value "php_version=$PhpVersion"
669+
$SourceDirectory = (Get-ChildItem -Path "c:\php" -Directory "couchbase-*" | Select-Object -First 1).FullName
670+
$DistName = "couchbase-${{ needs.source.outputs.extension_version }}-php${PhpVersion}-${{ matrix.ts }}-windows-${{ matrix.arch }}"
671+
New-Item -ItemType Directory -Path $DistName | Out-Null
672+
$FilesToCopy = Get-ChildItem -Path . -Filter "couchbase-*" -Include LICENSE,"Couchbase","GPBMetadata"
673+
Copy-Item -Path 90-couchbase.ini -Destination $DistName -Force
674+
Copy-Item -Path "${SourceDirectory}\LICENSE" -Destination $DistName -Force
675+
Copy-Item -Path "${SourceDirectory}\Couchbase" -Destination $DistName -Force -Recurse
676+
Copy-Item -Path "${SourceDirectory}\GPBMetadata" -Destination $DistName -Force -Recurse
677+
$FilesToCopy = Get-ChildItem -Path "C:\php\php-src\${{ matrix.arch == 'x64' && 'x64\\' || '' }}Release${{ matrix.ts == 'zts' && '_TS' || '' }}" -Filter "php_couchbase.*"
678+
foreach ($File in $FilesToCopy) {
679+
Write-Host "Copying file: $($File.FullName)"
680+
Copy-Item -Path $File.FullName -Destination $DistName -Force
681+
}
682+
$ZipArchive = $DistName + ".zip"
683+
Write-Host "Compressing $DistName directory into $ZipArchive"
684+
Compress-Archive -Path $DistName -DestinationPath $ZipArchive -CompressionLevel Optimal
685+
- uses: actions/upload-artifact@v4
686+
with:
687+
name: couchbase-${{ needs.source.outputs.extension_version }}-php${{ steps.package.outputs.php_version }}-${{ matrix.ts }}-windows-${{ matrix.arch }}
688+
path: |
689+
c:\php\couchbase-*-windows-${{ matrix.arch }}.zip
690+
691+
mock_windows:
692+
needs:
693+
- source
694+
- build_windows
695+
runs-on: windows-2019
696+
strategy:
697+
fail-fast: false
698+
matrix:
699+
php:
700+
- '8.1'
701+
- '8.2'
702+
- '8.3'
703+
ts:
704+
- nts
705+
- zts
706+
steps:
707+
- name: Setup PHP
708+
uses: shivammathur/setup-php@v2
709+
with:
710+
php-version: ${{ matrix.php }}
711+
extensions: json, mbstring, intl, sockets
712+
env:
713+
phpts: ${{ matrix.ts }}
714+
- uses: actions/download-artifact@v4
715+
with:
716+
name: couchbase-${{ needs.source.outputs.extension_version }}
717+
- uses: actions/download-artifact@v4
718+
with:
719+
name: scripts-${{ needs.source.outputs.extension_version }}
720+
- uses: actions/download-artifact@v4
721+
with:
722+
path: tests
723+
name: tests-${{ needs.source.outputs.extension_version }}
724+
- uses: actions/download-artifact@v4
725+
with:
726+
name: couchbase-${{ needs.source.outputs.extension_version }}-php${{ matrix.php }}-${{ matrix.ts }}-windows-x64
727+
- name: Test
728+
timeout-minutes: 60
729+
run: |
730+
Expand-Archive -Path couchbase-*-windows-x64.zip
731+
ruby ./bin/test.rb
732+
- name: Publish Test Report
733+
uses: mikepenz/action-junit-report@v4.1.0
734+
if: always()
735+
with:
736+
check_name: 🪟caves, php-${{ matrix.php }}-${{ matrix.ts }}
737+
report_paths: results.xml
738+
require_tests: true
739+
annotate_only: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
.deps
1111
.libs/
1212
.phpdoc
13+
.cache
1314
/*.out
15+
/logs
1416
/.idea/
1517
/.phpunit.result.cache
1618
/Debug/

0 commit comments

Comments
 (0)