|
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | test: |
10 | | - runs-on: ubuntu-latest |
| 10 | + runs-on: ${{ matrix.os }} |
11 | 11 | strategy: |
12 | 12 | fail-fast: false |
13 | 13 | matrix: |
14 | 14 | firebird-version: [3, 4, 5] |
| 15 | + os: [ubuntu-22.04, windows-latest] |
15 | 16 | include: |
16 | 17 | - firebird-version: 3 |
17 | 18 | db-file: fbtest30.fdb |
18 | | - docker-image: firebirdsql/firebird:3 |
| 19 | + fb-semver: '3.0.13' |
19 | 20 | - firebird-version: 4 |
20 | 21 | db-file: fbtest40.fdb |
21 | | - docker-image: firebirdsql/firebird:4 |
| 22 | + fb-semver: '4.0.6' |
22 | 23 | - firebird-version: 5 |
23 | 24 | db-file: fbtest50.fdb |
24 | | - docker-image: firebirdsql/firebird:5 |
25 | | - |
| 25 | + fb-semver: '5.0.3' |
| 26 | + |
| 27 | + defaults: |
| 28 | + run: |
| 29 | + shell: pwsh |
| 30 | + |
| 31 | + env: |
| 32 | + GITHUB_TOKEN: ${{ github.token }} |
| 33 | + |
26 | 34 | steps: |
27 | 35 | - uses: actions/checkout@v4 |
28 | | - |
| 36 | + |
29 | 37 | - name: Set up Python |
30 | 38 | uses: actions/setup-python@v5 |
31 | 39 | with: |
32 | 40 | python-version: '3.11' |
33 | | - |
| 41 | + |
34 | 42 | - name: Install Hatch |
35 | 43 | run: pip install hatch |
36 | | - |
37 | | - - name: Start Firebird Docker container |
| 44 | + |
| 45 | + - name: Install PSFirebird |
38 | 46 | run: | |
39 | | - # Create a tmp directory that will be bind-mounted to the container |
40 | | - # This ensures test files are accessible at the same paths inside and outside the container |
41 | | - mkdir -p /tmp/firebird-test |
42 | | - |
43 | | - # Start Firebird container with /tmp bind-mounted |
44 | | - # Configure RemoteAuxPort for Firebird events support |
45 | | - docker run -d \ |
46 | | - --name firebird \ |
47 | | - -e FIREBIRD_ROOT_PASSWORD=masterkey \ |
48 | | - -e ISC_PASSWORD=masterkey \ |
49 | | - -e FIREBIRD_CONF_RemoteAuxPort=3051 \ |
50 | | - -p 3050:3050 \ |
51 | | - -p 3051:3051 \ |
52 | | - -v /tmp:/tmp:rw \ |
53 | | - ${{ matrix.docker-image }} |
54 | | - |
55 | | - - name: Wait for Firebird to be ready |
| 47 | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted |
| 48 | + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser -ForceBootstrap -ErrorAction Continue |
| 49 | + Install-Module -Name PSFirebird -Force -AllowClobber -Scope CurrentUser -Repository PSGallery |
| 50 | +
|
| 51 | + - name: Create Firebird environment |
56 | 52 | run: | |
57 | | - echo "Waiting for Firebird to be fully ready..." |
58 | | - for i in {1..30}; do |
59 | | - if docker exec firebird /bin/bash -c "echo 'SELECT 1 FROM RDB\$DATABASE;' | /opt/firebird/bin/isql -u SYSDBA -p masterkey employee" &>/dev/null 2>&1; then |
60 | | - echo "Firebird is ready!" |
61 | | - exit 0 |
62 | | - fi |
63 | | - echo "Waiting... ($i/30)" |
64 | | - sleep 2 |
65 | | - done |
66 | | - echo "Firebird failed to start" |
67 | | - docker logs firebird |
68 | | - exit 1 |
69 | | - |
70 | | - - name: Extract and install Firebird client library from container |
| 53 | + $tempPath = if ($IsWindows) { $env:TEMP } else { '/tmp' } |
| 54 | + $fbPath = Join-Path $tempPath 'firebird-${{ matrix.firebird-version }}' |
| 55 | + New-FirebirdEnvironment -Version '${{ matrix.fb-semver }}' -Path $fbPath | Out-Null |
| 56 | + Write-Output "FB_PATH=$fbPath" >> $env:GITHUB_ENV |
| 57 | +
|
| 58 | + - name: Configure and start Firebird |
71 | 59 | run: | |
72 | | - # List available libraries in container for debugging |
73 | | - echo "Available libraries in container:" |
74 | | - docker exec firebird ls -la /opt/firebird/lib/ || docker exec firebird ls -la /usr/lib/ |
75 | | - |
76 | | - # Find and extract client library from the running container |
77 | | - # Different versions may have different file names or locations |
78 | | - LIB_PATH="" |
79 | | - if docker exec firebird test -f /opt/firebird/lib/libfbclient.so.2; then |
80 | | - # Get the actual file path by resolving the symlink |
81 | | - LIB_PATH=$(docker exec firebird readlink -f /opt/firebird/lib/libfbclient.so.2) |
82 | | - elif docker exec firebird test -f /opt/firebird/lib/libfbclient.so; then |
83 | | - LIB_PATH=$(docker exec firebird readlink -f /opt/firebird/lib/libfbclient.so) |
84 | | - elif docker exec firebird test -f /usr/lib/libfbclient.so; then |
85 | | - LIB_PATH=$(docker exec firebird readlink -f /usr/lib/libfbclient.so) |
86 | | - elif docker exec firebird test -f /usr/lib/x86_64-linux-gnu/libfbclient.so.2; then |
87 | | - LIB_PATH=$(docker exec firebird readlink -f /usr/lib/x86_64-linux-gnu/libfbclient.so.2) |
88 | | - else |
89 | | - echo "Could not find libfbclient.so in container" |
90 | | - exit 1 |
91 | | - fi |
92 | | - |
93 | | - echo "Copying library from: $LIB_PATH" |
94 | | - # Copy the actual library file (not the symlink) |
95 | | - docker cp firebird:$LIB_PATH ${{ github.workspace }}/libfbclient.so |
96 | | - |
97 | | - # Install to system |
98 | | - sudo cp ${{ github.workspace }}/libfbclient.so /usr/lib/x86_64-linux-gnu/ |
99 | | - sudo ldconfig |
100 | | - |
101 | | - # Verify installation |
102 | | - ldconfig -p | grep libfbclient |
103 | | - |
| 60 | + # Configure RemoteAuxPort for Firebird events support |
| 61 | + $confPath = Join-Path $env:FB_PATH 'firebird.conf' |
| 62 | + Write-FirebirdConfiguration -Path $confPath -Configuration @{ RemoteAuxPort = 3051 } |
| 63 | + # Start Firebird server |
| 64 | + Start-FirebirdInstance -Environment $env:FB_PATH | Out-Null |
| 65 | + # Wait for the server to be ready |
| 66 | + Write-Output "Waiting for Firebird to be ready..." |
| 67 | + for ($i = 1; $i -le 30; $i++) { |
| 68 | + try { |
| 69 | + $tcp = [System.Net.Sockets.TcpClient]::new('localhost', 3050) |
| 70 | + $tcp.Close() |
| 71 | + Write-Output "Firebird is ready!" |
| 72 | + break |
| 73 | + } catch { |
| 74 | + if ($i -eq 30) { Write-Error "Firebird failed to start"; exit 1 } |
| 75 | + Write-Output "Waiting... ($i/30)" |
| 76 | + Start-Sleep -Seconds 2 |
| 77 | + } |
| 78 | + } |
| 79 | +
|
| 80 | + - name: Find Firebird client library |
| 81 | + run: | |
| 82 | + if ($IsWindows) { |
| 83 | + $clientLib = Join-Path $env:FB_PATH 'fbclient.dll' |
| 84 | + } else { |
| 85 | + foreach ($name in @('lib/libfbclient.so.2', 'lib/libfbclient.so')) { |
| 86 | + $p = Join-Path $env:FB_PATH $name |
| 87 | + if (Test-Path $p) { $clientLib = $p; break } |
| 88 | + } |
| 89 | + } |
| 90 | + Write-Output "Found client library: $clientLib" |
| 91 | + Write-Output "FB_CLIENT_LIB=$clientLib" >> $env:GITHUB_ENV |
| 92 | +
|
104 | 93 | - name: Run tests |
105 | | - run: hatch test -- --host=localhost --port=3050 -v |
| 94 | + run: hatch test -- --host=localhost --port=3050 "--client-lib=$env:FB_CLIENT_LIB" -v |
106 | 95 | env: |
107 | 96 | FIREBIRD_VERSION: ${{ matrix.firebird-version }} |
108 | | - |
109 | | - - name: Stop Firebird container |
| 97 | + |
| 98 | + - name: Stop Firebird instance |
110 | 99 | if: always() |
111 | | - run: | |
112 | | - docker logs firebird |
113 | | - docker stop firebird |
114 | | - docker rm firebird |
| 100 | + run: Get-FirebirdInstance | Stop-FirebirdInstance |
115 | 101 |
|
116 | 102 | build: |
117 | 103 | needs: test |
|
0 commit comments