-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### Ticket #14688 ### Problem description To leverage clang-tidy we need assurance that the entire repo conforms to the specified clang-tidy config. ### What's changed Added a scan in post-commit and fixed up the repo as needed for the scan to come up clean. Now we have a baseline to work from. ### Checklist - [x] Post commit CI passes https://github.com/tenstorrent/tt-metal/actions/runs/11853360350 - [ ] Blackhole Post commit (if applicable) - [ ] Model regression CI testing passes (if applicable) - [ ] Device performance regression CI testing passes (if applicable) - [x] New/Existing tests provide coverage for changes
- Loading branch information
1 parent
282e7e2
commit c9b9db0
Showing
10 changed files
with
372 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: "Code analysis" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
os: | ||
required: false | ||
type: string | ||
default: "ubuntu-22.04-amd64" | ||
workflow_dispatch: | ||
inputs: | ||
os: | ||
required: false | ||
type: string | ||
default: "ubuntu-22.04-amd64" | ||
|
||
jobs: | ||
build-docker-image: | ||
uses: ./.github/workflows/build-docker-artifact.yaml | ||
secrets: inherit | ||
with: | ||
os: ${{ inputs.os }} | ||
|
||
|
||
clang-tidy: | ||
needs: build-docker-image | ||
env: | ||
ARCH_NAME: wormhole_b0 | ||
runs-on: | ||
- build | ||
- in-service | ||
steps: | ||
- name: Verify ccache availability | ||
shell: bash | ||
run: | | ||
if [ ! -d "/mnt/MLPerf/ccache" ]; then | ||
echo "::error title=ccache-mlperf-not-mounted::NFS drive is not mounted; build machine not properly provisioned." | ||
exit 1 | ||
fi | ||
if [ ! -d "$HOME/.ccache-ci" ]; then | ||
echo "::error title=ccache-not-provisioned::Ccache is not properly provisioned." | ||
exit 1 | ||
fi | ||
- uses: tenstorrent-metal/metal-workflows/.github/actions/checkout-with-submodule-lfs@v2.0.0 | ||
- name: Set up dynamic env vars for build | ||
run: | | ||
echo "TT_METAL_HOME=$(pwd)" >> $GITHUB_ENV | ||
echo "RUNNER_UID=$(id -u)" >> $GITHUB_ENV | ||
echo "RUNNER_GID=$(id -g)" >> $GITHUB_ENV | ||
- name: Update submodules | ||
run: | | ||
git submodule update --init --recursive | ||
- name: Generate docker tag | ||
id: generate-docker-tag | ||
uses: ./.github/actions/generate-docker-tag | ||
with: | ||
image: ${{ inputs.os }} | ||
- name: Docker login | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: https://ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Pull docker image | ||
run: docker pull ${{ env.TT_METAL_DOCKER_IMAGE_TAG }} | ||
- name: Analyze code with clang-tidy | ||
uses: addnab/docker-run-action@v3 | ||
with: | ||
image: ${{ env.TT_METAL_DOCKER_IMAGE_TAG }} | ||
options: | | ||
--rm | ||
--tmpfs /tmp | ||
-u ${{ env.RUNNER_UID }}:${{ env.RUNNER_GID }} | ||
--group-add 1457 | ||
-v ${{ github.workspace }}:${{ github.workspace }} | ||
-v /etc/passwd:/etc/passwd:ro | ||
-v /etc/shadow:/etc/shadow:ro | ||
-v /etc/bashrc:/etc/bashrc:ro | ||
-v /home/ubuntu/.ccache-ci:/home/ubuntu/.ccache | ||
-v /mnt/MLPerf/ccache:/mnt/MLPerf/ccache | ||
-e ARCH_NAME=${{ env.ARCH_NAME }} | ||
-e CARGO_HOME=${{ github.workspace }}/.cargo | ||
-w ${{ github.workspace }} | ||
run: | | ||
set -eu # basic shell hygiene | ||
# /tmp is a tmpfs; more efficient than persisted storage | ||
mkdir -p /tmp/ccache | ||
export CCACHE_TEMPDIR=/tmp/ccache | ||
# Zero out the stats so we can see how we did this build | ||
# NOTE: may be inaccurate if we have >1 build runner on the same machine, using the same local cache | ||
ccache -z | ||
cmake --preset clang-tidy | ||
# cmake -B .build/clang-tidy -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_CLANG_TIDY=clang-tidy-17 -DTT_UNITY_BUILDS=FALSE -DCMAKE_DISABLE_PRECOMPILE_HEADERS=TRUE -DENABLE_CCACHE=TRUE -DTT_METAL_BUILD_TESTS=TRUE -DTTNN_BUILD_TESTS=TRUE -DBUILD_PROGRAMMING_EXAMPLES=TRUE -DBUILD_TT_TRAIN=TRUE | ||
nice -n 19 cmake --build --preset clang-tidy | ||
mkdir out | ||
ccache -s > out/ccache.stats | ||
- name: Publish Ccache summary | ||
run: | | ||
echo '## CCache Summary' >> $GITHUB_STEP_SUMMARY | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
cat out/ccache.stats >> $GITHUB_STEP_SUMMARY | ||
echo '```' >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ tt_debug | |
build | ||
build_* | ||
/python_env/ | ||
CMakeUserPresets.json | ||
|
||
/llk_out/ | ||
/out/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"version": 3, | ||
"configurePresets": [ | ||
{ | ||
"name": "default", | ||
"displayName": "Default Config", | ||
"description": "Default build of all the code using Ninja", | ||
"generator": "Ninja Multi-Config", | ||
"binaryDir": "${sourceDir}/.build/default", | ||
"cacheVariables": { | ||
"TT_METAL_BUILD_TESTS": {"value": "TRUE"}, | ||
"TTNN_BUILD_TESTS": {"value": "TRUE"}, | ||
"TT_UMD_BUILD_TESTS": {"value": "TRUE"}, | ||
"BUILD_PROGRAMMING_EXAMPLES": {"value": "TRUE"}, | ||
"BUILD_TT_TRAIN": {"value": "TRUE"}, | ||
"CMAKE_DISABLE_PRECOMPILE_HEADERS": {"value": "TRUE"}, | ||
"ENABLE_CCACHE": {"value": "TRUE"}, | ||
"TT_UNITY_BUILDS": {"value": "FALSE"} | ||
} | ||
}, | ||
{ | ||
"name": "clang-tidy", | ||
"inherits": "default", | ||
"description": "Run Clang Tidy", | ||
"binaryDir": "${sourceDir}/.build/clang-tidy", | ||
"cacheVariables": { | ||
"CMAKE_CXX_CLANG_TIDY": {"value": "clang-tidy-17;--warnings-as-errors=*"}, | ||
"CMAKE_VERIFY_INTERFACE_HEADER_SETS": {"value": "TRUE"}, | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": {"value": "TRUE"} | ||
} | ||
} | ||
], | ||
"buildPresets": [ | ||
{ | ||
"name": "dev", | ||
"configurePreset": "default", | ||
"configuration": "RelWithDebInfo", | ||
"targets": ["all"] | ||
}, | ||
{ | ||
"name": "clang-tidy", | ||
"configurePreset": "clang-tidy", | ||
"configuration": "RelWithDebInfo" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.