Skip to content

Commit

Permalink
Azure and SonarCloud setup
Browse files Browse the repository at this point in the history
Signed-off-by: ¨Christina Tempelaar-Lietz¨ <xlietz@gmail.com>
  • Loading branch information
xlietz committed Jul 12, 2019
1 parent 8da3670 commit 65098c8
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 13 deletions.
96 changes: 83 additions & 13 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,95 @@
# Azure CI
# Azure CI build file
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema

jobs:
# ------------------------------------------------------------------------------
# Linux
# ------------------------------------------------------------------------------
# Note: 'agentImage' is the Microsoft-hosted agent. 'containerImage' is the
# Docker container where the build occurs.
# Note: 'containerImage' images are hosted on DockerHub.

# TODO: Move Docker images to ASWF DockerHub account

- job: Linux
strategy:
matrix:
CentOS 7 VFX CY2019:
agentImage: 'ubuntu-16.04'
containerImage: aswfstaging/ci-base:2019
cxxCompiler: g++
cCompiler: gcc
installSh: ''
pool:
vmImage: 'ubuntu-16.04'
container: aswfstaging/ci-base:2019
vmImage: $(agentImage)
container: $[ variables['containerImage'] ]

steps:
- bash: |
mkdir build
cd build
cmake ..
make -j4
displayName: Build
- bash: |
cd build
ctest -T Test --output-on-failure -VV -E PyImathNumpyTest
displayName: Test
- template: share/ci/templates/checkout.yml
- bash: $(installSh)
displayName: Install dependencies
condition: and(succeeded(), variables['installSh'])


- template: share/ci/templates/configure.yml
parameters:
cxxCompiler: $(cxxCompiler)
cCompiler: $(cCompiler)

- template: share/ci/templates/build.yml
parameters:
cxxCompiler: $(cxxCompiler)
cCompiler: $(cCompiler)
cmakeOpts: -- -j4

- task: PublishTestResults@2
condition: succeededOrFailed()
displayName: 'Publish test results'
inputs:
testResultsFormat: 'cTest'
testResultsFiles: '**/Test*.xml'
failTaskOnFailedTests: true
#pool:
# vmImage: 'ubuntu-16.04'
# container: aswfstaging/ci-base:2019
# steps:
# - bash: |
# mkdir _build
# cd _build
# cmake -DOPENEXR_BUILD_VIEWERS=OFF ..
# echo "Working directory $PWD"
# export LD_LIBRARY_PATH=$PWD/IlmBase/Half:$PWD/IlmBase/IlmThread:$PWD/IlmBase/Iex:$PWD/IlmBase/IexMath:$PWD/IlmBase/Imath:$PWD/OpenEXR/IlmImf:$PWD/OpenEXR/IlmImfUtil:$LD_LIBRARY_PATH
# echo `ls $PWD/IlmBase/Half`
# echo $LD_LIBRARY_PATH
# echo "Hello World"
# make -j4
# echo `ls $PWD/IlmBase/Half`
# displayName: Build
# - bash: |
# cd _build
# ctest -T Test --output-on-failure -VV -E PyImathNumpyTest
# displayName: Test

# ------------------------------------------------------------------------------
# SonarCloud static analysis
# ------------------------------------------------------------------------------
- job: SonarCloud
displayName: SonarCloud Ubuntu 16.04 VFX CY2019
condition: in(variables['Build.Reason'], 'Manual', 'Schedule')
pool:
vmImage: 'ubuntu-16.04'
container: aswfstaging/ci-base:2019

steps:
- template: share/ci/templates/checkout.yml
- template: share/ci/templates/configure.yml
parameters:
cxxFlags: -g -O0 -fprofile-arcs -ftest-coverage
cmakeOpts: |
-DCMAKE_EXE_LINKER_FLAGS="-lgcov" \
-DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON
- template: share/ci/templates/build_sonar.yml



23 changes: 23 additions & 0 deletions share/ci/scripts/linux/install_sonar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -ex

SONAR_VERSION="$1"

mkdir _sonar
cd _sonar

wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip
mv build-wrapper-linux-x86 /var/opt/.
ln -s /var/opt/build-wrapper-linux-x86/build-wrapper-linux-x86-64 /usr/bin/build-wrapper-linux-x86-64
echo $(build-wrapper-linux-x86-64 --help)

wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_VERSION}-linux.zip
unzip sonar-scanner-cli-${SONAR_VERSION}-linux.zip
mv sonar-scanner-${SONAR_VERSION}-linux /var/opt/.
ln -s /var/opt/sonar-scanner-${SONAR_VERSION}-linux/bin/sonar-scanner /usr/bin/sonar-scanner
echo $(sonar-scanner --help)

cd ..
rm -rf _sonar
17 changes: 17 additions & 0 deletions share/ci/scripts/linux/run_gcov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
!/usr/bin/env bash

set -ex

mkdir _coverage
cd _coverage

# The sed command below converts from:
# ../_build/src/OpenEXR/CMakeFiles/OpenColorIO.dir/ops/Exponent.gcno
# to:
# ../src/OpenEXR/ops/Exponent.cpp

for g in $(find ../_build -name "*.gcno" -type f); do
gcov -l -p -o $(dirname "$g") $(echo "$g" | sed -e 's/\/_build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')
done

cd ..
28 changes: 28 additions & 0 deletions share/ci/templates/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# azure-pipelines template file
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

parameters:
buildType: Release
cxxCompiler: ''
cCompiler: ''
cmakeOpts: ''

steps:
- bash: |
if [ "$CXXCOMPILER" ]; then
export CXX="$CXXCOMPILER"
fi
if [ "$CCOMPILER" ]; then
export CC="$CCOMPILER"
fi
export LD_LIBRARY_PATH=$PWD/IlmBase/Half:$PWD/IlmBase/IlmThread:$PWD/IlmBase/Iex:$PWD/IlmBase/IexMath:$PWD/IlmBase/Imath:$PWD/OpenEXR/IlmImf:$PWD/OpenEXR/IlmImfUtil:$LD_LIBRARY_PATH
cmake --build . \
--target install \
--config ${{ parameters.buildType }} \
${{ parameters.cmakeOpts }}
workingDirectory: _build
displayName: Build OpenEXR

- template: test.yml


31 changes: 31 additions & 0 deletions share/ci/templates/build_sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# azure-pipelines template file
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

# Note: This is currently Linux only

parameters:
cxxCompiler: ''
cCompiler: ''

steps:
- bash: |
if [ "$CXXCOMPILER" ]; then
export CXX="$CXXCOMPILER"
fi
if [ "$CCOMPILER" ]; then
export CC="$CCOMPILER"
fi
export LD_LIBRARY_PATH=$PWD/IlmBase/Half:$PWD/IlmBase/IlmThread:$PWD/IlmBase/Iex:$PWD/IlmBase/IexMath:$PWD/IlmBase/Imath:$PWD/OpenEXR/IlmImf:$PWD/OpenEXR/IlmImfUtil:$LD_LIBRARY_PATH
build-wrapper-linux-x86-64 --out-dir bw_output make clean all
workingDirectory: _build
displayName: Build OpenEXR with build-wrapper

- template: test.yml

- bash: share/ci/scripts/linux/run_gcov.sh
displayName: Generate code coverage report

- bash: sonar-scanner -X -Dsonar.login=$SONAR_TOKEN
env:
SONAR_TOKEN: $(tokens.sonarCloud)
displayName: Run sonar-scanner
8 changes: 8 additions & 0 deletions share/ci/templates/checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# azure-pipelines template file
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

steps:
- checkout: self
clean: true
fetchDepth: 50
displayName: Checkout OpenEXR source
66 changes: 66 additions & 0 deletions share/ci/templates/configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# azure-pipelines template file
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

parameters:
buildType: Release
buildIlmBase: ON
buildOpenEXR: ON
buildPythonLibs: ON
buildSharedLibs: ON
buildStaticLibs: OFF
buildTests: ON
buildUtils: ON
buildViewers: OFF
forceCXX03: OFF
useNamespaceVersioning: OFF
pythonMajor: 2
pythonMinor: 7
runFuzzTests: OFF
verbose: OFF
cxxStd: 14
cxxFlags: ''
cxxCompiler: ''
cCompiler: ''
cmakeOpts: ''

steps:
- bash: |
mkdir _build
mkdir _install
displayName: Create build directories

