From 28d67af30ff47cecafd75d11916254d6f22ad29b Mon Sep 17 00:00:00 2001 From: RoDuth Date: Fri, 20 Dec 2024 08:31:54 +1000 Subject: [PATCH] appveyor add MSYS2 test --- appveyor.yml | 7 +++++++ appveyor/after_test.cmd | 8 ++++++-- appveyor/build_script.cmd | 33 +++++++++++++++++++++++++++++++++ appveyor/install.cmd | 11 +++++++++-- appveyor/test_script.cmd | 35 ++++++++++++++++++++++++++++++++++- 5 files changed, 89 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8053ce10..e3649eb3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -42,10 +42,17 @@ environment: MYSQL_PATH: "C:\\Program Files\\MySQL\\MySQL Server 8.0" # the cache should always be saved, even on failure, to be available for the next run APPVEYOR_SAVE_CACHE_ON_ERROR: "true" + TEST_MSYS2: "false" matrix: # all the Python versions to be tested, both 32-bit and 64-bit # ref: https://www.appveyor.com/docs/windows-images-software/#python + - PYTHON_HOME: "C:\\Python313-x64" + CHERE_INVOKING: 1 + MSYSTEM: UCRT64 + # breaks $python_arch in install.ps1 but we don't need it here. + PATH: C:\msys64\usr\bin;%PATH% + TEST_MSYS2: "true" - PYTHON_HOME: "C:\\Python313-x64" - PYTHON_HOME: "C:\\Python313" - PYTHON_HOME: "C:\\Python312-x64" diff --git a/appveyor/after_test.cmd b/appveyor/after_test.cmd index 5a6894f2..7ba6492d 100644 --- a/appveyor/after_test.cmd +++ b/appveyor/after_test.cmd @@ -1,3 +1,7 @@ +IF "%TEST_MSYS2%" == "true" ( + ECHO *** MSYS2 - Skipping generation of the wheel file + GOTO :end +) IF "%APVYR_GENERATE_WHEELS%" == "true" ( ECHO *** pip install build/wheel modules "%PYTHON_HOME%\python" -m pip install build wheel --quiet --no-warn-script-location @@ -7,8 +11,8 @@ IF "%APVYR_GENERATE_WHEELS%" == "true" ( ECHO. ECHO *** \dist directory listing: DIR /B dist - ECHO. ) ELSE ( ECHO *** Skipping generation of the wheel file - ECHO. ) +:end +ECHO. diff --git a/appveyor/build_script.cmd b/appveyor/build_script.cmd index e2a34261..35477834 100644 --- a/appveyor/build_script.cmd +++ b/appveyor/build_script.cmd @@ -14,11 +14,13 @@ ECHO APVYR_GENERATE_WHEELS : %APVYR_GENERATE_WHEELS% ECHO APVYR_VERBOSE : %APVYR_VERBOSE% ECHO. ECHO PYTHON_HOME : %PYTHON_HOME% +ECHO TEST_MSYS2 : %TEST_MSYS2% ECHO MSSQL_INSTANCE: %MSSQL_INSTANCE% ECHO POSTGRES_PATH : %POSTGRES_PATH% ECHO MYSQL_PATH : %MYSQL_PATH% ECHO. +IF "%TEST_MSYS2%" == "true" GOTO :msys2 ECHO *** Get build info and compiler for the current Python installation: "%PYTHON_HOME%\python" -c "import platform; print(platform.python_build(), platform.python_compiler())" @@ -51,4 +53,35 @@ ECHO. ECHO *** Get version of the built pyodbc module: "%PYTHON_HOME%\python" -c "import pyodbc; print(pyodbc.version)" +GOTO :end + +:msys2 +ECHO *** Get build info and compiler for the current Python installation: +bash -lc "python -c ""import platform; print(platform.python_build(), platform.python_compiler())""" + +ECHO. +bash -lc "python -m pip freeze --all" + +ECHO. +ECHO *** Installing pyodbc... +SET PYTHON_ARGS=. +IF "%APVYR_VERBOSE%" == "true" ( + SET PYTHON_ARGS=--verbose %PYTHON_ARGS% +) +SET PIP_BREAK_SYSTEM_PACKAGES=1 +bash -lc "python -m pip install %PYTHON_ARGS%" +IF ERRORLEVEL 1 ( + ECHO *** ERROR: pyodbc install failed + EXIT 1 +) + +ECHO. +ECHO *** pip freeze... +bash -lc "python -m pip freeze --all" + +ECHO. +ECHO *** Get version of the built pyodbc module: +bash -lc "python -c ""import pyodbc; print(pyodbc.version)""" + +:end ECHO. diff --git a/appveyor/install.cmd b/appveyor/install.cmd index 0fc1c902..c968371e 100644 --- a/appveyor/install.cmd +++ b/appveyor/install.cmd @@ -1,3 +1,10 @@ -ECHO *** pip install pytest and other dev requirements *** -"%PYTHON_HOME%\python" -m pip install -r requirements-dev.txt --quiet --no-warn-script-location +IF "%TEST_MSYS2%" == "true" ( + ECHO *** pacman install dev requirements *** + bash -lc "pacman --noconfirm -Syuu" + bash -lc "pacman --noconfirm -Syuu" + bash -lc "pacman --noconfirm --needed -S - < ./appveyor/mingw_pkglist.txt" +) ELSE ( + ECHO *** pip install pytest and other dev requirements *** + "%PYTHON_HOME%\python" -m pip install -r requirements-dev.txt --quiet --no-warn-script-location +) ECHO. diff --git a/appveyor/test_script.cmd b/appveyor/test_script.cmd index 0fe6405c..fe20b4b5 100644 --- a/appveyor/test_script.cmd +++ b/appveyor/test_script.cmd @@ -4,7 +4,11 @@ SET OVERALL_RESULT=0 REM Output a list of the ODBC drivers available to pyodbc ECHO *** Available ODBC Drivers: -"%PYTHON_HOME%\python" -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))" +IF "%TEST_MSYS2%" == "true" ( + bash -lc "python -c ""import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))""" +) ELSE ( + "%PYTHON_HOME%\python" -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))" +) REM check if any testing should be done at all @@ -43,6 +47,14 @@ IF ERRORLEVEL 1 ( ) +REM check if only msys2 tests +IF "%TEST_MSYS2%" == "true" ( + ECHO. + ECHO *** testing MSYS2 + GOTO :msys2 +) + + :mssql2 REM Native Client 11.0 is so old, it might not be available on the server SET DRIVER={SQL Server Native Client 11.0} @@ -216,6 +228,27 @@ IF "%APVYR_VERBOSE%" == "true" ( %PYTHON_ARGS% "tests\mysql_test.py" IF ERRORLEVEL 1 SET OVERALL_RESULT=1 +GOTO :end + +:msys2 +SET DRIVER={ODBC Driver 17 for SQL Server} +SET PYODBC_SQLSERVER=Driver=%DRIVER%;Server=%MSSQL_INSTANCE%;Database=test_db;UID=sa;PWD=Password12!; +ECHO. +ECHO *** Run tests using driver: "%DRIVER%" +bash -lc "python appveyor/test_connect.py '%PYODBC_SQLSERVER%'" +IF ERRORLEVEL 1 ( + ECHO *** ERROR: Could not connect using the connection string: + ECHO "%PYODBC_SQLSERVER%" + SET OVERALL_RESULT=1 + GOTO :end +) +SET PYTHON_ARGS=-m pytest +IF "%APVYR_VERBOSE%" == "true" ( + SET PYTHON_ARGS=%PYTHON_ARGS% --verbose +) +bash -lc "python %PYTHON_ARGS% tests/sqlserver_test.py" +IF ERRORLEVEL 1 SET OVERALL_RESULT=1 + :end ECHO.