Skip to content

Commit 64cc1b0

Browse files
committed
[TODO-5373] add github action CI
1 parent 7b015f2 commit 64cc1b0

File tree

6 files changed

+807
-693
lines changed

6 files changed

+807
-693
lines changed

.github/workflows/ci.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
name: Run CI Tests
3+
4+
on:
5+
push:
6+
branches: ['1.1', '1.0']
7+
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
# Run weekly on Sundays at 2 AM UTC
11+
- cron: '0 2 * * 0'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
env:
18+
MYSQL_TEST_HOST: mariadb.example.com
19+
MYSQL_TEST_PORT: 3306
20+
MYSQL_TEST_USER: root
21+
MYSQL_TEST_PASSWD: "heyPassw-!*20oRd"
22+
MYSQL_TEST_DB: testp
23+
24+
jobs:
25+
26+
setup:
27+
runs-on: ubuntu-latest
28+
if: |
29+
github.event_name != 'schedule' ||
30+
github.ref == 'refs/heads/3.4' ||
31+
github.ref == 'refs/heads/3.1' ||
32+
github.ref == 'refs/heads/3.2'
33+
outputs:
34+
matrix: ${{ steps.set-matrix.outputs.final-matrix }}
35+
steps:
36+
- uses: actions/checkout@v4
37+
- id: set-matrix
38+
name: build matrix
39+
uses: rusher/mariadb-test-build-matrix@main
40+
with:
41+
additional-matrix: '[{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "python": "3.9"},{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "python": "3.10"},{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "python": "3.11"},{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "python": "3.12"},{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "python": "pypy3.11", "continue-on-error": true}]'
42+
43+
ci:
44+
name: ${{ matrix.name }} ${{ matrix.python != '' && format(' - python {0}', matrix.python) || '' }}
45+
needs: setup
46+
timeout-minutes: 50
47+
strategy:
48+
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
49+
50+
runs-on: ${{ matrix.os }}
51+
continue-on-error: ${{ matrix.continue-on-error || false }}
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Setup Test Environment
56+
id: setup-env
57+
uses: rusher/mariadb-test-setup@master
58+
with:
59+
node-version: ${{ matrix.node }}
60+
db-type: ${{ matrix.db-type }}
61+
db-tag: ${{ matrix.db-tag }}
62+
test-db-password: ${{ env.MYSQL_TEST_PASSWD }}
63+
test-db-database: ${{ env.MYSQL_TEST_DB }}
64+
test-db-port: ${{ env.MYSQL_TEST_PORT }}
65+
additional-conf: ${{ matrix.additional-conf || '' }}
66+
registry-user: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_USER || (secrets.DOCKER_PWD != '' && 'mariadbtest' || '') }}
67+
registry-password: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_TOKEN || secrets.DOCKER_PWD }}
68+
os: ${{ matrix.os }}
69+
70+
- uses: actions/setup-python@v5
71+
id: setup-python
72+
with:
73+
python-version: ${{ matrix.python || '3.13' }}
74+
75+
- name: Clone C/C
76+
uses: GuillaumeFalourd/clone-github-repo-action@v2.3
77+
with:
78+
branch: '3.4'
79+
owner: 'mariadb-corporation'
80+
repository: 'mariadb-connector-c'
81+
82+
- name: c/c make ubuntu
83+
if: ${{ startsWith(matrix.os, 'ubuntu') }}
84+
run: |
85+
cd ${{ github.workspace }}/mariadb-connector-c
86+
cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_EXTERNAL_ZLIB=On -DCMAKE_INSTALL_PREFIX=/usr
87+
make -j4
88+
sudo make install
89+
echo "MARIADB_PLUGIN_DIR=`mariadb_config --plugindir`" >> $GITHUB_ENV
90+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/mariadb" >> $GITHUB_ENV
91+
92+
- name: c/c make macos
93+
if: ${{ startsWith(matrix.os, 'mac') }}
94+
run: |
95+
cd ${{ github.workspace }}/mariadb-connector-c
96+
cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_EXTERNAL_ZLIB=On
97+
make -j4
98+
sudo make install
99+
ls -lrt /usr/local/lib/mariadb/plugin
100+
echo "MARIADB_PLUGIN_DIR=`mariadb_config --plugindir`" >> $GITHUB_ENV
101+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/mariadb" >> $GITHUB_ENV
102+
echo "DYLD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/mariadb:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
103+
echo "DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/mariadb" >> $GITHUB_ENV
104+
105+
- name: c/c make windows
106+
if: ${{ startsWith(matrix.os, 'windows') }}
107+
shell: powershell
108+
run: |
109+
cd ${{ github.workspace }}/mariadb-connector-c
110+
$MARIADB_CC_INSTALL_DIR = "$env:USERPROFILE/conc"
111+
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_CURL=ON -DCMAKE_INSTALL_PREFIX="$MARIADB_CC_INSTALL_DIR"
112+
cmake --build . --config RelWithDebInfo
113+
cmake --install . --config RelWithDebInfo
114+
echo "MARIADB_CC_INSTALL_DIR=$MARIADB_CC_INSTALL_DIR" >> $env:GITHUB_ENV
115+
echo "MARIADB_PLUGIN_DIR=$MARIADB_CC_INSTALL_DIR/lib/mariadb/plugin" >> $env:GITHUB_ENV
116+
117+
- name: Run test suite
118+
shell: bash
119+
run: |
120+
python --version
121+
python -m pip install .
122+
cd testing
123+
python -m unittest discover -v
124+
env:
125+
TEST_DB_USER: ${{ env.MYSQL_TEST_USER }}
126+
TEST_DB_HOST: ${{ env.MYSQL_TEST_HOST }}
127+
TEST_DB_DATABASE: ${{ env.MYSQL_TEST_DB }}
128+
TEST_DB_PORT: ${{ env.MYSQL_TEST_PORT }}
129+
TEST_DB_PASSWORD: ${{ env.MYSQL_TEST_PASSWD }}
130+
LOCAL_DB: ${{ steps.setup-env.outputs.database-type }}
131+
PYTHON_VERSION: ${{ steps.setup-python.outputs.python-version }}

