Skip to content

turn compiler warnings back on (and make some of them them Werror) #3237

turn compiler warnings back on (and make some of them them Werror)

turn compiler warnings back on (and make some of them them Werror) #3237

Workflow file for this run

name: Build and Test
on:
push:
branches:
- main
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_dispatch:
defaults:
run:
# This is already the default, except when running inside another Docker
# image, which is the case here. So set it up globally to avoid
# repeating elsewhere.
shell: bash
env:
# Run apt package manager in the CI in non-interactive mode.
# Otherwise, on Ubuntu 20.04 the installation of tzdata asking question
DEBIAN_FRONTEND: noninteractive
jobs:
build-repo:
name: Build and Test
# By latest GitHub means actually latest LTS only
runs-on: ubuntu-latest
strategy:
# Run all the test even if there are some which fail
fail-fast: false
# Run the tests on the Cartesian product of the following
matrix:
build_type: [ Assert, Release ]
ubuntu_version: [ 20.04, 22.04 ]
steps:
# Clone the repo and its submodules. Do shallow clone to save clone
# time.
- name: Get the project repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Python packages
run: |
pip install cmake numpy psutil pybind11 rich pkginfo lit PyYAML
- name: Install Ninja
run: sudo apt-get install -y ninja-build
- name: Install lld and clang (for aiecc)
run: sudo apt-get install -y clang lld
- name: Get MLIR
id: mlir-wheels
run: |
pip -q download mlir -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro && unzip -q mlir-*.whl
WHL=$(ls mlir-*.whl)
echo "MLIR_WHEEL_VERSION=$(python -c "import pkginfo; w = pkginfo.Wheel('$WHL'); print(w.version.split('+')[0] + '+' + w.version.split('+')[1].rsplit('.', 1)[-1])")" | tee -a $GITHUB_OUTPUT
echo "MLIR_DIR=$PWD/mlir" | tee -a $GITHUB_OUTPUT
- name: Ccache for C++ compilation
# https://github.com/hendrikmuhs/ccache-action/releases/tag/v1.2.9
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e
with:
# Since there are now several compilation jobs running in parallel,
# use a different key per job to avoid a ccache writing race condition
key: ${{ matrix.build_type }}-${{ runner.os }}-${{ matrix.ubuntu_version }}-${{ steps.mlir-wheels.outputs.MLIR_WHEEL_VERSION }}
max-size: 1G
# Build the repo test target in debug mode to build and test.
- name: Build and test (Assert)
if: matrix.build_type == 'Assert'
run: |
mkdir build_assert
cd build_assert
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-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_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 \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/mlir \
-DLLVM_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ninja
ninja check-aie
ninja check-tutorials
ninja check-reference-designs
# Build the repo test target in release mode to build and test.
- name: Build and test (Release)
if: matrix.build_type == 'Release'
run: |
mkdir build_release
cd build_release
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-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_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 \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/mlir \
-DLLVM_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit)
ninja
ninja check-aie
ninja check-tutorials
ninja check-reference-designs
lint-repo:
name: Check code format
runs-on: ubuntu-20.04
steps:
# We'll be running clang-tidy later in this flow.
- name: Install clang-tidy
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy-12
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy \
/usr/bin/clang-tidy-12 100
# Clone the repo and its submodules. Do shallow clone to save clone
# time.
- name: Get repo
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
# --------
# Lint the code.
# -------
# Choose the git commit to diff against for the purposes of linting.
# Since this workflow is triggered on both pushes and pull requests, we
# have to determine if the pull request target branch is set (which it
# will only be on the PR triggered flow). If it's not, then compare
# against the last commit.
- name: choose-commit
if: always()
env:
# Base ref is the target branch, in text form (not hash)
PR_BASE: ${{ github.base_ref }}
run: |
# Run clang-format
if [[ -z "$PR_BASE" ]]; then
DIFF_COMMIT_NAME="HEAD^"
else
DIFF_COMMIT_NAME="$PR_BASE"
fi
echo "DIFF_COMMIT_NAME=$DIFF_COMMIT_NAME" >> $GITHUB_ENV
# Since we did a shallow fetch for this repo, we must fetch the commit
# upon which we be diff'ing. The last step set the ref name in the
# $DIFF_COMMIT_NAME environment variable. When running the fetch, resolve
# it to the commit hash and pass that hash along to subsequent steps.
- name: git fetch base commit
continue-on-error: true
run: |
if [[ ! "$DIFF_COMMIT_NAME" == *"HEAD"* ]]; then
git fetch --recurse-submodules=no origin $DIFF_COMMIT_NAME
DIFF_COMMIT_SHA=$( git rev-parse origin/$DIFF_COMMIT_NAME )
else
DIFF_COMMIT_SHA=$( git rev-parse $DIFF_COMMIT_NAME )
fi
echo "DIFF_COMMIT=$DIFF_COMMIT_SHA" >> $GITHUB_ENV
# Run 'git clang-format', comparing against the target commit hash. If
# clang-format fixed anything, fail and output a patch.
- name: clang-format
if: always()
run: |
# Run clang-format
git clang-format-12 $DIFF_COMMIT
git diff --ignore-submodules > clang-format.patch
if [ -s clang-format.patch ]; then
echo "Clang-format found formatting problems in the following " \
"files. See diff in the clang-format.patch artifact."
git diff --ignore-submodules --name-only
git checkout .
exit 1
fi
echo "Clang-format found no formatting problems"
exit 0
# Run clang-tidy against only the changes. The 'clang-tidy-diff' script
# does this if supplied with the diff.
- name: clang-tidy
if: always()
run: |
git diff -U0 $DIFF_COMMIT | \
clang-tidy-diff-12.py -path build_assert -p1 -fix
git diff --ignore-submodules > clang-tidy.patch
if [ -s clang-tidy.patch ]; then
echo "Clang-tidy problems in the following files. " \
"See diff in the clang-tidy.patch artifact."
git diff --ignore-submodules --name-only
git checkout .
exit 1
fi
echo "Clang-tidy found no problems"
exit 0
# Upload the format and tidy patches to an artifact (zip'd) associated
# with the workflow run. Only run this on a failure.
- name: Upload format and tidy patches
uses: actions/upload-artifact@v3
continue-on-error: true
if: failure()
with:
name: clang-format-tidy-patches
path: clang-*.patch
# Unfortunately, artifact uploads are always zips so display the diff as
# well to provide feedback at a glance.
- name: clang format and tidy patches display
if: failure()
continue-on-error: true
run: |
# Display patches
if [ ! -z clang-format.patch ]; then
echo "Clang-format patch"
echo "================"
cat clang-format.patch
echo "================"
fi
if [ ! -z clang-tidy.patch ]; then
echo "Clang-tidy patch"
echo "================"
cat clang-tidy.patch
echo "================"
fi
code-coverage:
name: 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 lit
- 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 changed files
id: changed-files
run: |
git fetch origin main
# Because for the life of me I cannot figure out how to read the output of git diff into a bash array.
CHANGED_FILES=$(python utils/get_git_changed_files.py)
echo "changed-files=${CHANGED_FILES}" | tee $GITHUB_OUTPUT
- name: Get MLIR
id: mlir-wheels
run: |
pip -q download mlir -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro && unzip -q mlir-*.whl
echo "MLIR_DIR=$PWD/mlir" | tee -a $GITHUB_OUTPUT
- name: Ccache for C++ compilation
if: steps.changed-files.outputs.changed-files != ''
# 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 }}-code-cov
max-size: 1G
- name: Install our python reqs
if: steps.changed-files.outputs.changed-files != ''
run: pip install -r python/requirements.txt
- name: Build and generate coverage (Release)
if: steps.changed-files.outputs.changed-files != ''
run: |
mkdir build_release
cd build_release
cmake .. \
-GNinja \
-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 \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/mlir \
-DLLVM_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit) \
\
-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" \
-DBUILD_INSTRUMENTED_COVERAGE=ON \
-DINSTRUMENTED_COVERAGE_FILES="${{ steps.changed-files.outputs.changed-files }}"
ninja && ninja generate-aie-coverage-report
cat /home/runner/work/mlir-aie/mlir-aie/build_release/report/summary.txt
- name: Format coverage report
if: steps.changed-files.outputs.changed-files != ''
id: format-report
run: |
sed -i.bak 's/<!doctype html>/<!--<!doctype codecov html>-->/g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/<pre>//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/<\/pre>//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/([0-9]*\/[0-9]*)//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak "s/href=/href=''/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
WORKSPACE=$(echo "/home/runner/work/mlir-aie/mlir-aie/" | sed 's/\//\\\//g')
sed -i.bak "s/$WORKSPACE//g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
- name: Update PR with coverage results
if: steps.changed-files.outputs.changed-files != '' && github.event.pull_request.head.repo.full_name == github.repository
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-path: /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
edit-mode: replace