diff --git a/.github/on-pr.yml b/.github/on-pr.yml index 76a781f8..2c280ec1 100644 --- a/.github/on-pr.yml +++ b/.github/on-pr.yml @@ -12,6 +12,10 @@ jobs: spdx: uses: ./.github/workflows/spdx.yml secrets: inherit - build-and-test: - uses: ./.github/workflows/build-and-test.yml + build: + uses: ./.github/workflows/run-build.yml + secrets: inherit + test: + needs: build + uses: ./.github/workflows/run-tests.yml secrets: inherit diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 76a781f8..2c280ec1 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -12,6 +12,10 @@ jobs: spdx: uses: ./.github/workflows/spdx.yml secrets: inherit - build-and-test: - uses: ./.github/workflows/build-and-test.yml + build: + uses: ./.github/workflows/run-build.yml + secrets: inherit + test: + needs: build + uses: ./.github/workflows/run-tests.yml secrets: inherit diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 2d961e22..82a2b472 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -12,6 +12,10 @@ jobs: spdx: uses: ./.github/workflows/spdx.yml secrets: inherit - build-and-test: - uses: ./.github/workflows/build-and-test.yml + build: + uses: ./.github/workflows/run-build.yml + secrets: inherit + test: + needs: build + uses: ./.github/workflows/run-tests.yml secrets: inherit diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/run-build.yml similarity index 84% rename from .github/workflows/build-and-test.yml rename to .github/workflows/run-build.yml index 629a5048..80711be8 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/run-build.yml @@ -121,6 +121,9 @@ jobs: echo "build-output-dir=$(pwd)/build" >> "$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 }} + - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: @@ -134,6 +137,7 @@ jobs: source env/activate cmake -G Ninja \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.install-output-dir }} \ -B ${{ steps.strings.outputs.build-output-dir }} \ -S ${{ steps.strings.outputs.work-dir }} @@ -144,9 +148,18 @@ jobs: cmake --build ${{ steps.strings.outputs.build-output-dir }} cmake --install ${{ steps.strings.outputs.build-output-dir }} - - name: Run tests + - name: Copy tt-metal binaries shell: bash - run: | - export LD_LIBRARY_PATH="/opt/ttmlir-toolchain/lib/:${{ steps.strings.outputs.install-output-dir }}/lib:${LD_LIBRARY_PATH}" - source env/activate - pytest -v tests --ignore=tests/models + working-directory: ${{ steps.strings.outputs.install-output-dir }} + run: cp ${{ steps.strings.outputs.work-dir }}/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/*.so lib/ + + - name: 'Tar install 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.install-output-dir }}/artifact.tar diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..c6e5c3ba --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,70 @@ +name: Test + +on: + workflow_dispatch: + workflow_call: + workflow_run: + workflows: [Build] + types: [completed] + +jobs: + tests: + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + build: [ + {runs-on: n150, name: "run"}, + ] + + runs-on: + - in-service + - ${{ matrix.build.runs-on }} + + container: + image: ghcr.io/tenstorrent/tt-torch/tt-torch-ci-ubuntu-22-04:latest + options: --user root --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: Set reusable strings + id: strings + shell: bash + run: | + echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" + echo "build-output-dir=$(pwd)/build" >> "$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 }} + + - name: Use build artifacts + uses: actions/download-artifact@v4 + with: + name: install-artifacts + path: ${{ steps.strings.outputs.install-output-dir }} + + - name: 'Untar install directory' + shell: bash + working-directory: ${{ steps.strings.outputs.install-output-dir }} + run: tar xvf artifact.tar + + - name: Run tests + shell: bash + run: | + echo $pwd + echo ${{ steps.strings.outputs.install-output-dir }} + echo ${{ steps.strings.outputs.build-output-dir }}/ + source env/activate + export LD_LIBRARY_PATH="/opt/ttmlir-toolchain/lib/:${{ steps.strings.outputs.install-output-dir }}/lib:${{ steps.strings.outputs.build-output-dir }}/lib:./lib/:${LD_LIBRARY_PATH}" + pytest -sv tests --ignore=tests/models