- bash: |
if [ "$CXXCOMPILER" ]; then
export CXX="$CXXCOMPILER"
fi
if [ "$CCOMPILER" ]; then
export CC="$CCOMPILER"
fi
cmake ../. \
-DCMAKE_INSTALL_PREFIX=../_install \
-DCMAKE_BUILD_TYPE=${{ parameters.buildType }} \
-DCMAKE_CXX_STANDARD=${{ parameters.cxxStd }} \
-DCMAKE_CXX_FLAGS="${{ parameters.cxxFlags }}" \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${{ parameters.verbose }} \
-DBUILD_SHARED_LIBS=${{ parameters.buildSharedLibs }} \
-DOCIO_BUILD_TESTS=${{ parameters.buildTests }} \
-DOCIO_BUILD_GPU_TESTS=${{ parameters.buildGpuTests }} \
-DOCIO_BUILD_DOCS=${{ parameters.buildDocs }} \
-DOCIO_USE_SSE=${{ parameters.useSSE }} \
-DOCIO_WARNING_AS_ERROR=ON \
-DOPENEXR_BUILD_ILMBASE=${{ parameters.buildIlmBase }} \
-DOPENEXR_BUILD_OPENEXR=${{ parameters.buildOpenEXR }} \
-DOPENEXR_BUILD_PYTHONLIBS=${{ parameters.buildPythonLibs }} \
-DOPENEXR_BUILD_SHARED=${{ parameters.buildSharedLibs }} \
-DOPENEXR_BUILD_STATIC=${{ parameters.buildStaticLibs }} \
-DOPENEXR_BUILD_TESTS=${{ parameters.buildTests }} \
-DOPENEXR_BUILD_UTILS=${{ parameters.buildUtils }} \
-DOPENEXR_BUILD_VIEWERS=${{ parameters.buildViewers }} \
-DOPENEXR_FORCE_CXX03=${{ parameters.forceCXX03 }} \
-DOPENEXR_NAMESPACE_VERSIONING=${{ parameters.useNamespaceVersioning }} \
-DOPENEXR_PYTHON_MAJOR=${{ parameters.pythonMajor }} \
-DOPENEXR_PYTHON_MINOR=${{ parameters.pythonMinor }} \
-DOPENEXR_RUN_FUZZ_TESTS=${{ parameters.runFuzzTests }} \
${{ parameters.cmakeOpts }}
workingDirectory: _build
displayName: Configure OpenEXR
9 changes: 9 additions & 0 deletions share/ci/templates/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# azure-pipelines template file
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

steps:
- bash: |
export LD_LIBRARY_PATH=$PWD/IlmBase/Half:$PWD/IlmBase/IlmThread:$PWD/IlmBase/Iex:$PWD/IlmBase/IexMath:$PWD/IlmBase/Imath:$PWD/OpenEXR/IlmImf:$PWD/OpenEXR/IlmImfUtil:$LD_LIBRARY_PATH
ctest -T Test --output-on-failure -VV -E PyImathNumpyTest
workingDirectory: _build
displayName: Test OpenEXR
28 changes: 28 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SonarCloud analysis configuration file
# https://sonarcloud.io/documentation/analysis/analysis-parameters

sonar.host.url=https://sonarcloud.io

# Required metadata
sonar.organization=xlietz-github
sonar.projectKey=xlietz_openexr
sonar.projectName=OpenEXR
sonar.projectVersion=2.3
sonar.login=e7483617eed86aca699a04d73118cf1730f9b23d
sonar.password=

# Project links
sonar.links.homepage=http://openexr.com
# sonar.links.ci=https://dev.azure.com/OpenEXR/OpenEXR/_build
sonar.links.scm=https://github.com/OpenEXR/OpenEXR
sonar.links.issue=https://github.com/OpenEXR/OpenEXR/issues

# Source properties
sonar.sources=IlmBase,OpenEXR,PyIlmBase
sonar.sourceEncoding=UTF-8
sonar.exclusions=

# C/C++ analyzer properties
sonar.cfamily.build-wrapper-output=_build/bw_output
sonar.cfamily.gcov.reportsPath=_coverage

0 comments on commit 65098c8

Please sign in to comment.