Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sonar cloud analysis in CI for java code #780

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: Dev CI

on:
push:
branches:
# on all branches except main where full build will be run
- '*'
- '!main'
pull_request:

jobs:
manylinux_build:
Expand Down Expand Up @@ -168,3 +164,32 @@ jobs:
- name: Run doc examples
working-directory: ./docs
run: make html doctest SPHINXOPTS="-W"

build:
name: Run SonarCloud analysis for Java code
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up JDK 17
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: 'temurin'
java-version: '17'

- name: Build with Maven (Ubuntu)
working-directory: ./java
run: >
mvn --batch-mode -Pjacoco install

- name: Run SonarCloud analysis
working-directory: ./java
run: >
mvn --batch-mode -DskipTests sonar:sonar
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=powsybl-ci-github
-Dsonar.projectKey=powsybl_pypowsybl-java
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33 changes: 32 additions & 1 deletion .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ on:
push:
branches:
- main
- 'release-v**'
- 'full-sonar-analysis-**'
tags:
- 'v*.*.*'
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
manylinux_build:
Expand Down Expand Up @@ -245,3 +247,32 @@ jobs:
run: |
python -m pip install --user --upgrade twine
python -m twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} download/*/*.whl

build:
name: Run SonarCloud analysis for Java code
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up JDK 17
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: 'temurin'
java-version: '17'

- name: Build with Maven (Ubuntu)
working-directory: ./java
run: >
mvn --batch-mode -Pjacoco install

- name: Run SonarCloud analysis
working-directory: ./java
run: >
mvn --batch-mode -DskipTests sonar:sonar
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=powsybl-ci-github
-Dsonar.projectKey=powsybl_pypowsybl
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
The PyPowSyBl project gives access PowSyBl Java framework to Python developers. This Python integration relies on
GraalVM to compile Java code to a native library.

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=powsybl_pypowsybl-java&metric=alert_status)](https://sonarcloud.io/dashboard?id=powsybl_pypowsybl-java)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=powsybl_pypowsybl-java&metric=coverage)](https://sonarcloud.io/dashboard?id=powsybl_pypowsybl-java)

## Documentation

Latest version of the documentation with API reference and many code samples is [here](https://pypowsybl.readthedocs.io/).
Expand Down
27 changes: 26 additions & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,32 @@
</plugins>
</build>
</profile>
<profile>
<id>jacoco</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<title>pypowsybl</title>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencyManagement>
Expand All @@ -169,7 +195,6 @@

<dependencies>
<!-- compile -->

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private ReportCUtils() {

public static ReportNode getReportNode(ObjectHandle reportNodeHandle) {
ReportNode reportNode = ObjectHandles.getGlobal().get(reportNodeHandle);

return reportNode != null ? reportNode : ReportNode.NO_OP;
}
}
3 changes: 3 additions & 0 deletions tests/test_loadflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,6 @@ def test_wrong_regulated_bus_id():
pp.loadflow.run_ac(net)
parameters = lf.ValidationParameters()
validation = pp.loadflow.run_validation(net, validation_parameters=parameters)

def test():
pass
Loading