1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ '**' ]
6+ tags : [ 'v*' ]
7+
8+ jobs :
9+ test :
10+ runs-on : ubuntu-latest
11+ strategy :
12+ fail-fast : false
13+ matrix :
14+ firebird-version : [3, 4, 5]
15+ include :
16+ - firebird-version : 3
17+ db-file : fbtest30.fdb
18+ docker-image : firebirdsql/firebird:3
19+ - firebird-version : 4
20+ db-file : fbtest40.fdb
21+ docker-image : firebirdsql/firebird:4
22+ - firebird-version : 5
23+ db-file : fbtest50.fdb
24+ docker-image : firebirdsql/firebird:5
25+
26+ steps :
27+ - uses : actions/checkout@v4
28+
29+ - name : Set up Python
30+ uses : actions/setup-python@v5
31+ with :
32+ python-version : ' 3.11'
33+
34+ - name : Install Hatch
35+ run : pip install hatch
36+
37+ - name : Start Firebird Docker container
38+ 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
56+ 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
71+ 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+
104+ - name : Run tests
105+ run : hatch test -- --host=localhost --port=3050 -v
106+ env :
107+ FIREBIRD_VERSION : ${{ matrix.firebird-version }}
108+
109+ - name : Stop Firebird container
110+ if : always()
111+ run : |
112+ docker logs firebird
113+ docker stop firebird
114+ docker rm firebird
115+
116+ build :
117+ needs : test
118+ runs-on : ubuntu-latest
119+ steps :
120+ - uses : actions/checkout@v4
121+
122+ - name : Set up Python
123+ uses : actions/setup-python@v5
124+ with :
125+ python-version : ' 3.11'
126+
127+ - name : Install Hatch
128+ run : pip install hatch
129+
130+ - name : Build package
131+ run : hatch build
132+
133+ - name : Upload artifacts
134+ uses : actions/upload-artifact@v4
135+ with :
136+ name : dist
137+ path : dist/
138+
139+ release :
140+ if : startsWith(github.ref, 'refs/tags/v')
141+ needs : build
142+ runs-on : ubuntu-latest
143+ permissions :
144+ contents : write
145+ packages : write # Required for publishing to GitHub Packages
146+ steps :
147+ - uses : actions/checkout@v4
148+
149+ - name : Download artifacts
150+ uses : actions/download-artifact@v4
151+ with :
152+ name : dist
153+ path : dist/
154+
155+ - name : Create GitHub Release
156+ uses : softprops/action-gh-release@v2
157+ with :
158+ tag_name : ${{ github.ref_name }}
159+ generate_release_notes : true
160+ files : dist/*
161+
162+ - name : Publish to GitHub Packages
163+ uses : pypa/gh-action-pypi-publish@release/v1
164+ with :
165+ repository-url : https://pypi.pkg.github.com/fdcastel
0 commit comments