зеркало из https://github.com/microsoft/msphpsql.git
350 строки
13 KiB
YAML
350 строки
13 KiB
YAML
# Add steps that build, run tests, deploy, and more:
|
|
# https://aka.ms/yaml
|
|
|
|
variables:
|
|
server: 'localhost,1433'
|
|
host: 'sql1'
|
|
sqlsrv_db: 'sqlsrv_testdb'
|
|
pdo_sqlsrv_db: 'pdo_sqlsrv_testdb'
|
|
uid: 'sa'
|
|
pwd: 'Password456!'
|
|
|
|
trigger:
|
|
- dev
|
|
- fix/*
|
|
|
|
pr:
|
|
- dev
|
|
|
|
jobs:
|
|
- job: macOS
|
|
pool:
|
|
vmImage: 'macos-latest'
|
|
steps:
|
|
- checkout: self
|
|
clean: true
|
|
fetchDepth: 1
|
|
|
|
- task: UsePythonVersion@0
|
|
inputs:
|
|
versionSpec: '3.x'
|
|
architecture: 'x64'
|
|
|
|
- script: |
|
|
brew tap
|
|
brew tap homebrew/core
|
|
brew reinstall autoconf automake libtool
|
|
php -v
|
|
displayName: 'Install PHP prerequisites'
|
|
|
|
- script: |
|
|
echo ready to build extensions
|
|
cd $(Build.SourcesDirectory)/source
|
|
chmod a+x packagize.sh
|
|
./packagize.sh
|
|
|
|
cd $(Build.SourcesDirectory)/source/sqlsrv
|
|
ls -al
|
|
phpize && ./configure && make && sudo make install
|
|
cp run-tests.php $(Build.SourcesDirectory)/test/functional/sqlsrv
|
|
|
|
cd $(Build.SourcesDirectory)/source/pdo_sqlsrv
|
|
ls -al
|
|
phpize && ./configure && make && sudo make install
|
|
cp run-tests.php $(Build.SourcesDirectory)/test/functional/pdo_sqlsrv
|
|
|
|
echo extension=pdo_sqlsrv.so >> `php --ini | grep "Loaded Configuration File" | sed -e "s|.*:\s*||"`
|
|
echo extension=sqlsrv.so >> `php --ini | grep "Loaded Configuration File" | sed -e "s|.*:\s*||"`
|
|
|
|
php --ri sqlsrv
|
|
php --ri pdo_sqlsrv
|
|
displayName: 'Build and install drivers'
|
|
|
|
- job: Linux
|
|
variables:
|
|
phpver: 8.1
|
|
pool:
|
|
vmImage: 'ubuntu-20.04'
|
|
steps:
|
|
- checkout: self
|
|
clean: true
|
|
fetchDepth: 1
|
|
|
|
- task: UsePythonVersion@0
|
|
inputs:
|
|
versionSpec: '3.x'
|
|
architecture: 'x64'
|
|
|
|
- script: |
|
|
sudo update-alternatives --set php /usr/bin/php$(phpver)
|
|
sudo update-alternatives --set phpize /usr/bin/phpize$(phpver)
|
|
sudo update-alternatives --set phar /usr/bin/phar$(phpver)
|
|
sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpver)
|
|
sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpver)
|
|
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpver)
|
|
sudo update-alternatives --set php-config /usr/bin/php-config$(phpver)
|
|
sudo phpdismod xdebug
|
|
php -version
|
|
displayName: 'Use PHP version $(phpver)'
|
|
|
|
- script: |
|
|
echo install ODBC and dependencies
|
|
sudo apt-get purge unixodbc
|
|
sudo apt autoremove
|
|
sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
|
|
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > mssql-release.list
|
|
sudo mv mssql-release.list /etc/apt/sources.list.d/
|
|
sudo apt-get update
|
|
sudo ACCEPT_EULA=Y apt-get install msodbcsql17 mssql-tools
|
|
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
|
|
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
|
|
source ~/.bashrc
|
|
sudo apt-get install unixodbc-dev
|
|
odbcinst --j
|
|
odbcinst -q -d -n "ODBC Driver 17 for SQL Server"
|
|
displayName: 'Install prerequisites'
|
|
|
|
- script: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install --upgrade requests
|
|
python -m pip install PyYAML
|
|
python -m pip install cpp-coveralls
|
|
displayName: 'Install coveralls (upgrade both pip and requests first)'
|
|
|
|
- script: |
|
|
docker pull mcr.microsoft.com/mssql/server:2019-latest
|
|
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=$(pwd)' -p 1433:1433 -h $(host) --name=$(host) -d mcr.microsoft.com/mssql/server:2019-latest
|
|
docker ps -a
|
|
sleep 10
|
|
docker exec -t $(host) /opt/mssql-tools/bin/sqlcmd -S $(server) -U $(uid) -P $(pwd) -Q 'select @@Version'
|
|
displayName: 'Run SQL Server for Linux'
|
|
|
|
- script: |
|
|
sudo sed -i 's/# en_US ISO-8859-1/en_US ISO-8859-1/g' /etc/locale.gen
|
|
sudo sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen
|
|
sudo sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
|
sudo sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
|
|
sudo sed -i 's/# zh_CN GB2312/zh_CN GB2312/g' /etc/locale.gen
|
|
sudo sed -i 's/# zh_CN.GB18030 GB18030/zh_CN.GB18030 GB18030/g' /etc/locale.gen
|
|
sudo locale-gen
|
|
export LANG='en_US.UTF-8'
|
|
export LANGUAGE='en_US:en'
|
|
export LC_ALL='en_US.UTF-8'
|
|
displayName: 'Generate locales for testing'
|
|
|
|
- script: |
|
|
echo setting env variables
|
|
export TEST_PHP_SQL_SERVER='$(server)'
|
|
export TEST_PHP_SQL_UID='$(uid)'
|
|
export TEST_PHP_SQL_PWD='$(pwd)'
|
|
|
|
cd $(Build.SourcesDirectory)/test/functional/setup
|
|
python ./setup_dbs.py -dbname $(sqlsrv_db)
|
|
python ./setup_dbs.py -dbname $(pdo_sqlsrv_db)
|
|
displayName: 'Set up test databases'
|
|
|
|
- script: |
|
|
echo ready to build extensions
|
|
sudo apt-get install -y php$(phpver)-intl
|
|
cd $(Build.SourcesDirectory)/source
|
|
chmod a+x packagize.sh
|
|
./packagize.sh
|
|
|
|
dest=`php --ini | grep "Scan for additional .ini files" | sudo sed -e "s|.*:\s*||"`/
|
|
|
|
cd $(Build.SourcesDirectory)/source/sqlsrv
|
|
ls -al
|
|
phpize && ./configure LDFLAGS="-lgcov" CXXFLAGS="-O0 --coverage" && make && sudo make install
|
|
cp run-tests.php $(Build.SourcesDirectory)/test/functional/sqlsrv
|
|
echo extension=sqlsrv.so >> 20-sqlsrv.ini
|
|
|
|
echo copying sqlsrv to $dest
|
|
sudo cp 20-sqlsrv.ini $dest
|
|
|
|
cd $(Build.SourcesDirectory)/source/pdo_sqlsrv
|
|
ls -al
|
|
phpize && ./configure LDFLAGS="-lgcov" CXXFLAGS="-O0 --coverage" && make && sudo make install
|
|
cp run-tests.php $(Build.SourcesDirectory)/test/functional/pdo_sqlsrv
|
|
echo extension=pdo_sqlsrv.so >> 30-pdo_sqlsrv.ini
|
|
|
|
echo copying pdo_sqlsrv to $dest
|
|
sudo cp 30-pdo_sqlsrv.ini $dest
|
|
|
|
sudo touch $dest/99-overrides.ini
|
|
sudo chmod 666 $dest/99-overrides.ini
|
|
|
|
php --ri sqlsrv
|
|
php --ri pdo_sqlsrv
|
|
displayName: 'Build and install drivers'
|
|
|
|
- script: |
|
|
cd $(Build.SourcesDirectory)/test/functional/sqlsrv
|
|
sed -i -e 's/TARGET_SERVER/'"$(server)"'/g' MsSetup.inc
|
|
sed -i -e 's/TARGET_DATABASE/'"$(sqlsrv_db)"'/g' MsSetup.inc
|
|
sed -i -e 's/TARGET_USERNAME/'"$(uid)"'/g' MsSetup.inc
|
|
sed -i -e 's/TARGET_PASSWORD/'"$(pwd)"'/g' MsSetup.inc
|
|
|
|
export LC_ALL='en_US.UTF-8'
|
|
php run-tests.php -P ./*.phpt --no-color --show-diff 2>&1 | tee ../sqlsrv.log
|
|
displayName: 'Run sqlsrv functional tests'
|
|
|
|
- script: |
|
|
cd $(Build.SourcesDirectory)/test/functional/pdo_sqlsrv
|
|
sed -i -e 's/TARGET_SERVER/'"$(server)"'/g' MsSetup.inc
|
|
sed -i -e 's/TARGET_DATABASE/'"$(pdo_sqlsrv_db)"'/g' MsSetup.inc
|
|
sed -i -e 's/TARGET_USERNAME/'"$(uid)"'/g' MsSetup.inc
|
|
sed -i -e 's/TARGET_PASSWORD/'"$(pwd)"'/g' MsSetup.inc
|
|
|
|
export LC_ALL='en_US.UTF-8'
|
|
php run-tests.php -P ./*.phpt --no-color --show-diff 2>&1 | tee ../pdo_sqlsrv.log
|
|
displayName: 'Run pdo_sqlsrv functional tests'
|
|
|
|
- script: |
|
|
cd $(Build.SourcesDirectory)
|
|
echo -e "service_name: Azure Pipelines\n" > .coveralls.yml
|
|
coveralls -i ./source/ -e ./source/shared/ -e ./test/ -e ./source/pdo_sqlsrv/shared/core_stream.cpp \
|
|
-E r'.*localization*' -E r'.*globalization*' --gcov-options '\-lp'
|
|
displayName: 'Invoke coveralls using repo token'
|
|
condition: false
|
|
env:
|
|
COVERALLS_REPO_TOKEN: $(repo_token)
|
|
TRAVIS_JOB_ID: $(Build.BuildId)
|
|
TRAVIS_BRANCH: $(Build.SourceBranchName)
|
|
PYTHONWARNINGS: ignore::yaml.YAMLLoadWarning
|
|
|
|
- script: |
|
|
docker logs -t $(host)
|
|
cd $(Build.SourcesDirectory)/test/functional/
|
|
for f in sqlsrv/*.diff; do ls $f 2>/dev/null; cat $f 2>/dev/null; echo ''; done || true
|
|
for f in pdo_sqlsrv/*.diff; do ls $f 2>/dev/null; cat $f 2>/dev/null; echo ''; done || true
|
|
python output.py
|
|
ls -l *.xml
|
|
displayName: 'Processing test results'
|
|
|
|
- task: PublishTestResults@2
|
|
inputs:
|
|
testResultsFormat: 'JUnit'
|
|
testResultsFiles: '*.xml'
|
|
failTaskOnFailedTests: true
|
|
searchFolder: '$(Build.SourcesDirectory)/test/functional/'
|
|
|
|
- script: |
|
|
docker stop $(host)
|
|
docker rm $(host)
|
|
displayName: 'Stop SQL Server for Linux'
|
|
condition: always()
|
|
|
|
- job: Windows
|
|
variables:
|
|
phpVersion: 8.1
|
|
pool:
|
|
vmImage: 'windows-2019'
|
|
steps:
|
|
- checkout: self
|
|
clean: true
|
|
fetchDepth: 1
|
|
|
|
- task: UsePythonVersion@0
|
|
inputs:
|
|
versionSpec: '3.x'
|
|
architecture: 'x64'
|
|
|
|
- script: |
|
|
dir C:\tools\php\php*
|
|
dir C:\tools\php\ext\
|
|
echo extension_dir=C:\tools\php\ext >> C:\tools\php\php.ini
|
|
php --ini
|
|
php -v
|
|
displayName: 'Check PHP'
|
|
|
|
- powershell: |
|
|
cd $(Build.SourcesDirectory)\test\functional\sqlsrv
|
|
(Get-Content .\MsSetup.inc) | ForEach-Object { $_ -replace "TARGET_SERVER", "$(host)" -replace "TARGET_DATABASE", "$(sqlsrv_db)" -replace "TARGET_USERNAME", "$(uid)" -replace "TARGET_PASSWORD", "$(pwd)" } | Set-Content .\MsSetup.inc
|
|
Select-String $(host) .\MsSetup.inc
|
|
Select-String $(sqlsrv_db) .\MsSetup.inc
|
|
cd $(Build.SourcesDirectory)\test\functional\pdo_sqlsrv
|
|
(Get-Content .\MsSetup.inc) | ForEach-Object { $_ -replace "TARGET_SERVER", "$(host)" -replace "TARGET_DATABASE", "$(pdo_sqlsrv_db)" -replace "TARGET_USERNAME", "$(uid)" -replace "TARGET_PASSWORD", "$(pwd)" } | Set-Content .\MsSetup.inc
|
|
Select-String $(host) .\MsSetup.inc
|
|
Select-String $(pdo_sqlsrv_db) .\MsSetup.inc
|
|
displayName: 'Update connection credentials'
|
|
condition: false
|
|
|
|
- powershell: |
|
|
$client = New-Object Net.WebClient
|
|
$client.DownloadFile('https://download.microsoft.com/download/a/e/b/aeb7d4ff-ca20-45db-86b8-8a8f774ce97b/en-US/17.8.1.1/x64/msodbcsql.msi', 'c:\projects\msodbcsql.msi')
|
|
$client.DownloadFile('https://download.microsoft.com/download/0/e/6/0e63d835-3513-45a0-9cf0-0bc75fb4269e/EN/x64/MsSqlCmdLnUtils.msi', 'MsSqlCmdLnUtils.msi')
|
|
dir *.msi
|
|
displayName: 'Download ODBC msi and sql tools msi'
|
|
condition: false
|
|
|
|
- script: |
|
|
msiexec /i "msodbcsql.msi" /q IACCEPTMSODBCSQLLICENSETERMS=YES ADDLOCAL=ALL
|
|
reg query "HKLM\SOFTWARE\ODBC\odbcinst.ini\ODBC Driver 17 for SQL Server"
|
|
dir %WINDIR%\System32\msodbcsql*.dll
|
|
displayName: 'Install ODBC driver'
|
|
condition: false
|
|
|
|
# FOR SOME REASON the set up did not set the PATH
|
|
- script: |
|
|
msiexec /i "MsSqlCmdLnUtils.msi" /qn IACCEPTMSSQLCMDLNUTILSLICENSETERMS=YES
|
|
displayName: 'Install SQL command line utilities version 15'
|
|
condition: false
|
|
|
|
- powershell: |
|
|
$client = New-Object Net.WebClient
|
|
$client.Headers.Add("user-agent", "azure pipeline build")
|
|
$client.DownloadFile("http://windows.php.net/downloads/releases/releases.json", "releases.json");
|
|
$jsondata = Get-Content -Path .\releases.json | ConvertFrom-Json
|
|
$env:VERSION = $jsondata.{$(phpVersion)}.version
|
|
Write-Host "Latest PHP $(phpVersion) is ${env:VERSION}"
|
|
cd $(Build.SourcesDirectory)\buildscripts\
|
|
python builddrivers.py --PHPVER=${env:VERSION} --DRIVER=sqlsrv --ARCH=x64 --THREAD=nts --SOURCE=$(Build.SourcesDirectory)\source --TESTING --NO_RENAME
|
|
dir *sqlsrv*.dll
|
|
python builddrivers.py --PHPVER=${env:VERSION} --DRIVER=pdo_sqlsrv --ARCH=x64 --THREAD=nts --SOURCE=$(Build.SourcesDirectory)\source --TESTING --NO_RENAME
|
|
cp $(Build.SourcesDirectory)\buildscripts\php-sdk\phpdev\vs16\x64\php-${env:VERSION}-src\run-tests.php $(Build.SourcesDirectory)\test\functional\sqlsrv
|
|
cp $(Build.SourcesDirectory)\buildscripts\php-sdk\phpdev\vs16\x64\php-${env:VERSION}-src\run-tests.php $(Build.SourcesDirectory)\test\functional\pdo_sqlsrv
|
|
dir *sqlsrv*.dll
|
|
cp *sqlsrv*.dll C:\tools\php\ext\
|
|
displayName: 'Build drivers (separately) for the latest version of PHP $(phpVersion)'
|
|
|
|
- script: |
|
|
echo extension=php_sqlsrv.dll >> C:\tools\php\php.ini
|
|
echo extension=php_pdo_sqlsrv.dll >> C:\tools\php\php.ini
|
|
php --ri sqlsrv
|
|
php --ri pdo_sqlsrv
|
|
displayName: 'Load drivers'
|
|
condition: false
|
|
|
|
- script: |
|
|
docker pull microsoft/mssql-server-windows-developer
|
|
docker run -d --name sqlcontainer -h $(host) -p 1433:1433 -e sa_password=$(pwd) -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer
|
|
docker ps -a
|
|
displayName: 'Run SQL Server for Windows Server'
|
|
condition: false
|
|
|
|
- script: |
|
|
set path=C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;%path%
|
|
sqlcmd -S $(host) -U $(uid) -P $(pwd) -Q "SELECT @@Version"
|
|
set TEST_PHP_SQL_SERVER=$(host)
|
|
set TEST_PHP_SQL_UID=$(uid)
|
|
set TEST_PHP_SQL_PWD=$(pwd)
|
|
cd $(Build.SourcesDirectory)\test\functional\setup
|
|
python setup_dbs.py -dbname $(sqlsrv_db)
|
|
python setup_dbs.py -dbname $(pdo_sqlsrv_db)
|
|
displayName: 'Set up test databases'
|
|
condition: false
|
|
|
|
- script: |
|
|
cd $(Build.SourcesDirectory)\test\functional\sqlsrv
|
|
php run-tests.php -P sqlsrv_client_info.phpt
|
|
cd $(Build.SourcesDirectory)\test\functional\pdo_sqlsrv
|
|
php run-tests.php -P pdo_getAttribute_clientInfo.phpt
|
|
displayName: 'Smoke testing'
|
|
condition: false
|
|
|
|
- script: |
|
|
docker stop sqlcontainer
|
|
docker rm sqlcontainer
|
|
displayName: 'Stop SQL Server for Windows Server'
|
|
condition: false
|