-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test coverage and Codecov upload #1347
Open
nsumrakTT
wants to merge
8
commits into
main
Choose a base branch
from
nsumrak/test_coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9b44b31
[CI] add debug build
nsumrakTT 8875120
Add code_coverage target to libs
nsumrakTT b596ea8
Fix ccache and jobid
nsumrakTT 7d8fad4
Remove upload of non existant xml files and set gcov tool to llvm-cov-17
nsumrakTT 9de3fbf
Workaround for llvm-cov-17
nsumrakTT 885bbd8
SPDX header added
nsumrakTT 1a5af95
Correct path to the script
nsumrakTT 3a2309e
Corrected paths for lcov
nsumrakTT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,16 +106,110 @@ jobs: | |
cd ../../.. | ||
cp third_party/tvm/python/dist/*.whl dist/ | ||
|
||
- name: Run Unit Tests | ||
shell: bash | ||
run: | | ||
source env/activate | ||
pip install dist/forge*.whl --force-reinstall | ||
cmake --build ${{ steps.strings.outputs.build-output-dir }} -- run_unit_tests | ||
|
||
- name: Upload Build | ||
uses: actions/upload-artifact@v4 | ||
if: success() || failure() | ||
with: | ||
name: forge-wheel | ||
path: dist/*.whl | ||
|
||
|
||
test-build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: | ||
- runs-on: [runner] | ||
|
||
runs-on: | ||
- in-service | ||
- ${{ matrix.build.runs-on }} | ||
|
||
container: | ||
image: ${{ inputs.docker-image }} | ||
|
||
steps: | ||
|
||
- name: Fetch job id | ||
id: fetch-job-id | ||
uses: tenstorrent/tt-github-actions/.github/actions/job_id@main | ||
with: | ||
job_name: "${{ github.job }}" | ||
|
||
- name: Set reusable strings | ||
id: strings | ||
shell: bash | ||
env: | ||
JOB_ID: ${{ steps.fetch-job-id.outputs.job_id }} | ||
run: | | ||
echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" | ||
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT" | ||
echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT" | ||
echo "test_report_path=report_$JOB_ID.xml" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Git safe dir | ||
run: | | ||
git config --system --add safe.directory ${{ steps.strings.outputs.work-dir }} | ||
chown -R root:root ${{ steps.strings.outputs.work-dir }} | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
clean: true | ||
fetch-depth: 0 # Fetch all history and tags | ||
|
||
# Clean everything from submodules (needed to avoid issues | ||
# with cmake generated files leftover from previous builds) | ||
- name: Cleanup submodules | ||
run: | | ||
git submodule foreach --recursive git clean -ffdx | ||
git submodule foreach --recursive git reset --hard | ||
|
||
- name: ccache | ||
uses: hendrikmuhs/[email protected] | ||
with: | ||
create-symlink: true | ||
key: ${{ matrix.build.runs-on }}-runtime-${{ matrix.build.enable_runtime }} | ||
|
||
- name: Debug Build | ||
shell: bash | ||
run: | | ||
source env/activate | ||
cmake -G Ninja \ | ||
-B ${{ steps.strings.outputs.build-output-dir }} \ | ||
-DCMAKE_BUILD_TYPE=Debug \ | ||
-DCMAKE_C_COMPILER=clang \ | ||
-DCMAKE_CXX_COMPILER=clang++ \ | ||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
-DCODE_COVERAGE=ON | ||
cmake --build ${{ steps.strings.outputs.build-output-dir }} | ||
|
||
- name: Run Unit Tests | ||
shell: bash | ||
run: | | ||
source env/activate | ||
cmake --build ${{ steps.strings.outputs.build-output-dir }} -- run_unit_tests | ||
|
||
- name: Prepare code coverage report | ||
run: | | ||
lcov --directory build --capture --output-file coverage.info --gcov-tool ${{ steps.strings.outputs.work-dir }}/.github/workflows/gcov_for_clang.sh | ||
lcov --extract coverage.info '**/tt-forge-fe/forge/csrc/*' --output-file coverage.info | ||
sed -i 's|SF:/__w/tt-forge-fe/tt-forge-fe/forge/csrc/|SF:csrc/|' coverage.info | ||
lcov --list coverage.info | ||
|
||
- name: Upload coverage reports to Codecov | ||
if: 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 }} |
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,6 @@ | ||
#!/bin/bash | ||
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
exec llvm-cov-17 gcov "$@" |
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 |
---|---|---|
|
@@ -66,3 +66,6 @@ generated | |
infra/.coverage | ||
infra/pytest.xml | ||
pipeline_*.json | ||
|
||
coverage.info | ||
coverage.xml |
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
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
add_library(runtime STATIC runtime.cpp tt_device.cpp python_bindings.cpp) | ||
add_dependencies(runtime tt-mlir) | ||
|
||
target_link_libraries(runtime PUBLIC coverage_config) | ||
|
||
target_compile_options(runtime PRIVATE ${STATIC_LIB_FLAGS} ${TTFORGE_CSRC_CFLAGS}) |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken, we are not using ccache here, so builds are going to take a long time...
Let's sync offline.