-
-
Notifications
You must be signed in to change notification settings - Fork 13
171 lines (145 loc) · 5.36 KB
/
ci.yml
File metadata and controls
171 lines (145 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: CI
on:
push:
branches: [ '**' ]
tags: [ 'v*' ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
firebird-version: [3, 4, 5]
include:
- firebird-version: 3
db-file: fbtest30.fdb
docker-image: firebirdsql/firebird:3
- firebird-version: 4
db-file: fbtest40.fdb
docker-image: firebirdsql/firebird:4
- firebird-version: 5
db-file: fbtest50.fdb
docker-image: firebirdsql/firebird:5
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Hatch
run: pip install hatch
- name: Start Firebird Docker container
run: |
# Create a tmp directory that will be bind-mounted to the container
# This ensures test files are accessible at the same paths inside and outside the container
mkdir -p /tmp/firebird-test
# Start Firebird container with /tmp bind-mounted
# Configure RemoteAuxPort for Firebird events support
docker run -d \
--name firebird \
-e FIREBIRD_ROOT_PASSWORD=masterkey \
-e ISC_PASSWORD=masterkey \
-e FIREBIRD_CONF_RemoteAuxPort=3051 \
-p 3050:3050 \
-p 3051:3051 \
-v /tmp:/tmp:rw \
${{ matrix.docker-image }}
- name: Wait for Firebird to be ready
run: |
echo "Waiting for Firebird to be fully ready..."
for i in {1..30}; do
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
echo "Firebird is ready!"
exit 0
fi
echo "Waiting... ($i/30)"
sleep 2
done
echo "Firebird failed to start"
docker logs firebird
exit 1
- name: Extract and install Firebird client library from container
run: |
# List available libraries in container for debugging
echo "Available libraries in container:"
docker exec firebird ls -la /opt/firebird/lib/ || docker exec firebird ls -la /usr/lib/
# Find and extract client library from the running container
# Different versions may have different file names or locations
LIB_PATH=""
if docker exec firebird test -f /opt/firebird/lib/libfbclient.so.2; then
# Get the actual file path by resolving the symlink
LIB_PATH=$(docker exec firebird readlink -f /opt/firebird/lib/libfbclient.so.2)
elif docker exec firebird test -f /opt/firebird/lib/libfbclient.so; then
LIB_PATH=$(docker exec firebird readlink -f /opt/firebird/lib/libfbclient.so)
elif docker exec firebird test -f /usr/lib/libfbclient.so; then
LIB_PATH=$(docker exec firebird readlink -f /usr/lib/libfbclient.so)
elif docker exec firebird test -f /usr/lib/x86_64-linux-gnu/libfbclient.so.2; then
LIB_PATH=$(docker exec firebird readlink -f /usr/lib/x86_64-linux-gnu/libfbclient.so.2)
else
echo "Could not find libfbclient.so in container"
exit 1
fi
echo "Copying library from: $LIB_PATH"
# Copy the actual library file (not the symlink)
docker cp firebird:$LIB_PATH ${{ github.workspace }}/libfbclient.so
# Install to system
sudo cp ${{ github.workspace }}/libfbclient.so /usr/lib/x86_64-linux-gnu/
sudo ldconfig
# Verify installation
ldconfig -p | grep libfbclient
- name: Run tests
run: hatch test -- --host=localhost --port=3050 -v
env:
FIREBIRD_VERSION: ${{ matrix.firebird-version }}
- name: Stop Firebird container
if: always()
run: |
docker logs firebird
docker stop firebird
docker rm firebird
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Hatch
run: pip install hatch
- name: Build package
run: hatch build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for trusted publishing to PyPI
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
generate_release_notes: true
files: dist/*
# GitHub Packages does not currently support Python packages -- https://github.com/orgs/community/discussions/8542
# - name: Publish to GitHub Packages
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://pypi.pkg.github.com/fdcastel
- name: Publish to PyPI
if: github.repository == 'FirebirdSQL/python3-driver'
uses: pypa/gh-action-pypi-publish@release/v1