From dfb06ee793d91e1bb85a21c9e5c4e071fee087db Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Tue, 6 Sep 2022 15:32:58 -0700 Subject: [PATCH 1/9] Attemp to use AWS CI Runners instead of DO for CI --- .github/workflows/anghabench-after-build.yml | 175 ++++++++++++++++- .github/workflows/anghabench-cron-jobs.yml | 186 +++++++++++++++++-- 2 files changed, 342 insertions(+), 19 deletions(-) diff --git a/.github/workflows/anghabench-after-build.yml b/.github/workflows/anghabench-after-build.yml index 44e324a4..5c3ba199 100644 --- a/.github/workflows/anghabench-after-build.yml +++ b/.github/workflows/anghabench-after-build.yml @@ -8,12 +8,49 @@ on: types: [completed] jobs: - AnghaSmallRun: + start-runner: if: github.event.workflow_run.conclusion == 'success' + name: Start self-hosted EC2 runner runs-on: ubuntu-latest strategy: matrix: - llvm: ["14"] + ec2: + - { ami: ami-0610b26d76319237e, instance-type: m6i.8xlarge} + outputs: + label: ${{ steps.start-ec2-runner.outputs.label }} + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Start EC2 runner + id: start-ec2-runner + uses: machulav/ec2-github-runner@v2 + with: + mode: start + github-token: ${{ secrets.ACCESS_TOKEN }} + ec2-image-id: ${{ matrix.ec2.ami }} + ec2-instance-type: ${{ matrix.ec2.instance-type }} + subnet-id: subnet-0deb935f0bbfe1a5d + security-group-id: sg-0f6a02eb80fafb982 + aws-resource-tags: > # optional, requires additional permissions + [ + {"Key": "Name", "Value": "ec2-github-runner"}, + {"Key": "GitHubRepository", "Value": "${{ github.repository }}"} + ] + do-the-job: + strategy: + fail-fast: false + matrix: + llvm: [ '14' ] + run_size: [ '1k' ] + + name: Run AnghaBench CI (AMD64) + needs: start-runner # required to start the main job when the runner is ready + runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner steps: - uses: actions/checkout@v2 with: @@ -24,10 +61,138 @@ jobs: shell: bash run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" id: extract_branch - - name: Run against ${{ matrix.llvm }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Fix github token auth + shell: bash + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: | + export HOME=${HOME:-/root} + git config --global user.name "CI User" && git config --global user.email "ci@none.local" + git config --global url."https://${ACCESS_TOKEN}@github.com/".insteadOf "git@github.com:" + - name: Set up pre-requisies run: | - external/lifting-tools-ci/cloud/run-do-droplet.py --name "Rellic CI Run Post Build" --script scripts/run-on-anghabench.sh --env-vars RUN_SIZE=1k,RELLIC_BRANCH=${BRANCH},LLVM_VERSION=${{ matrix.llvm }} + sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get -qqy upgrade + sudo apt-get install -qqy \ + git curl wget unzip xz-utils pixz jq s3cmd ninja-build pkg-config \ + liblzma-dev zlib1g-dev libtinfo-dev build-essential \ + libc6-dev:i386 libstdc++-*-dev:i386 g++-multilib + wget "https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3-linux-$(uname -m).sh" && \ + /bin/bash cmake-*.sh --skip-license --prefix=/usr/local && rm cmake-*.sh + python3 -m pip install requests + - name: Build rellic against LLVM ${{ matrix.llvm }} + run: | + ./scripts/build.sh \ + --install \ + --extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \ + --download-dir "$(pwd)/../pre-built-llvm-${{ matrix.llvm }}" \ + --llvm-version ${{ matrix.llvm }} \ + - name: Fetch Angha Data for LLVM {{ matrix.llvm }} + run: | + pushd external/lifting-tools-ci + if [[ -f requirements.txt ]] + then + python3 -m pip install -r requirements.txt + fi + + mkdir -p $(pwd)/decompiled + mkdir -p $(pwd)/recompiled + + datasets/fetch_anghabench.sh --clang "${LLVM_VERSION}" --bitcode --run-size "${RUN_SIZE}" + + for i in *.tar.xz + do + tar -xJf $i + done + popd env: + LLVM_VERSION: ${{ matrix.llvm }} + RUN_SIZE: ${{ matrix.run_size }} + + - name: Run Angha Against LLVM {{ matrix.llvm }} + run: | + + pushd external/lifting-tools-ci + # Run the benchmark + tool_run_scripts/rellic.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [rellic: ${RELLIC_BRANCH}]" \ + --rellic rellic-decomp \ + --input-dir $(pwd)/bitcode \ + --output-dir $(pwd)/decompiled \ + --slack-notify + + # Try to recompile our decompiled code + tool_run_scripts/recompile.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [recompile]" \ + --clang clang-${LLVM_VERSION} \ + --input-dir $(pwd)/decompiled \ + --output-dir $(pwd)/recompiled \ + --slack-notify + env: + RUN_SIZE: ${{ matrix.run_size }} + RELLIC_BRANCH: ${{ steps.extract_branch.outputs.branch }} + RUN_NAME: "Rellic After Build CI Run" SLACK_HOOK: ${{ secrets.SLACK_HOOK }} DO_TOKEN: ${{ secrets.DO_TOKEN }} - BRANCH: ${{ steps.extract_branch.outputs.branch }} + LLVM_VERSION: ${{ matrix.llvm }} + + - name: Save Angha Run for LLVM {{ matrix.llvm }} + run: | + # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY passed in from original invocation environment + if [[ "${AWS_ACCESS_KEY_ID,,}" != "" ]] + then + datenow=$(date +'%F-%H-%M') + url_base="https://tob-amp-ci-results.nyc3.digitaloceanspaces.com" + tar -Ipixz -cf rellic-ci-${datenow}.tar.xz decompiled + tar -Ipixz -cf recompile-ci-${datenow}.tar.xz recompiled + + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + rellic-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/rellic/ + + tool_run_scripts/slack.py \ + --msg "Uploaded rellic decompilation results to ${url_base}/rellic/rellic-ci-${datenow}.tar.xz" + + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + recompile-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/recompile/ + + tool_run_scripts/slack.py \ + --msg "Uploaded recompilation results to ${url_base}/recompile/recompile-ci-${datenow}.tar.xz" + fi + env: + AWS_ACCESS_KEY_ID: ${{ secrets.DO_SPACES_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SPACES_SECRET }} + SLACK_HOOK: ${{ secrets.SLACK_HOOK }} + + stop-runner: + name: Stop self-hosted EC2 runner + needs: + - start-runner # required to get output from the start-runner job + - do-the-job # required to wait when the main job is done + runs-on: ubuntu-latest + if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Stop EC2 runner + uses: machulav/ec2-github-runner@v2 + with: + mode: stop + github-token: ${{ secrets.ACCESS_TOKEN }} + label: ${{ needs.start-runner.outputs.label }} + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} + diff --git a/.github/workflows/anghabench-cron-jobs.yml b/.github/workflows/anghabench-cron-jobs.yml index 8d28c4e1..4cfc7dd6 100644 --- a/.github/workflows/anghabench-cron-jobs.yml +++ b/.github/workflows/anghabench-cron-jobs.yml @@ -6,33 +6,191 @@ on: - cron: "0 3 * * *" jobs: - AnghaBenchRuns: + start-runner: + if: github.event.workflow_run.conclusion == 'success' + name: Start self-hosted EC2 runner runs-on: ubuntu-latest strategy: matrix: - llvm: ["14"] + ec2: + - { ami: ami-0610b26d76319237e, instance-type: m6i.8xlarge} + outputs: + label: ${{ steps.start-ec2-runner.outputs.label }} + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Start EC2 runner + id: start-ec2-runner + uses: machulav/ec2-github-runner@v2 + with: + mode: start + github-token: ${{ secrets.ACCESS_TOKEN }} + ec2-image-id: ${{ matrix.ec2.ami }} + ec2-instance-type: ${{ matrix.ec2.instance-type }} + subnet-id: subnet-0deb935f0bbfe1a5d + security-group-id: sg-0f6a02eb80fafb982 + aws-resource-tags: > # optional, requires additional permissions + [ + {"Key": "Name", "Value": "ec2-github-runner"}, + {"Key": "GitHubRepository", "Value": "${{ github.repository }}"} + ] + do-the-job: + strategy: + fail-fast: false + matrix: + llvm: [ '14' ] + run_size: [ '1k' ] + + name: Run AnghaBench CI (AMD64) + needs: start-runner # required to start the main job when the runner is ready + runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner steps: - uses: actions/checkout@v2 with: + ref: ${{ github.event.workflow_run.head_branch }} submodules: true # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions - name: Extract branch name shell: bash run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" id: extract_branch - - name: Small Run (1K) against LLVM ${{ matrix.llvm }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Fix github token auth + shell: bash + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: | + export HOME=${HOME:-/root} + git config --global user.name "CI User" && git config --global user.email "ci@none.local" + git config --global url."https://${ACCESS_TOKEN}@github.com/".insteadOf "git@github.com:" + - name: Set up pre-requisies run: | - external/lifting-tools-ci/cloud/run-do-droplet.py --name "Rellic CI 1K Run" --script scripts/run-on-anghabench.sh --env-vars RUN_SIZE=1k,RELLIC_BRANCH=${BRANCH},LLVM_VERSION=${{ matrix.llvm }} + sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get -qqy upgrade + sudo apt-get install -qqy \ + git curl wget unzip xz-utils pixz jq s3cmd ninja-build pkg-config \ + liblzma-dev zlib1g-dev libtinfo-dev build-essential \ + libc6-dev:i386 libstdc++-*-dev:i386 g++-multilib + wget "https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3-linux-$(uname -m).sh" && \ + /bin/bash cmake-*.sh --skip-license --prefix=/usr/local && rm cmake-*.sh + python3 -m pip install requests + - name: Build rellic against LLVM ${{ matrix.llvm }} + run: | + ./scripts/build.sh \ + --install \ + --extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \ + --download-dir "$(pwd)/../pre-built-llvm-${{ matrix.llvm }}" \ + --llvm-version ${{ matrix.llvm }} \ + - name: Fetch Angha Data for LLVM {{ matrix.llvm }} + run: | + pushd external/lifting-tools-ci + if [[ -f requirements.txt ]] + then + python3 -m pip install -r requirements.txt + fi + + mkdir -p $(pwd)/decompiled + mkdir -p $(pwd)/recompiled + + datasets/fetch_anghabench.sh --clang "${LLVM_VERSION}" --bitcode --run-size "${RUN_SIZE}" + + for i in *.tar.xz + do + tar -xJf $i + done + popd env: + LLVM_VERSION: ${{ matrix.llvm }} + RUN_SIZE: ${{ matrix.run_size }} + + - name: Run Angha Against LLVM {{ matrix.llvm }} + run: | + + pushd external/lifting-tools-ci + # Run the benchmark + tool_run_scripts/rellic.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [rellic: ${RELLIC_BRANCH}]" \ + --rellic rellic-decomp \ + --input-dir $(pwd)/bitcode \ + --output-dir $(pwd)/decompiled \ + --slack-notify + + # Try to recompile our decompiled code + tool_run_scripts/recompile.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [recompile]" \ + --clang clang-${LLVM_VERSION} \ + --input-dir $(pwd)/decompiled \ + --output-dir $(pwd)/recompiled \ + --slack-notify + env: + RUN_SIZE: ${{ matrix.run_size }} + RELLIC_BRANCH: ${{ steps.extract_branch.outputs.branch }} + RUN_NAME: "Rellic Cron Job CI Run" SLACK_HOOK: ${{ secrets.SLACK_HOOK }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} DO_TOKEN: ${{ secrets.DO_TOKEN }} - BRANCH: ${{ steps.extract_branch.outputs.branch }} - #- name: Big Run (1M) against LLM ${{ matrix.llvm }} - # run: | - # external/lifting-tools-ci/cloud/run-do-droplet.py --name "Rellic CI 1M Run" --script scripts/run-on-anghabench.sh --env-vars RUN_SIZE=1m,RELLIC_BRANCH=${BRANCH},LLVM_VERSION=${{ matrix.llvm }} - # env: - # SLACK_HOOK: ${{ secrets.SLACK_HOOK }} - # DO_TOKEN: ${{ secrets.DO_TOKEN }} - # BRANCH: ${{ steps.extract_branch.outputs.branch }} + LLVM_VERSION: ${{ matrix.llvm }} + + - name: Save Angha Run for LLVM {{ matrix.llvm }} + run: | + # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY passed in from original invocation environment + if [[ "${AWS_ACCESS_KEY_ID,,}" != "" ]] + then + datenow=$(date +'%F-%H-%M') + url_base="https://tob-amp-ci-results.nyc3.digitaloceanspaces.com" + tar -Ipixz -cf rellic-ci-${datenow}.tar.xz decompiled + tar -Ipixz -cf recompile-ci-${datenow}.tar.xz recompiled + + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + rellic-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/rellic/ + + tool_run_scripts/slack.py \ + --msg "Uploaded rellic decompilation results to ${url_base}/rellic/rellic-ci-${datenow}.tar.xz" + + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + recompile-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/recompile/ + + tool_run_scripts/slack.py \ + --msg "Uploaded recompilation results to ${url_base}/recompile/recompile-ci-${datenow}.tar.xz" + fi + env: + AWS_ACCESS_KEY_ID: ${{ secrets.DO_SPACES_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SPACES_SECRET }} + SLACK_HOOK: ${{ secrets.SLACK_HOOK }} + + stop-runner: + name: Stop self-hosted EC2 runner + needs: + - start-runner # required to get output from the start-runner job + - do-the-job # required to wait when the main job is done + runs-on: ubuntu-latest + if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Stop EC2 runner + uses: machulav/ec2-github-runner@v2 + with: + mode: stop + github-token: ${{ secrets.ACCESS_TOKEN }} + label: ${{ needs.start-runner.outputs.label }} + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} + From a83ab326de9df53da4fd1c932a4de582d14ca858 Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Tue, 6 Sep 2022 15:36:31 -0700 Subject: [PATCH 2/9] tabs -> spaces --- .github/workflows/anghabench-after-build.yml | 108 +++++++++---------- .github/workflows/anghabench-cron-jobs.yml | 108 +++++++++---------- 2 files changed, 108 insertions(+), 108 deletions(-) diff --git a/.github/workflows/anghabench-after-build.yml b/.github/workflows/anghabench-after-build.yml index 5c3ba199..5e89a1d7 100644 --- a/.github/workflows/anghabench-after-build.yml +++ b/.github/workflows/anghabench-after-build.yml @@ -87,26 +87,26 @@ jobs: run: | ./scripts/build.sh \ --install \ - --extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \ - --download-dir "$(pwd)/../pre-built-llvm-${{ matrix.llvm }}" \ - --llvm-version ${{ matrix.llvm }} \ + --extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \ + --download-dir "$(pwd)/../pre-built-llvm-${{ matrix.llvm }}" \ + --llvm-version ${{ matrix.llvm }} \ - name: Fetch Angha Data for LLVM {{ matrix.llvm }} run: | pushd external/lifting-tools-ci - if [[ -f requirements.txt ]] - then - python3 -m pip install -r requirements.txt - fi + if [[ -f requirements.txt ]] + then + python3 -m pip install -r requirements.txt + fi - mkdir -p $(pwd)/decompiled - mkdir -p $(pwd)/recompiled + mkdir -p $(pwd)/decompiled + mkdir -p $(pwd)/recompiled - datasets/fetch_anghabench.sh --clang "${LLVM_VERSION}" --bitcode --run-size "${RUN_SIZE}" + datasets/fetch_anghabench.sh --clang "${LLVM_VERSION}" --bitcode --run-size "${RUN_SIZE}" - for i in *.tar.xz - do - tar -xJf $i - done + for i in *.tar.xz + do + tar -xJf $i + done popd env: LLVM_VERSION: ${{ matrix.llvm }} @@ -116,59 +116,59 @@ jobs: run: | pushd external/lifting-tools-ci - # Run the benchmark - tool_run_scripts/rellic.py \ - --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [rellic: ${RELLIC_BRANCH}]" \ - --rellic rellic-decomp \ - --input-dir $(pwd)/bitcode \ - --output-dir $(pwd)/decompiled \ - --slack-notify + # Run the benchmark + tool_run_scripts/rellic.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [rellic: ${RELLIC_BRANCH}]" \ + --rellic rellic-decomp \ + --input-dir $(pwd)/bitcode \ + --output-dir $(pwd)/decompiled \ + --slack-notify - # Try to recompile our decompiled code - tool_run_scripts/recompile.py \ - --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [recompile]" \ - --clang clang-${LLVM_VERSION} \ - --input-dir $(pwd)/decompiled \ - --output-dir $(pwd)/recompiled \ - --slack-notify + # Try to recompile our decompiled code + tool_run_scripts/recompile.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [recompile]" \ + --clang clang-${LLVM_VERSION} \ + --input-dir $(pwd)/decompiled \ + --output-dir $(pwd)/recompiled \ + --slack-notify env: RUN_SIZE: ${{ matrix.run_size }} RELLIC_BRANCH: ${{ steps.extract_branch.outputs.branch }} - RUN_NAME: "Rellic After Build CI Run" + RUN_NAME: "Rellic After Build CI Run" SLACK_HOOK: ${{ secrets.SLACK_HOOK }} DO_TOKEN: ${{ secrets.DO_TOKEN }} LLVM_VERSION: ${{ matrix.llvm }} - name: Save Angha Run for LLVM {{ matrix.llvm }} run: | - # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY passed in from original invocation environment - if [[ "${AWS_ACCESS_KEY_ID,,}" != "" ]] - then - datenow=$(date +'%F-%H-%M') - url_base="https://tob-amp-ci-results.nyc3.digitaloceanspaces.com" - tar -Ipixz -cf rellic-ci-${datenow}.tar.xz decompiled - tar -Ipixz -cf recompile-ci-${datenow}.tar.xz recompiled + # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY passed in from original invocation environment + if [[ "${AWS_ACCESS_KEY_ID,,}" != "" ]] + then + datenow=$(date +'%F-%H-%M') + url_base="https://tob-amp-ci-results.nyc3.digitaloceanspaces.com" + tar -Ipixz -cf rellic-ci-${datenow}.tar.xz decompiled + tar -Ipixz -cf recompile-ci-${datenow}.tar.xz recompiled - s3cmd -c /dev/null \ - '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ - --acl-public \ - put \ - rellic-ci-${datenow}.tar.xz \ - s3://tob-amp-ci-results/rellic/ + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + rellic-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/rellic/ - tool_run_scripts/slack.py \ - --msg "Uploaded rellic decompilation results to ${url_base}/rellic/rellic-ci-${datenow}.tar.xz" - - s3cmd -c /dev/null \ - '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ - --acl-public \ - put \ - recompile-ci-${datenow}.tar.xz \ - s3://tob-amp-ci-results/recompile/ + tool_run_scripts/slack.py \ + --msg "Uploaded rellic decompilation results to ${url_base}/rellic/rellic-ci-${datenow}.tar.xz" + + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + recompile-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/recompile/ - tool_run_scripts/slack.py \ - --msg "Uploaded recompilation results to ${url_base}/recompile/recompile-ci-${datenow}.tar.xz" - fi + tool_run_scripts/slack.py \ + --msg "Uploaded recompilation results to ${url_base}/recompile/recompile-ci-${datenow}.tar.xz" + fi env: AWS_ACCESS_KEY_ID: ${{ secrets.DO_SPACES_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SPACES_SECRET }} diff --git a/.github/workflows/anghabench-cron-jobs.yml b/.github/workflows/anghabench-cron-jobs.yml index 4cfc7dd6..e7d83fa8 100644 --- a/.github/workflows/anghabench-cron-jobs.yml +++ b/.github/workflows/anghabench-cron-jobs.yml @@ -85,26 +85,26 @@ jobs: run: | ./scripts/build.sh \ --install \ - --extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \ - --download-dir "$(pwd)/../pre-built-llvm-${{ matrix.llvm }}" \ - --llvm-version ${{ matrix.llvm }} \ + --extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \ + --download-dir "$(pwd)/../pre-built-llvm-${{ matrix.llvm }}" \ + --llvm-version ${{ matrix.llvm }} \ - name: Fetch Angha Data for LLVM {{ matrix.llvm }} run: | pushd external/lifting-tools-ci - if [[ -f requirements.txt ]] - then - python3 -m pip install -r requirements.txt - fi + if [[ -f requirements.txt ]] + then + python3 -m pip install -r requirements.txt + fi - mkdir -p $(pwd)/decompiled - mkdir -p $(pwd)/recompiled + mkdir -p $(pwd)/decompiled + mkdir -p $(pwd)/recompiled - datasets/fetch_anghabench.sh --clang "${LLVM_VERSION}" --bitcode --run-size "${RUN_SIZE}" + datasets/fetch_anghabench.sh --clang "${LLVM_VERSION}" --bitcode --run-size "${RUN_SIZE}" - for i in *.tar.xz - do - tar -xJf $i - done + for i in *.tar.xz + do + tar -xJf $i + done popd env: LLVM_VERSION: ${{ matrix.llvm }} @@ -114,59 +114,59 @@ jobs: run: | pushd external/lifting-tools-ci - # Run the benchmark - tool_run_scripts/rellic.py \ - --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [rellic: ${RELLIC_BRANCH}]" \ - --rellic rellic-decomp \ - --input-dir $(pwd)/bitcode \ - --output-dir $(pwd)/decompiled \ - --slack-notify + # Run the benchmark + tool_run_scripts/rellic.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [rellic: ${RELLIC_BRANCH}]" \ + --rellic rellic-decomp \ + --input-dir $(pwd)/bitcode \ + --output-dir $(pwd)/decompiled \ + --slack-notify - # Try to recompile our decompiled code - tool_run_scripts/recompile.py \ - --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [recompile]" \ - --clang clang-${LLVM_VERSION} \ - --input-dir $(pwd)/decompiled \ - --output-dir $(pwd)/recompiled \ - --slack-notify + # Try to recompile our decompiled code + tool_run_scripts/recompile.py \ + --run-name "[${RUN_NAME}] [size: ${RUN_SIZE}] [recompile]" \ + --clang clang-${LLVM_VERSION} \ + --input-dir $(pwd)/decompiled \ + --output-dir $(pwd)/recompiled \ + --slack-notify env: RUN_SIZE: ${{ matrix.run_size }} RELLIC_BRANCH: ${{ steps.extract_branch.outputs.branch }} - RUN_NAME: "Rellic Cron Job CI Run" + RUN_NAME: "Rellic Cron Job CI Run" SLACK_HOOK: ${{ secrets.SLACK_HOOK }} DO_TOKEN: ${{ secrets.DO_TOKEN }} LLVM_VERSION: ${{ matrix.llvm }} - name: Save Angha Run for LLVM {{ matrix.llvm }} run: | - # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY passed in from original invocation environment - if [[ "${AWS_ACCESS_KEY_ID,,}" != "" ]] - then - datenow=$(date +'%F-%H-%M') - url_base="https://tob-amp-ci-results.nyc3.digitaloceanspaces.com" - tar -Ipixz -cf rellic-ci-${datenow}.tar.xz decompiled - tar -Ipixz -cf recompile-ci-${datenow}.tar.xz recompiled + # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY passed in from original invocation environment + if [[ "${AWS_ACCESS_KEY_ID,,}" != "" ]] + then + datenow=$(date +'%F-%H-%M') + url_base="https://tob-amp-ci-results.nyc3.digitaloceanspaces.com" + tar -Ipixz -cf rellic-ci-${datenow}.tar.xz decompiled + tar -Ipixz -cf recompile-ci-${datenow}.tar.xz recompiled - s3cmd -c /dev/null \ - '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ - --acl-public \ - put \ - rellic-ci-${datenow}.tar.xz \ - s3://tob-amp-ci-results/rellic/ + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + rellic-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/rellic/ - tool_run_scripts/slack.py \ - --msg "Uploaded rellic decompilation results to ${url_base}/rellic/rellic-ci-${datenow}.tar.xz" - - s3cmd -c /dev/null \ - '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ - --acl-public \ - put \ - recompile-ci-${datenow}.tar.xz \ - s3://tob-amp-ci-results/recompile/ + tool_run_scripts/slack.py \ + --msg "Uploaded rellic decompilation results to ${url_base}/rellic/rellic-ci-${datenow}.tar.xz" + + s3cmd -c /dev/null \ + '--host-bucket=%(bucket)s.nyc3.digitaloceanspaces.com' \ + --acl-public \ + put \ + recompile-ci-${datenow}.tar.xz \ + s3://tob-amp-ci-results/recompile/ - tool_run_scripts/slack.py \ - --msg "Uploaded recompilation results to ${url_base}/recompile/recompile-ci-${datenow}.tar.xz" - fi + tool_run_scripts/slack.py \ + --msg "Uploaded recompilation results to ${url_base}/recompile/recompile-ci-${datenow}.tar.xz" + fi env: AWS_ACCESS_KEY_ID: ${{ secrets.DO_SPACES_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SPACES_SECRET }} From 49a52177b1633a8ea3581ac6dbb7fe5df5bf59a7 Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Tue, 6 Sep 2022 16:13:19 -0700 Subject: [PATCH 3/9] Switch to AWS for regular CI flow since it uses integration tests --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b975fe92..37d73336 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,40 @@ on: - '*' jobs: - build_linux: + start-runner: + if: github.event.workflow_run.conclusion == 'success' + name: Start self-hosted EC2 runner (Linux) + runs-on: ubuntu-latest + strategy: + matrix: + ec2: + - { ami: ami-0610b26d76319237e, instance-type: m6i.8xlarge} + outputs: + label: ${{ steps.start-ec2-runner.outputs.label }} + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Start EC2 runner + id: start-ec2-runner + uses: machulav/ec2-github-runner@v2 + with: + mode: start + github-token: ${{ secrets.ACCESS_TOKEN }} + ec2-image-id: ${{ matrix.ec2.ami }} + ec2-instance-type: ${{ matrix.ec2.instance-type }} + subnet-id: subnet-0deb935f0bbfe1a5d + security-group-id: sg-0f6a02eb80fafb982 + aws-resource-tags: > # optional, requires additional permissions + [ + {"Key": "Name", "Value": "ec2-github-runner"}, + {"Key": "GitHubRepository", "Value": "${{ github.repository }}"} + ] + do-the-job: strategy: fail-fast: false matrix: @@ -27,7 +60,7 @@ jobs: '14' ] - runs-on: ubuntu-20.04 + runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner container: image: docker.pkg.github.com/lifting-bits/cxx-common/vcpkg-builder-${{ matrix.image.name }}:${{ matrix.image.tag }} credentials: @@ -120,6 +153,28 @@ jobs: name: ${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm${{ matrix.llvm }}_tgz_package path: ${{ steps.package_names.outputs.TGZ_PACKAGE_PATH }} + stop-runner: + name: Stop self-hosted EC2 runner (Linux) + needs: + - start-runner # required to get output from the start-runner job + - do-the-job # required to wait when the main job is done + runs-on: ubuntu-latest + if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Stop EC2 runner + uses: machulav/ec2-github-runner@v2 + with: + mode: stop + github-token: ${{ secrets.ACCESS_TOKEN }} + label: ${{ needs.start-runner.outputs.label }} + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} + build_mac: strategy: fail-fast: false From b069930e5ee395c5152d7681fcd6d5be98fd4bfa Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Tue, 6 Sep 2022 16:24:41 -0700 Subject: [PATCH 4/9] Run diff tests in AWS also --- .github/workflows/ci.yml | 3 ++- .github/workflows/diff_tests.yml | 40 +++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37d73336..27cd83ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,6 @@ on: jobs: start-runner: - if: github.event.workflow_run.conclusion == 'success' name: Start self-hosted EC2 runner (Linux) runs-on: ubuntu-latest strategy: @@ -60,6 +59,8 @@ jobs: '14' ] + name: Rellic CI + needs: start-runner # required to start the main job when the runner is ready runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner container: image: docker.pkg.github.com/lifting-bits/cxx-common/vcpkg-builder-${{ matrix.image.name }}:${{ matrix.image.tag }} diff --git a/.github/workflows/diff_tests.yml b/.github/workflows/diff_tests.yml index d4bada95..386fba25 100644 --- a/.github/workflows/diff_tests.yml +++ b/.github/workflows/diff_tests.yml @@ -6,7 +6,39 @@ on: - '*' jobs: - build_linux: + start-runner: + name: Start self-hosted EC2 runner (Linux) + runs-on: ubuntu-latest + strategy: + matrix: + ec2: + - { ami: ami-0610b26d76319237e, instance-type: m6i.8xlarge} + outputs: + label: ${{ steps.start-ec2-runner.outputs.label }} + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Start EC2 runner + id: start-ec2-runner + uses: machulav/ec2-github-runner@v2 + with: + mode: start + github-token: ${{ secrets.ACCESS_TOKEN }} + ec2-image-id: ${{ matrix.ec2.ami }} + ec2-instance-type: ${{ matrix.ec2.instance-type }} + subnet-id: subnet-0deb935f0bbfe1a5d + security-group-id: sg-0f6a02eb80fafb982 + aws-resource-tags: > # optional, requires additional permissions + [ + {"Key": "Name", "Value": "ec2-github-runner"}, + {"Key": "GitHubRepository", "Value": "${{ github.repository }}"} + ] + do-the-job: strategy: fail-fast: false matrix: @@ -19,7 +51,9 @@ jobs: CC: clang-${{ matrix.llvm }} CXX: clang++-${{ matrix.llvm }} - runs-on: ubuntu-20.04 + name: Diff in ouput between old and new rellic + needs: start-runner # required to start the main job when the runner is ready + runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner container: image: docker.pkg.github.com/lifting-bits/cxx-common/vcpkg-builder-${{ matrix.image.name }}:${{ matrix.image.tag }} credentials: @@ -108,4 +142,4 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: message - }) \ No newline at end of file + }) From 2197019286a685535e03759729bd3cfa3641a19f Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Tue, 6 Sep 2022 16:41:36 -0700 Subject: [PATCH 5/9] Ninja build. --- .github/workflows/ci.yml | 2 +- .github/workflows/diff_tests.yml | 6 +++--- scripts/build.sh | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27cd83ae..24d0804f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" >> /etc/apt/sources.list echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" >> /etc/apt/sources.list apt-get update - apt-get install -y pixz xz-utils make rpm python3.8 + apt-get install -y ninja-build pixz xz-utils make rpm python3.8 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 100 - name: Build with build script diff --git a/.github/workflows/diff_tests.yml b/.github/workflows/diff_tests.yml index 386fba25..44752d4a 100644 --- a/.github/workflows/diff_tests.yml +++ b/.github/workflows/diff_tests.yml @@ -83,7 +83,7 @@ jobs: echo "deb http://apt.llvm.org/${{ matrix.image.codename }}/ llvm-toolchain-${{ matrix.image.codename }}-${{ matrix.llvm }} main" >> /etc/apt/sources.list echo "deb-src http://apt.llvm.org/${{ matrix.image.codename }}/ llvm-toolchain-${{ matrix.image.codename }}-${{ matrix.llvm }} main" >> /etc/apt/sources.list apt-get update - apt-get install -y pixz xz-utils make rpm python3.8 clang-${{ matrix.llvm }} + apt-get install -y ninja-build pixz xz-utils make rpm python3.8 clang-${{ matrix.llvm }} update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 100 - name: Download cxx-commons shell: bash @@ -95,13 +95,13 @@ jobs: - name: Build old rellic shell: bash run: | - cmake -S old -B rellic-build-old -DVCPKG_ROOT=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64 + cmake -G Ninja -S old -B rellic-build-old -DVCPKG_ROOT=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64 cmake --build rellic-build-old - name: Build new rellic shell: bash run: | - cmake -S . -B rellic-build -DVCPKG_ROOT=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64 + cmake -G Ninja -S . -B rellic-build -DVCPKG_ROOT=$GITHUB_WORKSPACE/vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}_amd64 cmake --build rellic-build - name: Print job summary diff --git a/scripts/build.sh b/scripts/build.sh index 0e665ce5..428f8272 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -231,6 +231,7 @@ function Configure ( set -x cmake \ + -G Ninja \ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -DCMAKE_VERBOSE_MAKEFILE=True \ -DVCPKG_ROOT="${DOWNLOAD_DIR}/${LIBRARY_VERSION}" \ From 033f5cbe92ed84e4d280c12fbf9feb3f39fa67b9 Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Tue, 6 Sep 2022 16:49:22 -0700 Subject: [PATCH 6/9] more ci fixes --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24d0804f..6a0be44c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: {"Key": "Name", "Value": "ec2-github-runner"}, {"Key": "GitHubRepository", "Value": "${{ github.repository }}"} ] - do-the-job: + build_linux: strategy: fail-fast: false matrix: @@ -158,7 +158,7 @@ jobs: name: Stop self-hosted EC2 runner (Linux) needs: - start-runner # required to get output from the start-runner job - - do-the-job # required to wait when the main job is done + - build_linux # required to wait when the main job is done runs-on: ubuntu-latest if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs steps: From b44d48ce8c6815d3157d1c8936a3de740d727147 Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Tue, 6 Sep 2022 17:21:12 -0700 Subject: [PATCH 7/9] Run Ninja on MacOS --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a0be44c..d5f44634 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -197,6 +197,8 @@ jobs: with: fetch-depth: 0 submodules: true + - name: Install Ninja Build + run: brew install ninja - name: Build with build script shell: bash run: | From a8e0703f37744c1e86ae22e13a0a047fd6d9c0a8 Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Thu, 8 Sep 2022 13:41:29 -0400 Subject: [PATCH 8/9] Update .github/workflows/anghabench-after-build.yml Co-authored-by: Eric Kilmer --- .github/workflows/anghabench-after-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/anghabench-after-build.yml b/.github/workflows/anghabench-after-build.yml index 5e89a1d7..7335eb3d 100644 --- a/.github/workflows/anghabench-after-build.yml +++ b/.github/workflows/anghabench-after-build.yml @@ -62,7 +62,7 @@ jobs: run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" id: extract_branch - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 - name: Fix github token auth From 9bb0a9cc9fba8e02df88bd093817848bac24caa2 Mon Sep 17 00:00:00 2001 From: Artem Dinaburg Date: Thu, 8 Sep 2022 13:41:37 -0400 Subject: [PATCH 9/9] Update .github/workflows/anghabench-cron-jobs.yml Co-authored-by: Eric Kilmer --- .github/workflows/anghabench-cron-jobs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/anghabench-cron-jobs.yml b/.github/workflows/anghabench-cron-jobs.yml index e7d83fa8..84da8f38 100644 --- a/.github/workflows/anghabench-cron-jobs.yml +++ b/.github/workflows/anghabench-cron-jobs.yml @@ -60,7 +60,7 @@ jobs: run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" id: extract_branch - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 - name: Fix github token auth