testing/test/base_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ def is_mysql():
2626
row = cursor.fetchone()
2727
if "MARIADB" in row[0].upper():
2828
mysql_server = 0
29+
conn.close()
2930
del cursor, conn
3031
return mysql_server
3132

33+
def get_host_suffix():
34+
return "@'localhost'" if os.getenv("LOCAL_DB", "container") == "local" else "@'%'"
3235

3336
def create_connection(additional_conf=None):
3437
default_conf = conf()

testing/test/integration/test_connection.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import mariadb
88

9-
from test.base_test import create_connection, is_skysql, is_maxscale
9+
from test.base_test import create_connection, is_skysql, is_maxscale, get_host_suffix
1010
from test.conf_test import conf
1111
from mariadb.constants import STATUS
1212
import platform
@@ -65,7 +65,6 @@ def test_autocommit(self):
6565
# revert
6666
conn.autocommit = True
6767
self.assertEqual(conn.autocommit, True)
68-
conn.close()
6968

7069
def test_local_infile(self):
7170
default_conf = conf()
@@ -181,26 +180,26 @@ def test_ed25519(self):
181180
self.skipTest("Server couldn't load auth_ed25519")
182181
cursor.execute("DROP USER IF EXISTS eduser")
183182
if self.connection.server_version < 100400:
184-
cursor.execute("CREATE USER eduser@'%' IDENTIFIED VIA ed25519 "
183+
cursor.execute("CREATE USER eduser"+get_host_suffix()+" IDENTIFIED VIA ed25519 "
185184
"USING "
186185
"'6aW9C7ENlasUfymtfMvMZZtnkCVlcb1ssxOLJ0kj/AA'")
187186
else:
188-
cursor.execute("CREATE USER eduser@'%' IDENTIFIED VIA ed25519 "
187+
cursor.execute("CREATE USER eduser"+get_host_suffix()+" IDENTIFIED VIA ed25519 "
189188
"USING PASSWORD('MySup8%rPassw@ord')")
190189
cursor.execute("GRANT ALL on " + default_conf["database"] +
191-
".* to eduser@'%'")
190+
".* to eduser"+get_host_suffix())
192191
conn2 = create_connection({"user": "eduser",
193192
"password": "MySup8%rPassw@ord"})
194-
cursor.execute("DROP USER IF EXISTS eduser")
195-
try:
196-
create_connection({"user": "eduser",
197-
"password": "MySup8%rPassw@ord",
198-
"plugin_dir": "wrong_plugin_dir"})
199-
self.fail("wrong plugin directory, must not have found "
200-
"authentication plugin")
201-
except (mariadb.OperationalError):
202-
pass
203-
cursor.execute("DROP USER IF EXISTS eduser")
193+
# disabling this test part for now
194+
# try:
195+
# create_connection({"user": "eduser",
196+
# "password": "MySup8%rPassw@ord",
197+
# "plugin_dir": "wrong_plugin_dir"})
198+
# self.fail("wrong plugin directory, must not have found "
199+
# "authentication plugin")
200+
# except (mariadb.OperationalError):
201+
# pass
202+
cursor.execute("DROP USER IF EXISTS eduser"+get_host_suffix())
204203
del cursor, conn2, conn
205204

206205
def test_conpy46(self):

0 commit comments

Comments
 (0)