Skip to content

Commit

Permalink
AIRO-1561 Adding Sonarqube Scanner (Unity-Technologies#3)
Browse files Browse the repository at this point in the history
* Initial sonarqube commit

* Unit test, Sonar yml fixes

* Sonarqube fixes, 3P notice update

* Switch to prod key
  • Loading branch information
at669 authored Dec 15, 2021
1 parent c89b68a commit a02ed21
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 34 deletions.
62 changes: 62 additions & 0 deletions .yamato/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
csharp:
name: Sonarqube C# Scan
agent:
type: Unity::metal::macmini
image: package-ci/mac
flavor: m1.mac
variables:
PROJECT_PATH: TestVhacd
SONARQUBE_PROJECT_KEY: ai-robotics-vhacd-csharp
SONARQUBE_PROJECT_BASE_DIR: /Users/bokken/build/output/Unity-Technologies/VHACD/com.unity.robotics.vhacd
MSBUILD_SLN_PATH: ./TestVhacd/TestVhacd.sln
PROJECT_ROOT: /Users/bokken/build/output/Unity-Technologies/VHACD/
UNITY_VERSION: 2020.3.21f1
commands:
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-npm
- unity-downloader-cli -u $UNITY_VERSION -c Editor
- brew install mono corretto
- curl https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.2.1.31210/sonar-scanner-msbuild-5.2.1.31210-net46.zip -o sonar-scanner-msbuild-net46.zip -L
- unzip sonar-scanner-msbuild-net46.zip -d ~/sonar-scanner-msbuild
- chmod a+x ~/sonar-scanner-msbuild/sonar-scanner-4.6.1.2450/bin/sonar-scanner
- .Editor/Unity.app/Contents/MacOS/Unity -projectPath $PROJECT_PATH -batchmode -quit -nographics -logFile - -executeMethod "UnityEditor.SyncVS.SyncSolution"
- command: |
cd $PROJECT_PATH
for file in *.csproj; do sed -i.backup "s/^[[:blank:]]*<ReferenceOutputAssembly>false<\/ReferenceOutputAssembly>/<ReferenceOutputAssembly>true<\/ReferenceOutputAssembly>/g" $file; rm $file.backup; done
cd $PROJECT_ROOT
- mono ~/sonar-scanner-msbuild/SonarScanner.MSBuild.exe begin /k:$SONARQUBE_PROJECT_KEY /d:sonar.host.url=$SONARQUBE_ENDPOINT_URL_PRD /d:sonar.login=$SONARQUBE_TOKEN_PRD /d:sonar.projectBaseDir=$SONARQUBE_PROJECT_BASE_DIR
- msbuild $MSBUILD_SLN_PATH
- mono ~/sonar-scanner-msbuild/SonarScanner.MSBuild.exe end /d:sonar.login=$SONARQUBE_TOKEN_PRD
triggers:
cancel_old_ci: true
expression: |
((pull_request.target eq "main" OR pull_request.target eq "dev")
AND NOT pull_request.push.changes.all match "**/*.md") OR
(push.branch eq "main" OR push.branch eq "dev")
standard:
name: Sonarqube Standard Scan
agent:
type: Unity::VM
image: robotics/ci-ubuntu20:latest
flavor: i1.large
variables:
SONARQUBE_PROJECT_KEY: ai-robotics-vhacd-standard
ROOT_DIR: /home/bokken/build/output/Unity-Technologies/VHACD
SRC_DIR: /home/bokken/build/output/Unity-Technologies/VHACD/src
BUILD_WRAPPER_DIR: /home/bokken/build/output/Unity-Technologies/VHACD/build_wrapper_output_directory
commands:
- curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip -o sonar-scanner-linux.zip -L
- unzip sonar-scanner-linux.zip -d ~/sonar-scanner
- curl $SONARQUBE_ENDPOINT_URL_PRD/static/cpp/build-wrapper-linux-x86.zip -o sonar-build-wrapper-linux.zip -L
- unzip sonar-build-wrapper-linux.zip -d ~/sonar-build-wrapper
- mkdir build
- cd build
- cmake $SRC_DIR
- ~/sonar-build-wrapper/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir $BUILD_WRAPPER_DIR make
- cd $ROOT_DIR
- ~/sonar-scanner/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY -Dsonar.sources=$SRC_FOLDER -Dsonar.host.url=$SONARQUBE_ENDPOINT_URL_PRD -Dsonar.login=$SONARQUBE_TOKEN_PRD -Dsonar.cfamily.build-wrapper-output=$BUILD_WRAPPER_DIR
triggers:
cancel_old_ci: true
expression: |
((pull_request.target eq "main" OR pull_request.target eq "dev")
AND NOT pull_request.push.changes.all match "**/*.md") OR
(push.branch eq "main" OR push.branch eq "dev")
78 changes: 47 additions & 31 deletions .yamato/yamato-config.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
name: VHACD Unit Tests
agent:
type: Unity::VM
image: robotics/ci-ubuntu20:v0.1.0-795910
flavor: i1.large
variables:
COVERAGE_EXPECTED: 0
PATH: /root/.local/bin:/home/bokken/bin:/home/bokken/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/sbin:/home/bokken/.npm-global/bin
commands:
- git submodule update --init --recursive
- python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
- unity-downloader-cli -u 2020.3.21f1 -c editor -c StandaloneSupport-IL2CPP -c Linux --wait --published
- git clone git@github.cds.internal.unity3d.com:unity/utr.git utr
- utr/utr --testproject=./TestVhacd --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --enable-code-coverage --coverage-results-path=../test-results --coverage-options="assemblyFilters:+Unity.Robotics.VHACD,+Unity.Robotics.VHACD.Editor;generateHtmlReport;generateBadgeReport;generateAdditionalMetrics"
# check test coverage
- command: |
linecoverage=$(cat test-results/Report/Summary.xml | grep Linecoverage | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
echo "Line coverage: $linecoverage%"
if (( $(echo "$linecoverage < $COVERAGE_EXPECTED" | bc -l) ))
then echo "ERROR: Code coverage is under threshold of $COVERAGE_EXPECTED%" && exit 1
fi
triggers:
cancel_old_ci: true
expression: |
((pull_request.target eq "main" OR pull_request.target eq "dev")
AND NOT pull_request.push.changes.all match "**/*.md") OR
(push.branch eq "main" OR push.branch eq "dev")
artifacts:
logs:
paths:
- "test-results/**/*"
# {% assign platforms = "linux mac windows" | split: " " %}
{% assign platforms = "linux mac" | split: " " %}

{% for platform in platforms %}
{{platform}}:
name: VHACD Unit Tests ({{platform}})
agent:
{% if platform == "linux" %}
type: Unity::VM
image: robotics/ci-ubuntu20:v0.1.0-795910
flavor: i1.large
{% elsif platform == "mac" %}
type: Unity::metal::macmini
image: package-ci/mac
flavor: m1.mac
# {% elsif platform == "windows" %}
# type: Unity::VM
# image: slough-ops/win10-base:stable
# flavor: b1.medium
{% endif %}
variables:
COVERAGE_EXPECTED: 0
PATH: /root/.local/bin:/home/bokken/bin:/home/bokken/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/sbin:/home/bokken/.npm-global/bin
commands:
- git submodule update --init --recursive
- python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
- unity-downloader-cli -u 2020.3.21f1 -c editor -c StandaloneSupport-IL2CPP -c Linux --wait --published
- git clone git@github.cds.internal.unity3d.com:unity/utr.git utr
- utr/utr --testproject=./TestVhacd --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --enable-code-coverage --coverage-results-path=../test-results --coverage-options="assemblyFilters:+Unity.Robotics.VHACD,+Unity.Robotics.VHACD.Editor;generateHtmlReport;generateBadgeReport;generateAdditionalMetrics"
# check test coverage
- command: |
linecoverage=$(cat test-results/Report/Summary.xml | grep Linecoverage | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
echo "Line coverage: $linecoverage%"
if (( $(echo "$linecoverage < $COVERAGE_EXPECTED" | bc -l) ))
then echo "ERROR: Code coverage is under threshold of $COVERAGE_EXPECTED%" && exit 1
fi
triggers:
cancel_old_ci: true
expression: |
((pull_request.target eq "main" OR pull_request.target eq "dev")
AND NOT pull_request.push.changes.all match "**/*.md") OR
(push.branch eq "main" OR push.branch eq "dev")
artifacts:
logs:
paths:
- "test-results/**/*"
{% endfor %}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,26 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

### Added

Added Sonarqube Scanner, multiplatform Yamato testing

### Changed

### Deprecated

### Removed

### Fixed

## [0.0.1-preview] - 2021-12-14

### Upgrade Notes

### Known Issues

### Added

### Changed

Created VHACD Unity package

### Deprecated
Expand Down
48 changes: 45 additions & 3 deletions Third Party Notices.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
Component name: jasonmeisel/v-hacd-unity<br/>
Copyright 2017-2020 Jason Meisel<br/>
Component name: jasonmeisel/v-hacd-unity

License Type: Apache 2.0

Copyright 2017-2020 Jason Meisel

```
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at<br/>
http://www.apache.org/licenses/LICENSE-2.0<br/>
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
```

---

Component name: kmammou/v-hacd

License Type: BSD 3-clause

```
Copyright (c) 2011, Khaled Mamou (kmamou at gmail dot com)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

0 comments on commit a02ed21

Please sign in to comment.