Skip to content

Commit

Permalink
SonarCloud setup (#143)
Browse files Browse the repository at this point in the history
* dev: initial sonarcloud setup

* dev: config.yml update

* dev: config.yml update

* doc: README.md update
  • Loading branch information
borozcod authored Nov 29, 2023
1 parent 5c9fbea commit c8ca3e9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
25 changes: 22 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
orbs:
docker: circleci/[email protected]
node: circleci/[email protected]

sonarcloud: sonarsource/[email protected]
jobs:
generate_schema:
executor:
Expand Down Expand Up @@ -45,14 +45,23 @@ jobs:
docker build --network=flexo-mms-test-network -t flexo-mms-test:latest -f Dockerfile-Test .
docker run --network=flexo-mms-test-network --name flexo-mms-test-container flexo-mms-test:latest
SIG_INT=$?
docker cp flexo-mms-test-container:/application/build/reports/tests /home/circleci/results
docker cp flexo-mms-test-container:/application/build /home/circleci/flexo-mms-layer1-service/build
exit "$SIG_INT"
- store_artifacts:
path: /home/circleci/results
path: /home/circleci/flexo-mms-layer1-service/build
- persist_to_workspace:
root: /home/circleci/
paths:
- flexo-mms-layer1-service/*
scan:
executor:
name: docker/docker
working_directory: /home/circleci/flexo-mms-layer1-service
steps:
- checkout
- attach_workspace:
at: /home/circleci/flexo-mms-layer1-service
- sonarcloud/scan

deploy_snapshot:
executor:
Expand Down Expand Up @@ -132,13 +141,23 @@ workflows:
version: 2
build-test-deploy:
jobs:
- scan:
requires:
- build_and_test
context:
- SonarCloud
- generate_schema:
filters:
tags:
only: /v[0-9.]+(-[\w-]+(\.[0-9]+)?)?/
context:
- DockerHub
- build_and_test:
post-steps:
- persist_to_workspace:
root: /home/circleci/flexo-mms-layer1-service
paths:
- build/*
requires:
- generate_schema
filters:
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Flexo MMS Layer 1

[![CircleCI](https://circleci.com/gh/Open-MBEE/flexo-mms-layer1-service.svg?style=shield)](https://circleci.com/gh/Open-MBEE/flexo-mms-layer1-service)
[![CircleCI](https://circleci.com/gh/Open-MBEE/flexo-mms-layer1-service.svg?style=shield)](https://circleci.com/gh/Open-MBEE/flexo-mms-layer1-service) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service)
<details>
<summary>SonarCloud</summary>

[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=bugs)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service) [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_flexo-mms-layer1-service&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_flexo-mms-layer1-service)
</details>

This project is currently under development. This document describes how to set up a local dev environment.

Expand Down
14 changes: 14 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ plugins {
kotlin("jvm") version "1.9.20"
kotlin("plugin.serialization") version "1.9.20"
jacoco
id("org.sonarqube") version "4.4.1.3373"
}

group = "org.openmbee.flexo.mms"
version = "0.1.0-ALPHA"

sonar {
properties {
property("sonar.projectKey", "Open-MBEE_flexo-mms-layer1-service")
property("sonar.organization", "openmbee")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/jacocoTestReport.xml")
}
}

application {
mainClass.set("io.ktor.server.netty.EngineMain")
}
Expand Down Expand Up @@ -108,4 +119,7 @@ tasks.test {
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
reports {
xml.required.set(true)
}
}
4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sonar.projectKey=Open-MBEE_flexo-mms-layer1-service
sonar.organization=openmbee
sonar.language=kotlin
sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml

0 comments on commit c8ca3e9

Please sign in to comment.