-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f08aea
commit 87ec799
Showing
4 changed files
with
355 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
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 | ||
pull-requests: 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 codecov html>-->/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html | ||
echo "report=$(cat /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html)" >> $GITHUB_OUTPUT | ||
- 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 codecov html>-->' | ||
comment-author: 'github-actions[bot]' | ||
body: | | ||
# Test/code coverage report | ||
${{ steps.format-report.outputs.report }} | ||
edit-mode: replace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.