From b7ddc879c997b51089e1bf9652c0d0abe033a013 Mon Sep 17 00:00:00 2001 From: Lukas Petr Date: Wed, 27 Sep 2023 17:29:33 +0200 Subject: [PATCH] EqBench: Enable to run analysis in CI --- .github/workflows/analysis.yml | 68 ++++++++++++++++++++++++++++++++++ eqbench_scripts/analysis | 8 ++++ eqbench_scripts/run | 6 +++ 3 files changed, 82 insertions(+) create mode 100644 .github/workflows/analysis.yml diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml new file mode 100644 index 000000000..8f4b0ccb0 --- /dev/null +++ b/.github/workflows/analysis.yml @@ -0,0 +1,68 @@ +name: Analysis of DiffKemp equivalence checking + +on: [workflow_dispatch, push] + +jobs: + EqBench: + runs-on: ubuntu-latest + # todo refactor with ci.yaml - maybe creating action for building diffkemp + env: + llvm: 16 + CC: gcc-9 + CXX: g++-9 + asan: OFF + steps: + - uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - name: Install Dependencies + working-directory: ${{ github.workspace }} + shell: bash + run: | + sudo apt-get install bc cscope libelf-dev ninja-build + pip install -r requirements.txt + + - name: Install LLVM + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${llvm} main" + sudo apt-get update + sudo apt-get install llvm-${llvm} llvm-${llvm}-dev clang-${llvm} + sudo ln -s /usr/lib/llvm-${llvm} /usr/local/lib/llvm + echo "/usr/lib/llvm-${llvm}/bin" >> $GITHUB_PATH + + - name: Prepare Build Environment + run: | + mkdir -p ${{ github.workspace }}/build + + - name: CMake + working-directory: ${{ github.workspace }}/build + shell: bash + run: cmake $GITHUB_WORKSPACE -GNinja -DSANITIZE_ADDRESS=${{ env.asan }} -DVENDOR_GTEST=On + + - name: Build + working-directory: ${{ github.workspace }}/build + run: ninja + + - name: Install + working-directory: ${{ github.workspace }} + run: pip3 install -e . + + - name: Checkout on upstream master + working-directory: ${{ github.workspace }} + run: | + git remote add upstream git@github.com:viktormalik/diffkemp + git fetch upstream --depth=1 + git rebase upstream/master + - name: Get EqBench + working-directory: ${{ github.workspace }} + run: | + git clone https://github.com/shrBadihi/EqBench.git + - name: Run analysis + working-directory: ${{ github.workspace }} + run: | + eqbench_scripts/analysis compare-multiple eqbench-results EqBench diff --git a/eqbench_scripts/analysis b/eqbench_scripts/analysis index ed100a0d0..19c773fb7 100755 --- a/eqbench_scripts/analysis +++ b/eqbench_scripts/analysis @@ -7,6 +7,7 @@ import os import re import shutil import subprocess +from tabulate import tabulate from pathlib import Path from tempfile import mkdtemp @@ -73,6 +74,7 @@ def get_total(output_dir): program_level_pattern = re.compile( r"^\| program-level +\| *(\d+) \| +(\d+) \| +(\d+) \| +(\d+) \|$", re.MULTILINE) + results = [] for run in RUNS: result_file = os.path.join(output_dir, run[RUN_FILE], "result.md") with open(result_file, "r") as file: @@ -87,6 +89,12 @@ def get_total(output_dir): "same as build-kernel uses" if run[RUN_USE_LLVM_OPT] else "", run[RUN_DISABLE_PATTERNS], *function_program_total] print(";".join(result), flush=True) + results.append(result) + if "GITHUB_STEP_SUMMARY" in os.environ: + table = tabulate(results, headers=head, tablefmt="pipe") + with open(os.enviros["GITHUB_STEP_SUMMARY"], "a") as file: + print("## Total results") + print(table, file=file) def create_command(output_dir, eqbench_repo_path, diff --git a/eqbench_scripts/run b/eqbench_scripts/run index 050aff622..fd051714d 100755 --- a/eqbench_scripts/run +++ b/eqbench_scripts/run @@ -48,6 +48,7 @@ import tabulate from pathlib import Path from progressbar import ProgressBar import json +import os import re import shutil import subprocess @@ -345,6 +346,11 @@ class EqBenchRun: headers=header, tablefmt="pipe") print(report) + # Printing result summary if runs by github workflow + github_step_summary = os.getenv("GITHUB_STEP_SUMMARY") + if github_step_summary: + with open(github_step_summary, "a") as file: + print(report, file=file) # Saving summarisation of results to file report += f"\n\n(only-compare: {self.only_compare})\n" with open(Path(self.output_dir, "result.md"), "w") as file: