-
Notifications
You must be signed in to change notification settings - Fork 79
206 lines (197 loc) · 7.98 KB
/
all-static-checks.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: "[post-commit] all - Static checks, linters etc."
on:
workflow_dispatch:
workflow_call:
pull_request:
branches:
- "main"
jobs:
pre-commit:
name: Run Pre-commit Hooks
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so 'origin/main' is available
fetch-refs: true # Ensure all refs are fetched
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Run Pre-commit
uses: pre-commit/action@v3.0.1
with:
extra_args: |
--from-ref ${{ github.event_name == 'pull_request' && format('refs/remotes/origin/{0}', github.event.pull_request.base.ref) || 'HEAD^' }} \
--to-ref HEAD
continue-on-error: false
check-black:
runs-on: ubuntu-latest
steps:
- name: Do Nothing
run: echo "Black is covered by pre-commit. This is a placeholder to be removed after updating branch restrictions."
check-spdx-licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5.0.0
with:
cache: 'pip'
cache-dependency-path: infra/requirements-infra.txt
python-version: '3.10'
- name: Install infra deps
run: python -m pip install -r infra/requirements-infra.txt
- name: Check SPDX licenses
run: python -m check_copyright --verbose --dry-run --config ./check_copyright_config.yaml .
check-metal-kernel-count:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check kernel count in base metal is less than maximum
run: if (( $(find tt_metal/kernels/ -type f | wc -l) > 7 )); then exit 1; fi
check-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install ASPELL
run: sudo apt-get install -y aspell
- name: Run checks on docs
run: TT_METAL_HOME=$(pwd) docs/spellcheck.sh
check-forbidden-imports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check ttnn is not used in tt_metal tests
run: if (( $(grep -Rnw 'tests/tt_metal' -e 'ttnn' | wc -l ) > 11 )); then exit 1; fi
- name: Check tt_eager constructs is not used in tt_metal tests
run: |
if (( $(grep -Rnw 'tests/tt_metal' -e 'tt_lib' | wc -l ) > 0 )); then exit 1; fi
if (( $(grep -Rnw 'tests/tt_metal' -e 'tt_eager' | wc -l ) > 10 )); then exit 1; fi
check-sweeps-workflow:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5.0.0
with:
python-version: '3.10'
- name: Check sweeps workflow option count against sweep file count
run: |
pip install pyyaml
python tests/sweep_framework/framework/sweeps_workflow_verification.py
cmake-version:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Check for changed CMake files
id: changed-cmake-files
uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c
with:
files: |
**/*.cmake
**/CMakeLists.txt
- uses: lukka/get-cmake@b516803a3c5fac40e2e922349d15cdebdba01e60
if: steps.changed-cmake-files.outputs.any_changed == 'true'
with:
cmakeVersion: "~3.16.0"
- name: Check CMake version
if: steps.changed-cmake-files.outputs.any_changed == 'true'
run: cmake --version
- name: Install LLVM and Clang
if: steps.changed-cmake-files.outputs.any_changed == 'true'
run: |
wget https://apt.llvm.org/llvm.sh
chmod u+x llvm.sh
sudo ./llvm.sh 17
- name: Install deps
if: steps.changed-cmake-files.outputs.any_changed == 'true'
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt update
sudo xargs -a scripts/docker/requirements-22.04.txt apt install -y --no-install-recommends
- name: Check CMake compatibility
if: steps.changed-cmake-files.outputs.any_changed == 'true'
env:
ARCH_NAME: wormhole_b0
CMAKE_GENERATOR: Ninja
# TODO: Use a lukka/run-cmake with a preset after upgrading to a more modern CMake
run: |
echo "Checking compatibility with $(cmake --version)"
cmake -B build .
clang-tidy:
runs-on: ubuntu-latest
container: ghcr.io/tenstorrent/tt-metal/tt-metalium/ubuntu-22.04-amd64:latest
permissions:
pull-requests: write
# OPTIONAL: auto-closing conversations requires the `contents` permission
contents: write
if: github.event_name == 'pull_request' # Only run this job on pull request events
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
submodules: "recursive"
- name: Set safe directory for Git
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Fetch base branch
run: |
git remote add upstream "https://github.com/${{ github.event.pull_request.base.repo.full_name }}"
git fetch --no-tags upstream "${{ github.event.pull_request.base.ref }}"
- name: Install clang-tidy
run: |
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y clang-tidy-17 python3.11 python3.11-venv python3.11-dev
sudo ln -s $(which clang-tidy-17) /usr/local/bin/clang-tidy
- name: Prepare compile_commands.json
run: |
ARCH_NAME=grayskull cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -DTT_METAL_BUILD_TESTS=ON -DTTNN_BUILD_TESTS=ON -DTT_UMD_BUILD_TESTS=ON -DTT_UNITY_BUILDS=OFF
- name: 'Install jq'
uses: dcarbone/install-jq-action@v2
- name: Create results directory
run: |
mkdir clang-tidy-result
- name: Analyze
shell: bash
run: |
set -euo pipefail
# Find all touched files present in compile_commands.json
# This is not as simple as filtering non-code files, as some code (eg: Kernels) are C++ code that
# is not built at this level, and thus clang-tidy will be unable to process them.
PREFIX=$(pwd)
jq --arg prefix "$PREFIX/" -r '.[].file | sub("^" + $prefix; "")' build/compile_commands.json > relative_files_in_build.txt
git diff --name-only "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")..." > changed_files.txt
grep -F -f relative_files_in_build.txt changed_files.txt > common_files.txt || true
# Exit if there are no modified files known to CMake
[[ -s common_files.txt ]] || {
echo "No files to analyze"
exit 0
}
# Analyze the relevant diffs of the relevant files
git diff "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" -- $(cat common_files.txt) > filtered_changes.diff
clang-tidy-diff-17.py -p1 -path build -export-fixes clang-tidy-result/fixes.yml -j$(nproc) < filtered_changes.diff
timeout-minutes: 5
continue-on-error: true
- name: Run clang-tidy-pr-comments action
uses: platisd/clang-tidy-pr-comments@1b7395ce6f5a4186acabbba24cdd1e846f001aa8
with:
# The GitHub token (or a personal access token)
github_token: ${{ secrets.GITHUB_TOKEN }}
# The path to the clang-tidy fixes generated above
clang_tidy_fixes: clang-tidy-result/fixes.yml
# Optionally set to true if you want the Action to request
# changes in case warnings are found
request_changes: false
# Optionally set the number of comments per review
# to avoid GitHub API timeouts for heavily loaded
# pull requests
suggestions_per_comment: 10
continue-on-error: true
- name: Final step to signal success
run: echo "The job passes even if 3rd party action fails."