diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 117e4c975d5..818ce174543 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -54,8 +54,7 @@ jobs: BENCHER_ADAPTER: json run: | set -euxo pipefail - workspace=$(pwd) - docker run --name k-posting-profiling-tests-${GITHUB_SHA} \ + docker run --name k-posting-profiling-tests-${GITHUB_SHA} \ --rm -it --detach \ -e BENCHER_API_TOKEN=$BENCHER_API_TOKEN \ -e BENCHER_PROJECT=$BENCHER_PROJECT \ @@ -67,6 +66,7 @@ jobs: -e GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME \ -e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \ -e GITHUB_REF=$GITHUB_REF \ + -e GITHUB_SHA=${GITHUB_SHA} \ --workdir /opt/workspace \ -v "${workspace}:/opt/workspace" \ ${BASE_OS}:${BASE_DISTRO} @@ -77,14 +77,14 @@ jobs: - name: 'Getting Performance Tests Results' run: | set -euxo pipefail - docker exec -t k-posting-profiling-tests-${GITHUB_SHA} /bin/bash -c './k-distribution/tests/profiling/post_results_to_develop.py' + docker exec -t k-posting-profiling-tests-${GITHUB_SHA} /bin/bash -c './k-distribution/tests/profiling/post_results_to_develop.py ${GITHUB_SHA}' - name: 'Posting Performance Tests Results' run: | set -euxo pipefail docker exec -t k-posting-profiling-tests-${GITHUB_SHA} /bin/bash -c 'bencher run \ --if-branch "develop" --else-if-branch "master" \ --file .profiling-results.json --err --ci-only-on-alert \ - --github-actions "${GITHUB_TOKEN}" 'echo "Exporting report"' + --github-actions "${GITHUB_TOKEN}" "echo Exporting report"' - name: 'Tear down Docker' if: always() run: | diff --git a/k-distribution/tests/profiling/post_results_to_develop.py b/k-distribution/tests/profiling/post_results_to_develop.py index 37104b56def..21716a86ba9 100755 --- a/k-distribution/tests/profiling/post_results_to_develop.py +++ b/k-distribution/tests/profiling/post_results_to_develop.py @@ -1,8 +1,9 @@ #!/usr/bin/env python3 import json +import sys import subprocess -COMMIT_SHA='' +COMMIT_SHA = sys.argv[1] FROM_BRANCH='' TO_BRANCH='develop' @@ -24,10 +25,6 @@ def execute_command(command): return result.stdout -# git command to get the last commit in develop -commit_command = [ 'git', 'log', '--format=\"%H\"', '-n', '1' ] -COMMIT_SHA = execute_command(commit_command).strip('\"').strip('\"\n') - # curl command to get the branch name of last commit in develop API_URL = 'https://api.github.com/repos/runtimeverification/k/commits/' \ + COMMIT_SHA + '/pulls' @@ -36,6 +33,9 @@ def execute_command(command): '\"X-GitHub-Api-Version:', '2022-11-28\"', API_URL] FROM_BRANCH = json.loads(execute_command(branch_command))[0]['head']['label'] +# If FROM_BRANCH contains user information get only the branch name +if ':' in FROM_BRANCH: FROM_BRANCH = FROM_BRANCH.split(':')[1] + print("Exporting last bencher report from", FROM_BRANCH, "to", TO_BRANCH) # This command will generate a JSON file with a list containing the last reports @@ -49,6 +49,8 @@ def execute_command(command): k_framework = [item for item in data if item['project']['slug'] == 'k-framework' and item['branch']['slug'] == FROM_BRANCH] +print("Found", len(k_framework), "reports for k-framework in", FROM_BRANCH) + # Append the last 6 reports to the list, they correspond to the last performance # execution on the last commit in FROM_BRANCH def get_name_and_value(item): @@ -64,7 +66,7 @@ def get_name_and_value(item): branch = item['branch'] print("Appended:", benchmark_name, "created in", item['created'], - "on branch", branch['name'], "with version", branch['version']['number']) + "on branch", branch['name'], "with id", branch['version']['number']) data.update({benchmark_name: {metric_name_size: {"value": value_size}, metric_name_memory: {"value": value_memory}}