Skip to content

Commit 65669b7

Browse files
committed
feat: generate new report and aggregate test coverage
1 parent ae2d6bc commit 65669b7

File tree

12 files changed

+200
-62
lines changed

12 files changed

+200
-62
lines changed

.github/workflows/tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ jobs:
5151
if: github.ref == 'refs/heads/main'
5252
with:
5353
BRANCH: gh-pages
54-
folder: validation/target/site/jacoco
54+
folder: validation/target/site/jacoco-aggregate
5555
target-folder: coverage-report/
5656

5757
- name: ✅ Generate JaCoCo Badge
5858
uses: cicirello/jacoco-badge-generator@v2
5959
if: github.ref == 'refs/heads/main'
6060
with:
6161
generate-branches-badge: true
62-
jacoco-csv-file: validation/target/site/jacoco/jacoco.csv
63-
badges-directory: validation/build/reports/jacoco/test/html/badges
62+
jacoco-csv-file: validation/target/site/jacoco-aggregate/jacoco.csv
63+
badges-directory: validation/build/reports/jacoco-aggregate/test/html/badges
6464

6565
- name: 💾 Log coverage percentage
6666
run: |
@@ -72,5 +72,5 @@ jobs:
7272
if: github.ref == 'refs/heads/main'
7373
with:
7474
branch: gh-pages
75-
folder: validation/build/reports/jacoco/test/html/badges
75+
folder: validation/build/reports/jacoco-aggregate/test/html/badges
7676
target-folder: badges/

calculation/.flattened-pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<parent>
66
<groupId>org.cardanofoundation</groupId>
77
<artifactId>cf-rewards</artifactId>
8-
<version>0.9.0</version>
8+
<version>0.10.0</version>
99
</parent>
1010
<groupId>org.cardanofoundation</groupId>
1111
<artifactId>cf-rewards-calculation</artifactId>
12-
<version>0.9.0</version>
12+
<version>0.10.0</version>
1313
<description>This project aims to be a cardano reward calculation, java formula implementation and edge case
1414
documentation</description>
1515
<licenses>

pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<version.maven-gpg-plugin>3.1.0</version.maven-gpg-plugin>
7070
<version.flatten-maven-plugin>1.2.7</version.flatten-maven-plugin>
7171
<version.maven-project-info-reports-plugin>3.3.0</version.maven-project-info-reports-plugin>
72+
<version.maven-resources-plugin>3.3.1</version.maven-resources-plugin>
7273
</properties>
7374

7475
<distributionManagement>
@@ -82,4 +83,29 @@
8283
</repository>
8384
</distributionManagement>
8485

86+
<build>
87+
<plugins>
88+
<plugin>
89+
<groupId>org.jacoco</groupId>
90+
<artifactId>jacoco-maven-plugin</artifactId>
91+
<version>${version.jacoco-maven-plugin}</version>
92+
<executions>
93+
<execution>
94+
<id>jacoco-initialize</id>
95+
<goals>
96+
<goal>prepare-agent</goal>
97+
</goals>
98+
</execution>
99+
<execution>
100+
<id>jacoco-report</id>
101+
<phase>verify</phase>
102+
<goals>
103+
<goal>report</goal>
104+
</goals>
105+
</execution>
106+
</executions>
107+
</plugin>
108+
</plugins>
109+
</build>
110+
85111
</project>

report/treasury_calculation_result.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

validation/pom.xml

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,6 @@
127127
</executions>
128128
</plugin>
129129

130-
<plugin>
131-
<groupId>org.jacoco</groupId>
132-
<artifactId>jacoco-maven-plugin</artifactId>
133-
<version>${version.jacoco-maven-plugin}</version>
134-
<executions>
135-
<execution>
136-
<goals>
137-
<goal>prepare-agent</goal>
138-
</goals>
139-
</execution>
140-
<execution>
141-
<id>generate-code-coverage-report</id>
142-
<phase>test</phase>
143-
<goals>
144-
<goal>report</goal>
145-
</goals>
146-
</execution>
147-
</executions>
148-
</plugin>
149-
150130
<plugin>
151131
<groupId>org.apache.maven.plugins</groupId>
152132
<artifactId>maven-surefire-plugin</artifactId>
@@ -158,7 +138,20 @@
158138
</configuration>
159139
</plugin>
160140

141+
<plugin>
142+
<groupId>org.jacoco</groupId>
143+
<artifactId>jacoco-maven-plugin</artifactId>
144+
<version>${version.jacoco-maven-plugin}</version>
145+
<executions>
146+
<execution>
147+
<id>jacoco-site-aggregate</id>
148+
<phase>verify</phase>
149+
<goals>
150+
<goal>report-aggregate</goal>
151+
</goals>
152+
</execution>
153+
</executions>
154+
</plugin>
161155
</plugins>
162156
</build>
163-
164157
</project>

