Skip to content

Commit

Permalink
Add clang-tidy check
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaNikolaenko committed Jul 19, 2022
1 parent ab40b0c commit 249ef4d
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/clang_tidy_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Clang Tidy Check

# We use action's triggers 'push' and 'pull_request'.
# The strategy is the following: this action will be
# triggered on any push to 'main' branch and any pull
# request to any branch. Thus we avoid duplicate work-
# flows.
on:
push:
branches:
- "main"
pull_request:
branches:
- "**"
workflow_dispatch:
inputs:
# Live debug failures using tmate by toggling input parameter
# 'debug_enabled':
# https://github.com/mxschmitt/action-tmate#manually-triggered-debug
# When manually running this workflow:
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
debug_enabled:
description: 'Enable tmate debugging'
type: boolean
default: true

jobs:
clang-tidy-check:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
#- os: macos-latest
# sudo-command: "sudo"
# # Explicitly not using `dazel` here as we don't want to
# # build/test on Linux but on macOS!
# bazel-command: "bazelisk"
# bazel-config: ""
# output-user_root: ""
- os: ubuntu-latest
sudo-command: "sudo"
bazel-command: "dazel"
bazel-config: "--config=asan"
output-user_root: ""
eventuals-regex: |
"eventuals[\\\/]eventuals[\\\/]eventuals[\\\/][^.]+.(cc|h)" \
"eventuals[\\\/]eventuals[\\\/]test[\\\/][^.]+.(cc|h)"
- os: windows-2019
sudo-command: "" # The Windows runner already runs as root.
# Explicitly not using `dazel` here as we don't want to
# build/test on Linux but on Windows!
bazel-command: "bazelisk"
bazel-config: ""
# Fixes issue #248.
output-user_root: "--output_user_root=C:/bzl"
eventuals-regex: |
"eventuals[\\\/]eventuals[\\\/][^.]+.(cc|h)" \
"eventuals[\\\/]test[\\\/][^.]+.(cc|h)"
defaults:
run:
shell: bash

steps:
# We should checkout the repo with submodules
# cause we need to have symlink to
# dev-tools/.clang-format file for all code
# style checks.
- uses: actions/checkout@v2
with:
submodules: 'recursive'

# Install 'wheel' for Python on Windows as required for running
# commands like 'python setup.py bdist_wheel'.
- name: Install Python 'wheel'
if: ${{ matrix.os == 'windows-2019' }}
run: ${{ matrix.sudo-command }} pip3 install wheel

# Install Dazel for use on Linux so that we use the same build
# tooling in our Actions as we do on our workstations.
- name: Install Dazel
if: ${{ matrix.bazel-command == 'dazel' }}
run: ${{ matrix.sudo-command }} pip3 install dazel

# Invoke 'dazel version' in order to build the Docker container
# as a separate step so we can track how long it takes and
# optimize as necessary.
- name: Dazel Docker Build
if: ${{ matrix.bazel-command == 'dazel' }}
run: dazel version

# We have to build everything first to correctly extract
# compile commands later.
- name: Build
run: |
${{ matrix.bazel-command }} \
${{ matrix.output-user_root }} \
build \
${{ matrix.bazel-config }} \
${{ env.BAZEL_REMOTE_CACHE }} \
--verbose_failures \
-c dbg \
--strip="never" \
...
- name: Extract Compile Commands
run: |
${{ matrix.bazel-command }} \
${{ matrix.output-user_root }} \
run \
refresh_cc_github_actions \
-- \
${{ matrix.bazel-config }} \
${{ env.BAZEL_REMOTE_CACHE }} \
--verbose_failures \
--compilation_mode=dbg \
--strip="never" \
- name: Run clang-tidy
run: |
run-clang-tidy \
${{ matrix.eventuals-regex }}
7 changes: 7 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ refresh_compile_commands(
},
)

refresh_compile_commands(
name = "refresh_cc_github_actions",
targets = {
"//test:eventuals": "",
},
)

########################################################################

0 comments on commit 249ef4d

Please sign in to comment.