Skip to content

Commit 574f416

Browse files
committed
chore: split publish and report workflows
1 parent 4206206 commit 574f416

File tree

7 files changed

+76
-69
lines changed

7 files changed

+76
-69
lines changed

.github/workflows/publish.yaml

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
name: 📊 Generate Report and 📦 Publish to Maven Central
1+
name: 📦 Publish to Maven Central
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
84
workflow_dispatch:
95

106
jobs:
117
publish-to-maven-central:
128
runs-on: ubuntu-latest
13-
if: "github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, 'release-please--branches--main')"
9+
if: "github.event_name == 'workflow_dispatch'"
1410
steps:
1511
- name: ⬇️ Checkout repository
1612
uses: actions/checkout@v3
@@ -32,57 +28,3 @@ jobs:
3228
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_OSSRH_USERNAME }}
3329
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_OSSRH_TOKEN }}
3430
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE }}
35-
create-report:
36-
runs-on: ubuntu-latest
37-
if: "github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, 'release-please--branches--main')"
38-
steps:
39-
- name: ⬇️ Checkout repository
40-
uses: actions/checkout@v3
41-
42-
- name: Setup JDK 18
43-
uses: actions/setup-java@v3
44-
with:
45-
java-version: '18'
46-
distribution: 'temurin'
47-
cache: maven
48-
49-
- name: Setup dependencies
50-
run: |
51-
pip install yq
52-
53-
- name: JSON result to js file
54-
run: |
55-
echo -e "const treasuryCalculationResult = $(cat ./report/treasury_calculation_result.json)" > ./report/treasury_calculation_result.js
56-
57-
- name: 👀 Lookup metadata for report
58-
run: |
59-
echo "VERSION=$(xq -r .project.version pom.xml)" >> $GITHUB_ENV
60-
echo "LATEST_COMMIT_HASH=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_ENV
61-
echo "LATEST_COMMIT_HASH_SHORT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
62-
echo "UTC_DATE=$(date -uR|sed 's/.....$//')" >> $GITHUB_ENV
63-
64-
- name: 📂 Create report directory
65-
run: |
66-
mkdir -p report-v${{ env.VERSION }}
67-
68-
- name: 📄 Copy report files
69-
run: |
70-
cp -r report/* report-v${{ env.VERSION }}
71-
72-
- name: 📝 Add metadata to the report
73-
run: |
74-
sed -i 's|<footer></footer>|<footer><p>Created on ${{ env.UTC_DATE }} UTC as a result of modifications triggered by <a href="https://github.com/cardano-foundation/cf-java-rewards-calculation/commit/${{ env.LATEST_COMMIT_HASH }}">${{ env.LATEST_COMMIT_HASH_SHORT }}</a></p></footer>|' report-v${{ env.VERSION }}/treasury_calculation.html
75-
76-
- name: 📅 Publish report to gh-pages
77-
uses: JamesIves/github-pages-deploy-action@v4
78-
with:
79-
BRANCH: gh-pages
80-
folder: report-v${{ env.VERSION }}
81-
target-folder: report-latest/
82-
83-
- name: 📅 Publish report to gh-pages
84-
uses: JamesIves/github-pages-deploy-action@v4
85-
with:
86-
BRANCH: gh-pages
87-
folder: report-v${{ env.VERSION }}
88-
target-folder: report-v${{ env.VERSION }}/

.github/workflows/report.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 📊 Generate Report
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
workflow_dispatch:
9+
10+
jobs:
11+
create-report:
12+
runs-on: ubuntu-latest
13+
if: "github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, 'release-please--branches--main')"
14+
steps:
15+
- name: ⬇️ Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Setup JDK 18
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '18'
22+
distribution: 'temurin'
23+
cache: maven
24+
25+
- name: Setup dependencies
26+
run: |
27+
pip install yq
28+
29+
- name: JSON result to js file
30+
run: |
31+
echo -e "const treasuryCalculationResult = $(cat ./report/treasury_calculation_result.json)" > ./report/treasury_calculation_result.js
32+
33+
- name: 👀 Lookup metadata for report
34+
run: |
35+
echo "VERSION=$(xq -r .project.version pom.xml)" >> $GITHUB_ENV
36+
echo "LATEST_COMMIT_HASH=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_ENV
37+
echo "LATEST_COMMIT_HASH_SHORT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
38+
echo "UTC_DATE=$(date -uR|sed 's/.....$//')" >> $GITHUB_ENV
39+
40+
- name: 📂 Create report directory
41+
run: |
42+
mkdir -p report-v${{ env.VERSION }}
43+
44+
- name: 📄 Copy report files
45+
run: |
46+
cp -r report/* report-v${{ env.VERSION }}
47+
48+
- name: 📝 Add metadata to the report
49+
run: |
50+
sed -i 's|<footer></footer>|<footer><p>Created on ${{ env.UTC_DATE }} UTC as a result of modifications triggered by <a href="https://github.com/cardano-foundation/cf-java-rewards-calculation/commit/${{ env.LATEST_COMMIT_HASH }}">${{ env.LATEST_COMMIT_HASH_SHORT }}</a></p></footer>|' report-v${{ env.VERSION }}/treasury_calculation.html
51+
52+
- name: 📅 Publish report to gh-pages
53+
uses: JamesIves/github-pages-deploy-action@v4
54+
with:
55+
BRANCH: gh-pages
56+
folder: report-v${{ env.VERSION }}
57+
target-folder: report-latest/
58+
59+
- name: 📅 Publish report to gh-pages
60+
uses: JamesIves/github-pages-deploy-action@v4
61+
with:
62+
BRANCH: gh-pages
63+
folder: report-v${{ env.VERSION }}
64+
target-folder: report-v${{ env.VERSION }}/

report/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ window.onload = () => {
198198
const highestDifferenceEpoch = relativeDifference.x[relativeDifference.y.indexOf(highestDifference)];
199199
fillCard('highest-difference-percentage', 'Highest relative difference', `${highestDifference}%`, `Epoch ${highestDifferenceEpoch}`);
200200

201-
const highestAbsolutDifference = Math.max(...difference.y);
201+
const highestAbsolutDifference = difference.y.reduce((a, b) => Math.abs(a) > Math.abs(b) ? a : b);
202202
const highestAbsolutDifferenceEpoch = difference.x[difference.y.indexOf(highestAbsolutDifference)];
203203
fillCard('highest-absolut-difference', 'Highest absolut difference', `${highestAbsolutDifference.toLocaleString()}₳`, `Epoch ${highestAbsolutDifferenceEpoch}`);
204204

205-
const averageDifferenceMedian = relativeDifference.y.sort((a, b) => a - b)[Math.round(relativeDifference.y.length / 2)];
206-
fillCard('average-difference-percentage', 'Average relative difference', `${averageDifferenceMedian}%`, 'Median');
205+
const totalAbsoluteDifference = difference.y.reduce((a, b) => Math.abs(a) + Math.abs(b), 0);
206+
fillCard('total-absolute-difference', 'Total absolute difference', `${totalAbsoluteDifference}`, 'Sum of all differences');
207207

208208
const averageAbsolutDifferenceMedian = difference.y.sort((a, b) => a - b)[Math.round(difference.y.length / 2)]
209209
fillCard('average-absolut-difference', 'Average absolut difference', `${averageAbsolutDifferenceMedian.toLocaleString()}₳`, 'Median');

report/treasury_calculation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ <h2>Treasury Calculation Report</h2>
115115
<h4 id="epoch-info"></h4>
116116
<div class="cards">
117117
<div class="card" id="highest-difference-percentage"></div>
118-
<div class="card" id="average-difference-percentage"></div>
118+
<div class="card" id="total-absolute-difference"></div>
119119
<div class="card" id="highest-absolut-difference"></div>
120120
<div class="card" id="average-absolut-difference"></div>
121121
<div class="card" id="exact-matches"></div>

report/treasury_calculation_result.json

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ private void fetchSharedPoolRewardAddressWithoutReward(int epoch, boolean overri
321321
}
322322

323323
private void fetchLateAccountDeregistrationsInEpoch(int epoch, boolean override, boolean mainnet) {
324-
if (mainnet && epoch >= MAINNET_VASIL_HARDFORK_EPOCH) {
324+
int earnedEpoch = epoch - 2;
325+
if (mainnet && earnedEpoch > MAINNET_VASIL_HARDFORK_EPOCH) {
325326
return;
326327
}
327328

validation/src/test/java/org/cardanofoundation/rewards/validation/EpochValidationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void testCalculateEpochPots(final int epoch, DataProvider dataProvider, b
4343
}
4444

4545
static Stream<Integer> dataProviderEpochRange() {
46-
return IntStream.range(208, 230).boxed();
46+
return IntStream.range(360, 370).boxed();
4747
}
4848

4949
@ParameterizedTest
@@ -67,8 +67,8 @@ public void testCalculateEpochRewardsForEpoch417() {
6767

6868
@Test
6969
@EnabledIf(expression = "#{environment.acceptsProfiles('db-sync')}", loadContext = true, reason = "DB Sync data provider must be available for this test")
70-
public void testCalculateEpochRewardsForEpoch365() {
71-
testCalculateEpochPots(365, dbSyncDataProvider, true);
70+
public void testCalculateEpochRewardsForEpoch367() {
71+
testCalculateEpochPots(365, jsonDataProvider, false);
7272
}
7373

7474
@Test

0 commit comments

Comments
 (0)