Skip to content

Commit 51d3db6

Browse files
authored
Merge branch 'main' into nro/licenses
2 parents 21246aa + 20332d1 commit 51d3db6

395 files changed

Lines changed: 68964 additions & 3290 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI on forks - build and tests
2+
3+
on:
4+
pull_request:
5+
6+
permissions: {}
7+
8+
jobs:
9+
build:
10+
name: Build OS ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
if: github.event.pull_request.head.repo.fork == true
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
17+
steps:
18+
- name: Checkout sources
19+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
20+
21+
- name: Set up JDK 21
22+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
23+
with:
24+
distribution: 'temurin'
25+
java-version: '21'
26+
27+
- name: Build with Maven (Ubuntu)
28+
if: matrix.os == 'ubuntu-latest'
29+
run: ./mvnw --batch-mode -P jacoco,checks install
30+
31+
- name: Build with Maven (Windows)
32+
if: matrix.os == 'windows-latest'
33+
run: mvnw.cmd --batch-mode install
34+
shell: cmd
35+
36+
- name: Build with Maven (MacOS)
37+
if: matrix.os == 'macos-latest'
38+
run: ./mvnw --batch-mode install
39+
40+
- name: Regroup dependencies in target folders
41+
if: matrix.os == 'ubuntu-latest'
42+
run: ./mvnw dependency:copy-dependencies
43+
44+
- name: Save classes and Jacoco report
45+
if: matrix.os == 'ubuntu-latest'
46+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
47+
with:
48+
name: data-for-sonar-analysis-${{ github.event.pull_request.number }}
49+
retention-days: 1
50+
path: |
51+
*/target/classes
52+
*/*/target/classes
53+
*/*/*/target/classes
54+
*/target/generated-sources
55+
*/*/target/generated-sources
56+
*/*/*/target/generated-sources
57+
distribution-diagram/target/dependency
58+
distribution-diagram/target/site/jacoco-aggregate/jacoco.xml
59+
60+
- name: Save PR Information
61+
if: matrix.os == 'ubuntu-latest'
62+
env:
63+
REPO_NAME: ${{ github.event.pull_request.head.repo.full_name }}
64+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
65+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
66+
PR_NUMBER: ${{ github.event.pull_request.number }}
67+
BASE_REF: ${{ github.event.pull_request.base.ref }}
68+
run: |
69+
mkdir -p pr-info
70+
echo "$REPO_NAME" > pr-info/repo-name
71+
echo "$HEAD_REF" > pr-info/head-ref
72+
echo "$HEAD_SHA" > pr-info/head-sha
73+
echo "$PR_NUMBER" > pr-info/pr-number
74+
echo "$BASE_REF" > pr-info/base-ref
75+
76+
- name: Upload PR Information
77+
if: matrix.os == 'ubuntu-latest'
78+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
79+
with:
80+
name: pr-info-${{ github.event.pull_request.number }}
81+
path: pr-info/
82+
retention-days: 1

.github/workflows/fork-sonar.yml

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
name: CI on forks - Sonar analysis
2+
3+
on:
4+
workflow_run:
5+
workflows: [CI on forks - build and tests]
6+
types:
7+
- completed
8+
9+
permissions: {}
10+
11+
jobs:
12+
sonar:
13+
name: Run Sonar Analysis for forks
14+
runs-on: ubuntu-latest
15+
if: >
16+
github.event.workflow_run.event == 'pull_request' &&
17+
github.event.workflow_run.conclusion == 'success'
18+
permissions:
19+
actions: write
20+
checks: write
21+
contents: read
22+
issues: read
23+
pull-requests: write
24+
statuses: write
25+
steps:
26+
- name: Download PR information
27+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
28+
with:
29+
script: |
30+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
run_id: context.payload.workflow_run.id,
34+
});
35+
let prInfoArtifact = allArtifacts.data.artifacts.filter((artifact) => {
36+
return artifact.name.startsWith("pr-info-")
37+
})[0];
38+
if (!prInfoArtifact) {
39+
core.setFailed("❌ No PR info artifact found");
40+
return;
41+
}
42+
let download = await github.rest.actions.downloadArtifact({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
artifact_id: prInfoArtifact.id,
46+
archive_format: 'zip',
47+
});
48+
const fs = require('fs');
49+
const path = require('path');
50+
const temp = '${{ runner.temp }}/pr-info';
51+
if (!fs.existsSync(temp)){
52+
fs.mkdirSync(temp, { recursive: true });
53+
}
54+
fs.writeFileSync(path.join(temp, 'pr-info.zip'), Buffer.from(download.data));
55+
console.log("PR information downloaded");
56+
57+
- name: Extract PR Information
58+
run: |
59+
mkdir -p ${{ runner.temp }}/pr-info-extracted
60+
unzip -q ${{ runner.temp }}/pr-info/pr-info.zip -d ${{ runner.temp }}/pr-info-extracted
61+
REPO_NAME=$(cat ${{ runner.temp }}/pr-info-extracted/repo-name)
62+
HEAD_REF=$(cat ${{ runner.temp }}/pr-info-extracted/head-ref)
63+
HEAD_SHA=$(cat ${{ runner.temp }}/pr-info-extracted/head-sha)
64+
PR_NUMBER=$(cat ${{ runner.temp }}/pr-info-extracted/pr-number)
65+
BASE_REF=$(cat ${{ runner.temp }}/pr-info-extracted/base-ref)
66+
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
67+
echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
68+
echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_ENV
69+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
70+
echo "BASE_REF=$BASE_REF" >> $GITHUB_ENV
71+
echo "PR information extracted: $REPO_NAME $HEAD_REF $HEAD_SHA $PR_NUMBER $BASE_REF"
72+
73+
- name: Checkout sources
74+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
75+
with:
76+
ref: ${{ env.HEAD_REF }}
77+
repository: ${{ env.REPO_NAME }}
78+
fetch-depth: 0
79+
80+
- name: Set up JDK 21
81+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
82+
with:
83+
distribution: 'temurin'
84+
java-version: '21'
85+
86+
- name: Download artifact
87+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
88+
with:
89+
script: |
90+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
91+
owner: context.repo.owner,
92+
repo: context.repo.repo,
93+
run_id: context.payload.workflow_run.id,
94+
});
95+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
96+
return artifact.name.startsWith("data-for-sonar-analysis-")
97+
})[0];
98+
if (!matchArtifact) {
99+
core.setFailed("❌ No matching artifact found");
100+
return;
101+
}
102+
const prNumber = matchArtifact.name.replace("data-for-sonar-analysis-", "");
103+
console.log(`PR number: ${prNumber}`);
104+
core.exportVariable('PR_NUMBER', prNumber);
105+
let download = await github.rest.actions.downloadArtifact({
106+
owner: context.repo.owner,
107+
repo: context.repo.repo,
108+
artifact_id: matchArtifact.id,
109+
archive_format: 'zip',
110+
});
111+
const fs = require('fs');
112+
const path = require('path');
113+
const temp = '${{ runner.temp }}/artifacts';
114+
if (!fs.existsSync(temp)){
115+
fs.mkdirSync(temp);
116+
}
117+
fs.writeFileSync(path.join(temp, 'sonar-data.zip'), Buffer.from(download.data));
118+
119+
- name: Extract Sonar Analysis Data
120+
run: |
121+
mkdir -p ${{ runner.temp }}/extracted
122+
unzip -q ${{ runner.temp }}/artifacts/sonar-data.zip -d ${{ runner.temp }}/extracted
123+
cp -r ${{ runner.temp }}/extracted/* .
124+
ls -la distribution-diagram/target/site/jacoco-aggregate/ || echo "Jacoco report directory not found"
125+
126+
- name: Prepare Sonar Analysis
127+
run: |
128+
echo "Checking required directories..."
129+
if [ -f "distribution-diagram/target/site/jacoco-aggregate/jacoco.xml" ]; then
130+
echo "Jacoco report found"
131+
else
132+
echo "Warning: Jacoco report not found at expected location"
133+
fi
134+
echo "Finding sources and binaries..."
135+
SOURCES=$(find . -type d -path "*/main/java" | sort -u | paste -sd "," -)
136+
if [ -z "$SOURCES" ]; then
137+
echo "Warning: No source directories found!"
138+
else
139+
echo "SOURCES : $SOURCES"
140+
echo "SOURCES=$SOURCES" >> $GITHUB_ENV
141+
fi
142+
GENERATED=$(find . -type d -path "*/target/generated-sources" | sort -u | paste -sd "," -)
143+
if [ -z "$GENERATED" ]; then
144+
echo "Warning: No generated source directories found!"
145+
else
146+
echo "GENERATED : $GENERATED"
147+
echo "GENERATED=$GENERATED" >> $GITHUB_ENV
148+
fi
149+
TESTS=$(find . -type d -path "*/test/java" | sort -u | paste -sd "," -)
150+
if [ -z "$TESTS" ]; then
151+
echo "Warning: No test directories found!"
152+
else
153+
echo "TESTS : $TESTS"
154+
echo "TESTS=$TESTS" >> $GITHUB_ENV
155+
fi
156+
BINARIES=$(find . -type d -path "*/target/classes" | sort -u | paste -sd "," -)
157+
if [ -z "$BINARIES" ]; then
158+
echo "Warning: No binaries directories found!"
159+
else
160+
echo "BINARIES : $BINARIES"
161+
echo "BINARIES=$BINARIES" >> $GITHUB_ENV
162+
fi
163+
LIBRARIES="distribution-diagram/target/dependency"
164+
if [ -z "$LIBRARIES" ]; then
165+
echo "Warning: No libraries directory found!"
166+
else
167+
echo "LIBRARIES : $LIBRARIES"
168+
echo "LIBRARIES=$LIBRARIES" >> $GITHUB_ENV
169+
fi
170+
171+
# This sonar action should NOT be replaced by a direct use of the mvn verify command since we don't want external
172+
# code to run in a workflow_run workflow (it may lead to security issues).
173+
- name: Run Sonar Analysis
174+
uses: SonarSource/sonarqube-scan-action@1a6d90ebcb0e6a6b1d87e37ba693fe453195ae25 # v5.3.1
175+
env:
176+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
177+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
178+
with:
179+
args: >
180+
-Dsonar.projectKey=com.powsybl:powsybl-diagram
181+
-Dsonar.organization=powsybl-ci-github
182+
-Dsonar.sources=${{ env.SOURCES }}
183+
-Dsonar.generatedSources=${{ env.GENERATED }}
184+
-Dsonar.tests=${{ env.TESTS }}
185+
-Dsonar.java.binaries=${{ env.BINARIES }}
186+
-Dsonar.java.libraries=${{ env.LIBRARIES }}
187+
-Dsonar.java.test.libraries=${{ env.LIBRARIES }}
188+
-Dsonar.coverage.jacoco.xmlReportPaths="distribution-diagram/target/site/jacoco-aggregate/jacoco.xml"
189+
-Dsonar.pullrequest.key=${{ env.PR_NUMBER }}
190+
-Dsonar.pullrequest.branch=${{ env.HEAD_REF }}
191+
-Dsonar.pullrequest.base=${{ env.BASE_REF }}
192+
-Dsonar.pullrequest.provider=github
193+
-Dsonar.pullrequest.github.repository=${{ github.repository }}
194+
-Dsonar.host.url=https://sonarcloud.io
195+
-Dsonar.scm.provider=git
196+
-Dsonar.qualitygate.wait=true
197+
-Dsonar.scm.revision=${{ env.HEAD_SHA }}
198+
199+
- name: Delete artifacts used in analysis
200+
if: always()
201+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
202+
with:
203+
github-token: ${{ secrets.GITHUB_TOKEN }}
204+
script: |
205+
let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
206+
owner: context.repo.owner,
207+
repo: context.repo.repo,
208+
run_id: context.payload.workflow_run.id,
209+
});
210+
for (const artifact of artifacts.data.artifacts) {
211+
if (
212+
artifact.name.startsWith("data-for-sonar-analysis-") ||
213+
artifact.name.startsWith("pr-info-")
214+
) {
215+
console.log(`Deleting artifact: ${artifact.name} (ID: ${artifact.id})`);
216+
await github.rest.actions.deleteArtifact({
217+
owner: context.repo.owner,
218+
repo: context.repo.repo,
219+
artifact_id: artifact.id
220+
});
221+
}
222+
}

