Skip to content

Commit

Permalink
ci: linters: enabled clang-tidy, format-tags checks
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaciak authored Feb 6, 2025
1 parent 6d6ce3f commit 447ea75
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/automation/build_linters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build oneDNN for PR linter checks.

set -o errexit -o pipefail -o noclobber

export CC=clang
export CXX=clang++

if [[ "$ONEDNN_ACTION" == "configure" ]]; then
if [[ "$GITHUB_JOB" == "pr-clang-tidy" ]]; then
set -x
cmake \
-Bbuild -S. \
-DCMAKE_BUILD_TYPE=debug \
-DONEDNN_BUILD_GRAPH=ON \
-DDNNL_EXPERIMENTAL=ON \
-DDNNL_EXPERIMENTAL_SPARSE=ON \
-DDNNL_EXPERIMENTAL_PROFILING=ON \
-DDNNL_EXPERIMENTAL_UKERNEL=ON \
-DONEDNN_EXPERIMENTAL_LOGGING=ON \
-DDNNL_USE_CLANG_TIDY=CHECK \
-DDNNL_CPU_RUNTIME=OMP \
-DDNNL_GPU_RUNTIME=OCL \
-DDNNL_WERROR=ON \
-DDNNL_BUILD_FOR_CI=ON
set +x
elif [[ "$GITHUB_JOB" == "pr-format-tags" ]]; then
set -x
cmake -B../build -S. -DONEDNN_BUILD_GRAPH=OFF -DDNNL_EXPERIMENTAL_SPARSE=ON
set +x
else
echo "Unknown linter job: $GITHUB_JOB"
exit 1
fi
elif [[ "$ONEDNN_ACTION" == "build" ]]; then
set -x
cmake --build build
set +x
else
echo "Unknown action: $ONEDNN_ACTION"
exit 1
fi
56 changes: 56 additions & 0 deletions .github/workflows/pr-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,59 @@ jobs:
run: sudo apt update && sudo apt install -y "clang-format-11"
- name: Check code formatting
run: .github/automation/clang-format.sh

pr-format-tags:
name: Format tags consistency
runs-on: ubuntu-latest
steps:
- name: Checkout oneDNN
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: source

- name: Install clang
run: |
sudo apt-get update
sudo apt-get install -y clang libomp-dev
- name: Install castxml package
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --no-cache-dir --disable-pip-version-check castxml
- name: Configure oneDNN
run: .github/automation/build_linters.sh
working-directory: ${{ github.workspace }}/source
env:
ONEDNN_ACTION: configure

- name: Check format-tags
run: |
venv/bin/castxml --castxml-cc-gnu-c clang --castxml-output=1 -I${{ github.workspace }}/source/include -I${{ github.workspace }}/build/include ${{ github.workspace }}/source/include/oneapi/dnnl/dnnl_types.h -o ${{ github.workspace }}/types.xml
python ${{ github.workspace }}/source/scripts/generate_dnnl_debug.py ${{ github.workspace }}/types.xml
python ${{ github.workspace }}/source/scripts/generate_format_tags.py
cd ${{ github.workspace }}/source/
git diff | grep . && exit 1
pr-clang-tidy:
name: Clang-Tidy
runs-on: ubuntu-latest
steps:
- name: Checkout oneDNN
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install clang
run: |
sudo apt-get update
sudo apt-get install -y clang libomp-dev ocl-icd-libopencl1 ocl-icd-opencl-dev
- name: Configure oneDNN
run: .github/automation/build_linters.sh
env:
ONEDNN_ACTION: configure

- name: Build oneDNN
run: .github/automation/build_linters.sh
env:
ONEDNN_ACTION: build

0 comments on commit 447ea75

Please sign in to comment.