validation/src/main/java/org/cardanofoundation/rewards/validation/EpochValidation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static EpochCalculationResult calculateEpochRewardPots(int epoch, DataPro
8383
.build();
8484
}
8585

86-
HashSet<String> poolIds = epochValidationInput.getPoolRewards().stream().map(EpochValidationPoolReward::getPoolId).collect(Collectors.toCollection(HashSet::new));
86+
HashSet<String> poolIds = epochValidationInput.getPoolStates().stream().map(PoolState::getPoolId).collect(Collectors.toCollection(HashSet::new));
8787

8888
if (detailedValidation) {
8989
memberRewardsInEpoch = epochValidationInput.getPoolRewards().stream()

validation/src/main/java/org/cardanofoundation/rewards/validation/data/fetcher/DbSyncDataFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void fetch(int epoch, boolean override, boolean skipValidationData) {
158158
.mirCertificates(new HashSet<>(mirCertificates))
159159
.build();
160160
try {
161-
JsonConverter.writeObjectToJsonFile(epochValidationInput, filePath);
161+
JsonConverter.writeObjectToCompressedJsonFile(epochValidationInput, filePath);
162162
} catch (IOException e) {
163163
logger.error("Failed to write epoch validation input data to json file for epoch " + epoch);
164164
}

validation/src/main/java/org/cardanofoundation/rewards/validation/data/fetcher/KoiosDataFetcher.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.List;
1515

1616
import static org.cardanofoundation.rewards.validation.enums.DataType.*;
17-
import static org.cardanofoundation.rewards.validation.util.JsonConverter.writeObjectToJsonFile;
17+
import static org.cardanofoundation.rewards.validation.util.JsonConverter.writeObjectToCompressedJsonFile;
1818

1919
@Service
2020
public class KoiosDataFetcher implements DataFetcher {
@@ -45,7 +45,7 @@ private void fetchAdaPots(int epoch, boolean override) {
4545
}
4646

4747
try {
48-
writeObjectToJsonFile(adaPots, filePath);
48+
writeObjectToCompressedJsonFile(adaPots, filePath);
4949
} catch (IOException e) {
5050
logger.error("Failed to write AdaPots to json file for epoch " + epoch);
5151
}
@@ -67,7 +67,7 @@ private void fetchEpochInfo(int epoch, boolean override) {
6767
}
6868

6969
try {
70-
writeObjectToJsonFile(epochInfo, filePath);
70+
writeObjectToCompressedJsonFile(epochInfo, filePath);
7171
} catch (IOException e) {
7272
logger.error("Failed to write EpochInfo to json file for epoch " + epoch);
7373
}
@@ -89,7 +89,7 @@ private void fetchProtocolParameters(int epoch, boolean override) {
8989
}
9090

9191
try {
92-
writeObjectToJsonFile(protocolParameters, filePath);
92+
writeObjectToCompressedJsonFile(protocolParameters, filePath);
9393
} catch (IOException e) {
9494
logger.error("Failed to write ProtocolParameters to json file for epoch " + epoch);
9595
}
@@ -115,7 +115,7 @@ private void fetchPoolHistoryByEpoch(String poolId, int epoch, boolean override)
115115
PoolState poolState = koiosDataProvider.getPoolHistory(poolId, epoch);
116116

117117
try {
118-
writeObjectToJsonFile(poolState, filePath);
118+
writeObjectToCompressedJsonFile(poolState, filePath);
119119
} catch (IOException e) {
120120
logger.error("Failed to write pool history to json file for epoch " + epoch);
121121
}

validation/src/main/java/org/cardanofoundation/rewards/validation/data/plotter/JsonDataPlotter.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ public void plot(int epochStart, int epochEnd) {
3939
TreasuryValidationResult treasuryValidationResult = TreasuryValidationResult
4040
.fromTreasuryCalculationResult(epochCalculationResult.getTreasuryCalculationResult());
4141
AdaPots adaPotsForCurrentEpoch = jsonDataProvider.getAdaPotsForEpoch(epoch);
42-
treasuryValidationResult.setActualTreasury(adaPotsForCurrentEpoch.getTreasury());
43-
epochTreasuryValidationResultMap.put(epoch, treasuryValidationResult);
42+
43+
if (adaPotsForCurrentEpoch != null) {
44+
treasuryValidationResult.setActualTreasury(adaPotsForCurrentEpoch.getTreasury());
45+
epochTreasuryValidationResultMap.put(epoch, treasuryValidationResult);
46+
} else {
47+
logger.warn("Failed to get AdaPots for epoch " + epoch + ". Skipping epoch.");
48+
}
4449
}
4550

4651
try {

0 commit comments

Comments
 (0)