From ab94d4e6096cd0dfd9589da96db927523211e449 Mon Sep 17 00:00:00 2001 From: Niko Diamadis Date: Sat, 19 Oct 2024 07:39:53 -0400 Subject: [PATCH] ci: Attemp to fix performance calculation --- .github/perf-impr-calc.py | 33 ++++++++++++--------------- .github/workflows/release-builder.yml | 7 +++++- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/perf-impr-calc.py b/.github/perf-impr-calc.py index 88be430..aefcd57 100644 --- a/.github/perf-impr-calc.py +++ b/.github/perf-impr-calc.py @@ -5,24 +5,21 @@ with open("performance-data.csv", "r") as file: reader = csv.reader(file, delimiter=',') next(reader) - base_value = next(reader)[1] - new_value = next(reader)[1] + base_value = int(next(reader)[1]) + new_value = int(next(reader)[1]) percent = ((base_value - new_value) / base_value) * 100 -print("Average performance enhancement:", percent) -# changelog = os.getenv("CHANGELOG") -# # changelog = open("changelog.txt", "r", encoding="utf-8").read() -# marker = "<>" -# first_index = changelog.find(marker) -# if first_index == -1: -# raise Exception("Position marker not found") -# -# last_index = first_index + len(marker) -# print(f"Marker index at {first_index}") -# -# print("Writing changelog output") -# changelog = changelog[:first_index] + str(average_percentage) + "%" + changelog[last_index:] -# env_file = os.getenv('GITHUB_ENV') -# with open(env_file, "a") as file: -# file.write(f"NEW_CHANGELOG={changelog}") +rounded_percent = round(percent, 2) +print("Average performance enhancement:", rounded_percent) +changelog = os.getenv("CHANGELOG") +# changelog = open("changelog.txt", "r", encoding="utf-8").read() +marker = "<>" +first_index = changelog.find(marker) +if first_index == -1: + raise Exception("Position marker not found") +print(f"Marker index at {first_index}") + +print("Writing changelog output") +changelog = changelog.replace(marker, str(rounded_percent)) +print(f"::set-output name=changelog::{changelog}") diff --git a/.github/workflows/release-builder.yml b/.github/workflows/release-builder.yml index 9005eee..554b7b7 100644 --- a/.github/workflows/release-builder.yml +++ b/.github/workflows/release-builder.yml @@ -89,7 +89,10 @@ jobs: uses: actions/checkout@v4 - name: Calculate and insert performance calculation + id: github_release2 shell: sh + env: + CHANGELOG: ${{ steps.github_release.outputs.changelog }} run: | cd .github python perf-impr-calc.py @@ -122,7 +125,9 @@ jobs: - name: Create Release uses: softprops/action-gh-release@v2 + env: + CHANGELOG: ${{ steps.github_release2.outputs.changelog }} with: name: "Version ${{ env.RELEASE_VERSION }}" - body: ${{steps.github_release.outputs.changelog}} + body: ${{env.CHANGELOG}} files: app/build/outputs/apk/release/FlashDim-${{env.RELEASE_VERSION}}.apk