Skip to content

Commit 1eda79a

Browse files
committedOct 19, 2024
ci: Attemp to fix performance calculation
1 parent 5bfe398 commit 1eda79a

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed
 

‎.github/perf-impr-calc.py

+15-18
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,21 @@
55
with open("performance-data.csv", "r") as file:
66
reader = csv.reader(file, delimiter=',')
77
next(reader)
8-
base_value = next(reader)[1]
9-
new_value = next(reader)[1]
8+
base_value = int(next(reader)[1])
9+
new_value = int(next(reader)[1])
1010
percent = ((base_value - new_value) / base_value) * 100
1111

12-
print("Average performance enhancement:", percent)
13-
# changelog = os.getenv("CHANGELOG")
14-
# # changelog = open("changelog.txt", "r", encoding="utf-8").read()
15-
# marker = "<<marker1>>"
16-
# first_index = changelog.find(marker)
17-
# if first_index == -1:
18-
# raise Exception("Position marker not found")
19-
#
20-
# last_index = first_index + len(marker)
21-
# print(f"Marker index at {first_index}")
22-
#
23-
# print("Writing changelog output")
24-
# changelog = changelog[:first_index] + str(average_percentage) + "%" + changelog[last_index:]
25-
# env_file = os.getenv('GITHUB_ENV')
26-
# with open(env_file, "a") as file:
27-
# file.write(f"NEW_CHANGELOG={changelog}")
12+
rounded_percent = round(percent, 2)
13+
print("Average performance enhancement:", rounded_percent)
14+
changelog = os.getenv("CHANGELOG")
15+
# changelog = open("changelog.txt", "r", encoding="utf-8").read()
16+
marker = "<<marker1>>"
17+
first_index = changelog.find(marker)
18+
if first_index == -1:
19+
raise Exception("Position marker not found")
2820

21+
print(f"Marker index at {first_index}")
22+
23+
print("Writing changelog output")
24+
changelog = changelog.replace(marker, str(rounded_percent))
25+
print(f"::set-output name=changelog::{changelog}")

‎.github/workflows/release-builder.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ jobs:
8989
uses: actions/checkout@v4
9090

9191
- name: Calculate and insert performance calculation
92+
id: github_release2
9293
shell: sh
94+
env:
95+
CHANGELOG: ${{ steps.github_release.outputs.changelog }}
9396
run: |
9497
cd .github
9598
python perf-impr-calc.py
@@ -122,7 +125,9 @@ jobs:
122125
123126
- name: Create Release
124127
uses: softprops/action-gh-release@v2
128+
env:
129+
CHANGELOG: ${{ steps.github_release2.outputs.changelog }}
125130
with:
126131
name: "Version ${{ env.RELEASE_VERSION }}"
127-
body: ${{steps.github_release.outputs.changelog}}
132+
body: ${{env.CHANGELOG}}
128133
files: app/build/outputs/apk/release/FlashDim-${{env.RELEASE_VERSION}}.apk

0 commit comments

Comments
 (0)
Please sign in to comment.