-
Notifications
You must be signed in to change notification settings - Fork 3
288 lines (249 loc) · 9.14 KB
/
build-and-test.yml
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: Build and Test
on:
workflow_dispatch:
inputs:
mlir_override:
description: 'Git SHA of commit in tenstorrent/tt-mlir'
required: false
type: string
test_mark:
description: 'Test mark to run'
required: true
default: 'push'
type: choice
options:
- push
- nightly
workflow_call:
inputs:
mlir_override:
description: 'Git SHA of commit in tenstorrent/tt-mlir'
required: false
type: string
test_mark:
description: 'Test mark to run'
required: false
default: 'push'
type: string
permissions:
packages: write
checks: write
pull-requests: write
jobs:
# build-ttxla:
# timeout-minutes: 120
# strategy:
# fail-fast: false
# name: Build and test tt-xla
# runs-on: ubuntu-latest
# container:
# image: ghcr.io/tenstorrent/tt-mlir/tt-mlir-ci-ubuntu-22-04:latest #TODO update this to the correct image
# options: --user root
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# lfs: true
# - name: Set reusable strings
# id: strings
# shell: bash
# run: |
# echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
# echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
# echo "metal-lib-dir=$(pwd)/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib" >> "$GITHUB_OUTPUT"
# echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"
# - name: Git safe dir
# run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }}
# # Build project
# - name: Configure CMake
# shell: bash
# run: |
# source venv/activate
# cmake -G Ninja \
# -B ${{ steps.strings.outputs.build-output-dir }} \
# -S ${{ steps.strings.outputs.work-dir }}
# - name: Build
# shell: bash
# run: |
# source venv/activate
# cmake --build ${{ steps.strings.outputs.build-output-dir }}
# cmake --install ${{ steps.strings.outputs.build-output-dir }}
# # This is needed to preserve file permissions
# # https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
# - name: 'Tar install directory and metal lib directory'
# shell: bash
# working-directory: ${{ steps.strings.outputs.install-output-dir }}
# run: |
# tar cvf artifact.tar .
# - name: Upload install folder to archive
# uses: actions/upload-artifact@v4
# with:
# name: install-artifacts
# path: ${{ steps.strings.outputs.build-output-dir }}/artifact.tar
# - name: Get the latest tag
# shell: bash
# run: |
# latest_tag=$(git describe --tags --abbrev=0)
# latest_tag=${latest_tag#v}
# echo "latest_tag=$latest_tag" >> $GITHUB_ENV
# commit_count=$(git rev-list ${{ env.latest_tag }}..HEAD --count)
# echo "commit_count=$commit_count" >> $GITHUB_ENV
# version="${{ env.latest_tag }}.${{ env.commit_count }}"
# echo "version=$version" >> $GITHUB_ENV
# echo $version
build-image:
runs-on: n300
outputs:
docker-image: ${{ steps.build.outputs.docker-image }}
steps:
- name: Fix permissions
shell: bash
run: sudo chown ubuntu:ubuntu -R $(pwd)
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker images and output the image name
id: build
shell: bash
run: |
# Output the image name
set pipefail
.github/build-docker-images.sh | tee docker.log
DOCKER_CI_IMAGE=$(tail -n 1 docker.log)
echo "DOCKER_CI_IMAGE $DOCKER_CI_IMAGE"
echo "docker-image=$DOCKER_CI_IMAGE" >> "$GITHUB_OUTPUT"
# # Run tests on TT hardware
build-and-run-tests:
timeout-minutes: 120
needs: build-image
strategy:
fail-fast: false
matrix:
build: [
{runs-on: n150, name: "run"},
{runs-on: n300, name: "run"},
]
runs-on:
- in-service
- ${{ matrix.build.runs-on }}
container:
image: ${{ needs.build-image.outputs.docker-image }}
options: --device /dev/tenstorrent/0
volumes:
- /dev/hugepages:/dev/hugepages
- /dev/hugepages-1G:/dev/hugepages-1G
- /etc/udev/rules.d:/etc/udev/rules.d
- /lib/modules:/lib/modules
- /opt/tt_metal_infra/provisioning/provisioning_env:/opt/tt_metal_infra/provisioning/provisioning_env
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: true
- name: Override tt-mlir SHA mlir_override is set
if: ${{ inputs.mlir_override }}
shell: bash
run: |
# Update the CMakeLists.txt file with the new SHA
sed -i "s/set(TT_MLIR_VERSION \".*\")/set(TT_MLIR_VERSION \"${{ inputs.mlir_override }}\")/" third_party/CMakeLists.txt
- name: Set reusable strings
id: strings
shell: bash
env:
job-name: "${{ github.job }} (${{ matrix.build.runs-on }}, ${{ matrix.build.name }})"
run: |
echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"
# Github job context unfortunately doesn't contain job_id, this is the workaround how to fetch it using GH API
echo "Expected job name: ${{ env.job-name }}"
JOB_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs" | \
jq -r '.jobs[] | select(.name | contains("${{ env.job-name }}")) | .id ')
echo "Current job id: $JOB_ID"
echo "job-id=$JOB_ID" >> "$GITHUB_OUTPUT"
echo "test_report_path=report_$JOB_ID.xml" >> "$GITHUB_OUTPUT"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
create-symlink: true
key: ${{ matrix.build.runs-on }}
# Build project
- name: Configure CMake
shell: bash
run: |
source venv/activate
cmake -G Ninja \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCODE_COVERAGE=ON \
-B ${{ steps.strings.outputs.build-output-dir }} \
-S ${{ steps.strings.outputs.work-dir }}
- name: Build
shell: bash
run: |
source venv/activate
cmake --build ${{ steps.strings.outputs.build-output-dir }}
cmake --install ${{ steps.strings.outputs.build-output-dir }}
- name: Verify tt-mlir SHA override
if: ${{ inputs.mlir_override }}
continue-on-error: true
shell: bash
run: |
cd third_party/tt-mlir
branch_name=$(git rev-parse --abbrev-ref HEAD)
commit_sha=$(git rev-parse HEAD)
commit_title=$(git log -1 --pretty=%s)
echo "Branch name: $branch_name"
echo "Commit SHA: $commit_sha"
echo "Commit title: $commit_title"
echo "::notice::Using tt-mlir: $branch_name, commit: $commit_sha, title: $commit_title"
cd ../..
- name: Run tests
shell: bash
run: |
export LD_LIBRARY_PATH="/opt/ttmlir-toolchain/lib/:${{ steps.strings.outputs.install-output-dir }}/lib:${LD_LIBRARY_PATH}"
source venv/activate
pytest -v tests/ \
--junitxml=${{ steps.strings.outputs.test_report_path }}
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-reports-${{ matrix.build.runs-on }}-${{ matrix.test_group_id }}
path: ${{ steps.strings.outputs.test_report_path }}
- name: Show Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure()
with:
report_paths: ${{ steps.strings.outputs.test_report_path }}
check_name: TT-XLA Tests
comment: true
updateComment: true
detailed_summary: true
group_suite: true
- name: Prepare code coverage report
if: matrix.build.runs-on == 'n300' && (success() || failure())
run: |
lcov --directory build --capture --output-file coverage.info
lcov --extract coverage.info '**/tt-xla/src/*' --output-file coverage.info
sed -i 's|SF:/__w/tt-xla/tt-xla/src/|SF:src/|' coverage.info
lcov --list coverage.info
- name: Upload coverage reports to Codecov
if: matrix.build.runs-on == 'n300' && (success() || failure())
uses: codecov/codecov-action@v5
with:
files: coverage.info
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: success() || failure()
uses: codecov/test-results-action@v1
with:
files: ${{ steps.strings.outputs.test_report_path }}
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}