.github/workflows/maven.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ on:
66
- 'main'
77
- 'release-v**'
88
- 'full-sonar-analysis-**'
9+
tags:
10+
- 'v[0-9]+.[0-9]+.[0-9]+*'
911
pull_request:
1012

13+
permissions: {}
14+
1115
jobs:
1216
build:
1317
name: Build OS ${{ matrix.os }}
1418
runs-on: ${{ matrix.os }}
19+
if: github.event.pull_request.head.repo.fork == false
1520
strategy:
1621
matrix:
1722
os: [ubuntu-latest, windows-latest, macos-latest]
1823

1924
steps:
2025
- name: Checkout sources
21-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2227

2328
- name: Set up JDK 21
24-
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
29+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
2530
with:
2631
distribution: 'temurin'
2732
java-version: 21
@@ -47,6 +52,4 @@ jobs:
4752
-Dsonar.organization=powsybl-ci-github
4853
-Dsonar.projectKey=com.powsybl:powsybl-diagram
4954
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5155
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
52-

diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.Optional;
1616

1717
/**
18-
*
1918
* @author Massimo Ferraro {@literal <massimo.ferraro@techrain.eu>}
2019
*/
2120
public final class Networks {

diagram-util/pom.xml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
4-
Copyright (c) 2022, RTE (http://www.rte-france.com)
5-
This Source Code Form is subject to the terms of the Mozilla Public
6-
License, v. 2.0. If a copy of the MPL was not distributed with this
7-
file, You can obtain one at http://mozilla.org/MPL/2.0/.
8-
9-
-->
2+
<!--~
3+
~ Copyright (c) 2022-2026, RTE (http://www.rte-france.com)
4+
~ This Source Code Form is subject to the terms of the Mozilla Public
5+
~ License, v. 2.0. If a copy of the MPL was not distributed with this
6+
~ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
~ SPDX-License-Identifier: MPL-2.0
8+
-->
109
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1110
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1211
<modelVersion>4.0.0</modelVersion>
@@ -54,6 +53,10 @@
5453
<groupId>org.slf4j</groupId>
5554
<artifactId>slf4j-api</artifactId>
5655
</dependency>
56+
<dependency>
57+
<groupId>org.slf4j</groupId>
58+
<artifactId>slf4j-simple</artifactId>
59+
</dependency>
5760

5861
<!-- test dependencies -->
5962
<dependency>
@@ -81,10 +84,5 @@
8184
<artifactId>junit-jupiter</artifactId>
8285
<scope>test</scope>
8386
</dependency>
84-
<dependency>
85-
<groupId>org.slf4j</groupId>
86-
<artifactId>slf4j-simple</artifactId>
87-
<scope>test</scope>
88-
</dependency>
8987
</dependencies>
9088
</project>

0 commit comments

Comments
 (0)