Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[misc] Enable clang-tidy check in CI #3475

Merged
merged 4 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,37 @@ jobs:
exit 1
fi

check_clang_tidy:
# TODO: Move installation of clang-tidy to docker image
name: Check clang-tidy
runs-on: ubuntu-latest
needs: check_files
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Get docker images
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
echo $CR_PAT | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker pull ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0
env:
CR_PAT: ${{ secrets.GITHUB_TOKEN }}
- name: Run clang-tidy
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
docker run -id --user dev --name check_clang_tidy ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0 /bin/bash
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx --owner dev --group dev | docker cp - check_clang_tidy:/home/dev/
docker exec --user root check_clang_tidy apt install -y clang-tidy-10
ailzhang marked this conversation as resolved.
Show resolved Hide resolved
docker exec --user dev check_clang_tidy /home/dev/taichi/.github/workflows/scripts/check_clang_tidy.sh "$CI_SETUP_CMAKE_ARGS"
env:
CI_SETUP_CMAKE_ARGS: -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=ON -DTI_WITH_VULKAN:BOOL=OFF -DTI_BUILD_TESTS:BOOL=OFF

build_and_test_cpu_required:
# This job will be required to pass before merging to master branch.
name: Required Build and Test (CPU)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/check_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CI_SETUP_CMAKE_ARGS=$1
cd taichi
python3 -m pip install -r requirements_dev.txt

mkdir build && cd build
rm -rf build && mkdir build && cd build
cmake $CI_SETUP_CMAKE_ARGS ..

cd ..
Expand Down
14 changes: 8 additions & 6 deletions scripts/run_clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
output, err = proc.communicate()
if proc.returncode != 0:
failed_files.append(name)
with lock:
sys.stdout.write(' '.join(invocation) + '\n' +
output.decode('utf-8'))
if len(err) > 0:
sys.stdout.flush()
sys.stderr.write(err.decode('utf-8'))
with lock:
sys.stdout.write(' '.join(invocation) + '\n' +
output.decode('utf-8'))
if len(err) > 0:
sys.stdout.flush()
sys.stderr.write(err.decode('utf-8'))
queue.task_done()


Expand Down Expand Up @@ -325,6 +325,8 @@ def main():
task_queue.join()
if len(failed_files):
return_code = 1
else:
print("No errors detected, congratulations!")

except KeyboardInterrupt:
# This is a sad hack. Unfortunately subprocess goes
Expand Down