Skip to content

implement llvm-cov

implement llvm-cov #17

name: Build and collect test coverage
on:
push:
branches:
- main
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_dispatch:
defaults:
run:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive
jobs:
build-repo:
name: Build and Code Coverage
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Get the project repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python and other packages
run: |
pip install cmake numpy psutil pybind11 rich
- name: Install Ninja
run: sudo apt-get install -y ninja-build
- name: Install llvm-cov
run: sudo apt-get install -y clang lld llvm
- name: Get LLVM
id: clone-llvm
run: utils/clone-llvm.sh
- name: Get LLVM commit hash
id: get-llvm-commit-hash
run: echo "hash=$(cd llvm ; git log -1 --format='%H')" >> $GITHUB_OUTPUT
- name: Ccache for C++ compilation
# https://github.com/hendrikmuhs/ccache-action/releases/tag/v1.2.9
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e
with:
key: ${{ runner.os }}-${{ matrix.ubuntu_version }}-${{ steps.get-llvm-commit-hash.outputs.hash }}
max-size: 1G
- name: Build and install LLVM
run: LLVM_ENABLE_RTTI=ON utils/build-llvm.sh
- name: Install our python reqs
run: pip install -r python/requirements.txt
- name: Build and generate coverage (Release)
run: |
mkdir build_release
cd build_release
cmake .. \
-GNinja \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DBUILD_INSTRUMENTED_COVERAGE=ON \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=/home/runner/work/mlir-aie/mlir-aie/llvm/install/lib/cmake/mlir \
-DLLVM_DIR=/home/runner/work/mlir-aie/mlir-aie/llvm/install/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build/bin/llvm-lit
ninja && ninja generate-aie-coverage-report
- name: Format coverage report
id: format-report
run: |
sed -i.bak "s/class='column-entry-bold'/style='font-weight: bold; text-align: left;'/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak "s/class='column-entry-yellow'/style='text-align: left; background-color: #ffffd0;'/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak "s/class='column-entry-red'/style='text-align: left; background-color: #ffd0d0;'/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak "s/class='column-entry-green'/style='text-align: left; background-color: #d0ffd0;'/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak "s/<!doctype html>/<!--<!doctype html>-->/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
- name: Update PR with coverage results
uses: edumserrano/find-create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!--<!doctype html>-->'
comment-author: 'github-actions[bot]'
body-path: /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
edit-mode: replace