Skip to content

Commit

Permalink
#47 Add CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierbureau authored and rosiereflo committed Jan 14, 2022
1 parent ef391fb commit bc0f270
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI

on: [push]

defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
container: dynawo/dynawo-ci:latest
env:
DYNAWO_BUILD_TYPE: Debug
DYNAWO_CXX11_ENABLED: YES
DYNAWO_COMPILER: GCC
DYNAWO_RESULTS_SHOW: "false"
DYNAWO_NB_PROCESSORS_USED: 2
DYNAWO_VERSION: 1.3.0
GH_API_DYNAWO: ${{ github.api_url }}/repos/${{ github.repository_owner }}/dynawo
CURL_JSON: 'curl --silent --header "Content-Type": "application/json"'
steps:
- name: Checkout sources
uses: actions/checkout@v1

- name: Fetch Dynawo
run: |
source .github/workflows/tools.sh
download_asset $GH_API_DYNAWO nightly Dynawo_headers_V${DYNAWO_VERSION}.zip
- name: Unzip Dynawo
run: |
unzip "Dynawo_headers_V${DYNAWO_VERSION}.zip"
- name: Build
run: |
export DYNAWO_HOME=$(pwd)/dynawo
export DYNAWO_ALGORITHMS_HOME=$(pwd)
util/envDynawoAlgorithms.sh build
coverage:
runs-on: ubuntu-latest
container: dynawo/dynawo-ci:latest
env:
DYNAWO_BUILD_TYPE: Debug
DYNAWO_CXX11_ENABLED: YES
DYNAWO_COMPILER: GCC
DYNAWO_RESULTS_SHOW: "false"
DYNAWO_NB_PROCESSORS_USED: 2
DYNAWO_VERSION: 1.3.0
GH_API_DYNAWO: ${{ github.api_url }}/repos/${{ github.repository_owner }}/dynawo
CURL_JSON: 'curl --silent --header "Content-Type": "application/json"'
steps:
- name: Install Sonar wrapper
working-directory: ${{ runner.workspace }}
env:
CONTAINER_WORKSPACE: ${{ runner.workspace }}
run: |
wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip
- name: Install Sonar scanner
working-directory: ${{ runner.workspace }}
env:
SONAR_SCANNER_VERSION: 4.6.0.2311
run: |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip
unzip sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip
ln -s sonar-scanner-${SONAR_SCANNER_VERSION} sonar
rm sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip
dnf install -y java-11-openjdk
- name: Checkout sources
uses: actions/checkout@v1

- name: Fetch Dynawo
run: |
source .github/workflows/tools.sh
download_asset $GH_API_DYNAWO nightly Dynawo_omc_V${DYNAWO_VERSION}.zip
- name: Unzip Dynawo
run: |
unzip "Dynawo_omc_V${DYNAWO_VERSION}.zip"
- name: Build
env:
CONTAINER_WORKSPACE: ${{ runner.workspace }}
run: |
export DYNAWO_HOME=$(pwd)/dynawo
export DYNAWO_ALGORITHMS_HOME=$(pwd)
$CONTAINER_WORKSPACE/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output util/envDynawoAlgorithms.sh build-tests-coverage
- name: Sonarcloud
working-directory: ${{ runner.workspace }}/dynawo-algorithms
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
CONTAINER_WORKSPACE: ${{ runner.workspace }}
run: $CONTAINER_WORKSPACE/sonar/bin/sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.cfamily.threads=2
11 changes: 11 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sonar.sources=sources
sonar.projectKey=dynawo_dynawo-algorithms
sonar.organization=dynawo
sonar.projectName=dynawo-algorithms
sonar.sourceEncoding=UTF8
sonar.cfamily.gcov.reportsPath=build/coverage-sonar
sonar.cfamily.build-wrapper-output=bw-output
sonar.cfamily.cache.enabled=false
sonar.python.coverage.reportPaths=build/coverage-sonar/coverage-python/*coverage*.xml
sonar.exclusions=**/test/**,**/xsd/**,**/*.xml,**/ModelicaExternalC/**,**/DYNModelManagerOwnFunctions.**
sonar.host.url=https://sonarcloud.io
13 changes: 12 additions & 1 deletion util/envDynawoAlgorithms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ test_doxygen_doc_dynawo_algorithms() {
fi
}


build_tests() {
clean_dynawo_algorithms || error_exit
config_dynawo_algorithms || error_exit
Expand Down Expand Up @@ -445,6 +444,18 @@ build_tests_coverage() {
if [ "$DYNAWO_RESULTS_SHOW" = true ] ; then
$DYNAWO_BROWSER $DYNAWO_ALGORITHMS_BUILD_DIR/coverage/index.html
fi
cp $DYNAWO_ALGORITHMS_BUILD_DIR/coverage/coverage.info $DYNAWO_ALGORITHMS_HOME/build
if [ -d "$DYNAWO_ALGORITHMS_HOME/build/coverage-sonar" ]; then
rm -rf "$DYNAWO_ALGORITHMS_HOME/build/coverage-sonar"
fi
mkdir -p $DYNAWO_ALGORITHMS_HOME/build/coverage-sonar || error_exit "Impossible to create $DYNAWO_ALGORITHMS_HOME/build/coverage-sonar."
cd $DYNAWO_ALGORITHMS_HOME/build/coverage-sonar
for file in $(find $DYNAWO_ALGORITHMS_BUILD_DIR -name "*.gcno" | grep -v "/test/"); do
cpp_file_name=$(basename $file .gcno)
cpp_file=$(find $DYNAWO_ALGORITHMS_HOME/sources -name "$cpp_file_name" 2> /dev/null)
gcov -pb $cpp_file -o $file > /dev/null
done
find $DYNAWO_ALGORITHMS_HOME/build/coverage-sonar -type f -not -name "*dynawo-algorithms*" -exec rm -f {} \;
}

unittest_gdb() {
Expand Down

0 comments on commit bc0f270

Please sign in to comment.