diff --git a/.github/automation/build_linters.sh b/.github/automation/build_linters.sh new file mode 100755 index 00000000000..6ae4717167e --- /dev/null +++ b/.github/automation/build_linters.sh @@ -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 diff --git a/.github/workflows/pr-linter.yml b/.github/workflows/pr-linter.yml index e9a32e25510..e1f2b2beb06 100644 --- a/.github/workflows/pr-linter.yml +++ b/.github/workflows/pr-linter.yml @@ -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