Skip to content

Commit 92c08cd

Browse files
authored
Merge pull request #80 from rosette-api/RCB-615-release-php-binding
Rcb 615 release php binding
2 parents b6f0b5f + ccd66bd commit 92c08cd

191 files changed

Lines changed: 272 additions & 29547 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ composer.lock
1919
vendor/
2020
bin/
2121
*.cache
22+
23+
# Code coverage
24+
coverage.xml
25+
coverage/

CI.Jenkinsfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// These are Debian images.
2-
def php_versions = [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2]
2+
def php_versions = [7.3, 7.4, 8.0, 8.1, 8.2]
33

44
def runVersion(sourceDir, ver) {
5-
mySonarOpts = "-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}"
5+
mySonarOpts = "-Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}"
66
if ("${env.CHANGE_ID}" != "null") {
77
mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.BRANCH_NAME}"
88
} else {
@@ -12,12 +12,15 @@ def runVersion(sourceDir, ver) {
1212
mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
1313
}
1414

15-
// Only run Sonar once. Use 7.4 until we get our 8.x ducks in a row.
16-
if (ver == 7.4) {
15+
// Only run Sonar once.
16+
// There is an equivalent check in CI.sh. Update both!!!!
17+
// The coverage tool version we are using doesn't like 8.2.
18+
// TODO: Add CS Fixer Execution somewhere in CI.sh during the 8.2 extras.
19+
if (ver == 8.1) {
1720
sonarExec = "cd /root/ && \
1821
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \
1922
unzip -q sonar-scanner-cli-4.8.0.2856-linux.zip && \
20-
cd /source && \
23+
cd /php-source && \
2124
/root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner ${mySonarOpts}"
2225
} else {
2326
sonarExec = "echo Skipping Sonar for this version."
@@ -27,9 +30,9 @@ def runVersion(sourceDir, ver) {
2730
sh "docker run --rm \
2831
--pull always \
2932
-e ROSETTE_API_KEY=${env.ROSETTE_API_KEY} \
30-
-v ${sourceDir}:/source \
33+
-v ${sourceDir}:/php-source \
3134
php:${ver}-cli \
32-
bash -c \"cd /source && \
35+
bash -c \"cd /php-source && \
3336
./CI.sh && \
3437
${sonarExec}\""
3538
}

CI.sh

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env bash
2-
set -ex
2+
set -e
33

44
this_script=$(basename "$0")
55

66
# Install some tools
77
echo "*** [${this_script}] Installing some OS packages"
8-
apt-get update
9-
apt-get install -y git wget zip
8+
apt-get update > /dev/null 2>&1
9+
apt-get install -y git wget zip > /dev/null 2>&1
1010

1111
# The composer installation steps via https://getcomposer.org/download/
1212
# and https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
@@ -28,7 +28,7 @@ echo "*** [${this_script}] Removing composer-setup.php"
2828
php -r "unlink('composer-setup.php');"
2929

3030
echo "*** [${this_script}] Changing to binding source directory"
31-
pushd /source
31+
pushd /php-source
3232

3333
# TODO: Review if we should be using a compose.lock file instead.
3434
echo "*** [${this_script}] Running composer update"
@@ -37,15 +37,46 @@ composer update
3737
echo "*** [${this_script}] Running composer install"
3838
composer install --prefer-source --no-interaction
3939

40-
echo "*** [${this_script}] Running phpspec"
41-
bin/phpspec run --config=phpspec.yml --bootstrap=./vendor/autoload.php --no-interaction --format=pretty
40+
#Install Xdebug coverage tool
41+
version=$(php -v | awk 'match($0, /PHP [78]\.[0-4]/) { print substr($0, RSTART, RLENGTH) } ' | awk '{print $2}')
42+
echo "*** [${this_script}] PHP version: $version"
43+
if [ "${version}" == "8.1" ]; then
44+
# Installation according to https://xdebug.org/docs/install#source
45+
echo "*** [${this_script}] Installing Xdebug coverage tool"
46+
cd /
47+
git clone https://github.com/xdebug/xdebug.git
48+
cd xdebug
49+
git checkout 3.1.5 > /dev/null 2>&1
50+
phpize
51+
./configure --enable-xdebug > /dev/null 2>&1
52+
make > /dev/null 2>&1
53+
make install > /dev/null 2>&1
54+
echo "zend_extension=xdebug" > /usr/local/etc/php/conf.d/99-xdebug.ini
55+
export XDEBUG_MODE=coverage
56+
cd /php-source
57+
echo "*** [${this_script}] Running phpspec"
58+
bin/phpspec run --config=phpspec.coverage.yml --bootstrap=./vendor/autoload.php --no-interaction --format=pretty
59+
else
60+
echo "*** [${this_script}] Skipping test coverage generation for this version"
61+
echo "*** [${this_script}] Running phpspec"
62+
bin/phpspec run --config=phpspec.yml --bootstrap=./vendor/autoload.php --no-interaction --format=pretty
63+
fi
4264

4365
echo "*** [${this_script}] Running examples"
4466
pushd examples
4567
for example in $(ls *.php); do
46-
echo "*** [${this_script}] Running ${example}"
47-
php ${example} --key ${ROSETTE_API_KEY}
48-
# TODO: Capture output in a file and only print it for errors.
68+
echo "*** [${this_script}] Running ${example} with PHP ${version}"
69+
php ${example} --key ${ROSETTE_API_KEY} > "${example}-output.txt" 2>&1
70+
# Disable error mode for grep
71+
set +e
72+
if grep -q Exception "${example}-output.txt"; then
73+
echo "*** [${this_script}] ${example} failed!"
74+
cat "${example}-output.txt"
75+
rm -f "${example}-output.txt"
76+
exit 1
77+
fi
78+
set -e
79+
rm -f "${example}-output.txt"
4980
done
5081

5182
echo "*** [${this_script}] Finished!"

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014-2015 Basis Technology Corporation.
1+
Copyright (c) 2014-2023 Basis Technology Corporation.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

classes.svg

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)