diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 99adb9555..28b9e2271 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -359,20 +359,20 @@ jobs: # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # restore-keys: | # ${{ runner.os }}-node- - # - name: Enable compiler cache - # uses: actions/cache@v3 - # with: - # path: ~/.ccache - # key: ccache-${{ matrix.name }}-${{ github.sha }} - # restore-keys: | - # ccache-${{ matrix.name }}- - # - name: Enable Conan cache - # uses: actions/cache@v3 - # with: - # path: ~/.conan - # key: v9-conan-${{ matrix.name }}-${{ github.sha }} - # restore-keys: | - # v9-conan-${{ matrix.name }}- + # - name: Enable compiler cache + # uses: actions/cache@v3 + # with: + # path: ~/.ccache + # key: ccache-${{ matrix.name }}-${{ github.sha }} + # restore-keys: | + # ccache-${{ matrix.name }}- + # - name: Enable Conan cache + # uses: actions/cache@v3 + # with: + # path: ~/.conan + # key: v9-conan-${{ matrix.name }}-${{ github.sha }} + # restore-keys: | + # v9-conan-${{ matrix.name }}- # - name: Enable test cache # uses: actions/cache@v3 # with: @@ -611,12 +611,26 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} GITHUB_REPOSITORY: ${{ github.repository }} steps: + - name: Enable compiler cache + uses: actions/cache@v3 + with: + path: ~/.ccache + key: v1-ccache-benchmarks-${{ github.sha }} + restore-keys: | + v1-ccache-benchmarks- + - name: Enable Conan cache + uses: actions/cache@v3 + with: + path: ~/.conan + key: v1-conan-benchmarks-${{ github.sha }} + restore-keys: | + v1-conan-benchmarks- - name: Checkout PR Branch uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} path: pr - - run: pip install "conan<2.0.0" + - run: python3 -m pip install "conan<2.0.0" "requests==2.31.0" - name: Build run: | mkdir -p pr/build @@ -628,7 +642,7 @@ jobs: make -C test/data - name: Run Benchmark on Master Branch run: | - ./pr/build/src/benchmarks/match-bench ../test/data/mld/monaco.osrm mld > pr_bench.txt + ./pr/build/src/benchmarks/match-bench ./pr/test/data/mld/monaco.osrm mld > pr_bench.txt - name: Checkout Master Branch uses: actions/checkout@v3 with: @@ -645,7 +659,7 @@ jobs: make -C test/data - name: Run Benchmark on Master Branch run: | - ./master/build/src/benchmarks/match-bench ../test/data/mld/monaco.osrm mld > master_bench.txt + ./master/build/src/benchmarks/match-bench ./master/test/data/mld/monaco.osrm mld > master_bench.txt - name: Compare Benchmarks run: | cat pr_bench.txt diff --git a/scripts/ci/post_benchmark_results.py b/scripts/ci/post_benchmark_results.py index 41e63721c..5ac035b8c 100644 --- a/scripts/ci/post_benchmark_results.py +++ b/scripts/ci/post_benchmark_results.py @@ -1,10 +1,10 @@ import requests import os +import re -# GitHub token and repository details -GITHUB_TOKEN = os.getenv('GITHUB_TOKEN') # Ensure this token has repo and workflow permissions -REPO = os.getenv('GITHUB_REPOSITORY') -PR_NUMBER = os.getenv('PR_NUMBER') # Ensure this is set in the GitHub Actions environment +GITHUB_TOKEN = os.getenv('GITHUB_TOKEN') +REPO = os.getenv('GITHUB_REPOSITORY') +PR_NUMBER = os.getenv('PR_NUMBER') REPO_OWNER, REPO_NAME = REPO.split('/') @@ -36,15 +36,26 @@ def update_comment(comment_id, repo_owner, repo_name, body): def main(): comments = get_pr_comments(REPO_OWNER, REPO_NAME, PR_NUMBER) - if comments: + if comments and len(comments) > 0: first_comment = comments[0] markdown_table = create_markdown_table(benchmark_results) - new_body = f"{first_comment['body']}\n\n### Benchmark Results\n{markdown_table}" - update_comment(first_comment['id'], REPO_OWNER, REPO_NAME, new_body) + new_benchmark_section = f"\n## Benchmark Results\n{markdown_table}\n" + + if re.search(r'.*', first_comment['body'], re.DOTALL): + updated_body = re.sub( + r'.*', + new_benchmark_section, + first_comment['body'], + flags=re.DOTALL + ) + else: + updated_body = f"{first_comment['body']}\n\n{new_benchmark_section}" + + update_comment(first_comment['id'], REPO_OWNER, REPO_NAME, updated_body) print("PR comment updated successfully.") else: print("No comments found on this PR.") exit(1) if __name__ == "__main__": - main() \ No newline at end of file + main()