Skip to content

Commit

Permalink
Integrate Dev branch into Master
Browse files Browse the repository at this point in the history
  • Loading branch information
rogervila authored Feb 4, 2019
1 parent 08724a6 commit 60de490
Show file tree
Hide file tree
Showing 23 changed files with 626 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
build: false
version: appveyor-{branch}-{build}
shallow_clone: false
clone_folder: C:\projects\app

environment:
matrix:
- php_ver: 7.3.1
- php_ver: 7.2.14
- php_ver: 7.1.26

cache:
- '%APPDATA%\Composer'
- '%LOCALAPPDATA%\Composer'
- C:\tools\php -> .appveyor.yml
- C:\tools\composer.phar -> .appveyor.yml

init:
- SET PATH=C:\tools\php;%PATH%

install:
- ps: Set-Service wuauserv -StartupType Manual
- IF NOT EXIST C:\tools\php (choco install --yes --allow-empty-checksums php --version %php_ver% --params '/InstallDir:C:\tools\php')
- cd C:\tools\php
- copy php.ini-production php.ini
- echo date.timezone="UTC" >> php.ini
- echo memory_limit=512M >> php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_curl.dll >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- IF NOT EXIST C:\tools\composer.phar (cd C:\tools && appveyor DownloadFile https://getcomposer.org/composer.phar)
- php C:\tools\composer.phar --version
- cd C:\projects\app

before_test:
- cd C:\projects\app
- php C:\tools\composer.phar update --optimize-autoloader --no-interaction --no-progress --prefer-stable --no-ansi
- php C:\tools\composer.phar info -D | sort

test_script:
- cd C:\projects\app
- vendor\bin\phpunit
- chmod +x sonar-scanner
- touch sonar-project.properties
- php sonar-scanner
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/vendor
composer.lock
junit-logfile.xml
clover.xml
/tmp
sonar-project.properties
.scannerwork
5 changes: 5 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
preset: psr2

finder:
exclude:
- "vendor"
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: php

php:
- 7.1
- 7.2
- 7.3

cache:
directories:
- $HOME/.composer/cache

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev

script:
- vendor/bin/phpunit
- chmod +x sonar-scanner
- touch sonar-project.properties
- php sonar-scanner
- sonar-scanner -Dsonar.projectKey=rogervila_php-sonarqube-scanner -Dsonar.sources=. -Dsonar.exclusions='tmp/**, vendor/**, tests/**' -Dsonar.php.tests.reportPath=junit-logfile.xml -Dsonar.php.coverage.reportPaths=clover.xml

addons:
sonarcloud:
organization: "rogervila-github"
token:
secure: "zKPo2B8Sw1RAQLTpdAgeejocp0p/dmXJo+WBLOx19jpr9gORvJX1WlynDZqOVgXoMolebvMKmi02dK543sK17RIe6I2ytFukHqlrFYVHCuebcjD8UeY+uYhw2XPrzdYVbBDADvUExG0sJ3FUcdCu3M2fQkuhHCDCCKtYA2QeglAUlA8KaoQ3UwlSNhaHCrAvP1icZ9LDWI/X4n545wiva2ezTdGoVYeVZNWovKMByI8lq3qvidRga1gKV7d2w/Qm8ipbVCOd6yQJLF+a040nLLMTOpfpt36iU6ott/DD2X/Ib/TEMVHT6aVVJsc0iZ72nyFfjNgTxWOmSSKUhp+oBTvHg+1aA86kkfQuJUcXwxl63paf7aJ3pDEmzHJXB0k1qkkwwqEXNpkr+ecBkLPneLE0im6vkk7rbbae94Ep5AHP3NBQKS6N50YyWMjFnE2f4sEvmFAYbbN7IDDbkOhxQLhqJAl2eE1FN4DbtugF+wT59tqhyJDY/1twxe6Zydzr6jMTLNav9r+XsPh+O1Nx2IdDThemMSFUB0bWp6Y7NpvZTTgrT9tWUCIvBUnXpw3/kgwYi+gnEmaxEQR7NpJ9/5myoSEBzZpv76Svwu/LtfrN7VtAtoXnytS8zAfHsaQf02xwE3uUo0mL7zIUByKIl2n/zjDuWu5iybbmoHy+lFE="
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<p align="center"><img src="https://i.imgur.com/xcIhGwP.png" alt="Run SonarQube Scanner with composer" /></p>

[![Build Status](https://travis-ci.org/rogervila/php-sonarqube-scanner.svg?branch=master)](https://travis-ci.org/rogervila/php-sonarqube-scanner)
[![Build status](https://ci.appveyor.com/api/projects/status/weidwo98jcdrtkxm?svg=true)](https://ci.appveyor.com/project/roger-vila/php-sonarqube-scanner)


# Run SonarQube Scanner with composer

**Install the package as a dev requirement**

```
composer install rogervila/php-sonarqube-scanner --dev
```

> Make sure you have a `sonar-project.properties` on your project root!

**Run with composer**

```
vendor/bin/sonar-scanner
```

## License

This project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
44 changes: 44 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "rogervila/php-sonarqube-scanner",
"description": "Run SonarQube Scanner with composer",
"keywords": [
"sonarqube scanner php",
"sonar scanner php"
],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Roger Vilà",
"email": "[email protected]"
}
],
"require": {
"ext-zip": "*",
"crysalead/dir": "^2.0",
"tivie/php-os-detector": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
},
"autoload": {
"psr-4": {
"SonarScanner\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\SonarScanner\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"bin": [
"sonar-scanner"
],
"minimum-stability": "dev",
"prefer-stable": true
}
25 changes: 25 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="clover.xml"/>
<log type="junit" target="junit-logfile.xml"/>
</logging>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
Binary file added scanners/sonar-scanner-cli-3.3.0.1492-linux.zip
Binary file not shown.
Binary file not shown.
Binary file added scanners/sonar-scanner-cli-3.3.0.1492-windows.zip
Binary file not shown.
60 changes: 60 additions & 0 deletions sonar-scanner
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env php
<?php

if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

$autoloads = [
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php',
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php',
__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php',
];

foreach ($autoloads as $file) {
if (file_exists($file)) {
define('COMPOSER_AUTOLOAD_FILE', $file);

break;
}
}

unset($file);
unset($autoloads);

if (!defined('COMPOSER_AUTOLOAD_FILE')) {
fwrite(
STDERR,
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
' composer install' . PHP_EOL . PHP_EOL .
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
);

die(1);
}

require COMPOSER_AUTOLOAD_FILE;

$app = new \SonarScanner\App(
new \SonarScanner\Device\Detector()
);

try {
$app->run(getcwd());
} catch (\SonarScanner\Exceptions\PropertiesFileNotFoundException $e) {
fwrite(
STDERR,
'You need to set up a sonar-project.properties file:' . PHP_EOL . PHP_EOL .
' touch sonar-project.properties' . PHP_EOL . PHP_EOL .
'You can learn all about Sonar properties on https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner.' . PHP_EOL
);

die(1);
} catch (\Exception $e) {
fwrite(
STDERR,
'Unexpected error.' . PHP_EOL . 'Please, check the project issues on https://github.com/rogervila/php-sonarqube-scanner/issues' . PHP_EOL
);

die(1);
}
Loading

0 comments on commit 60de490

Please sign in to comment.