From 8f5b24bf348178d7b16e42f7b5b03ad36fc1d68a Mon Sep 17 00:00:00 2001 From: Aleks Knezevic Date: Tue, 17 Sep 2024 16:49:23 +0000 Subject: [PATCH] WIP --- .github/workflows/build-and-test.yml | 144 +++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..02b86cc --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,144 @@ +name: Build and Test + +on: + workflow_dispatch: + workflow_call: + +jobs: + build-ttxla: + + timeout-minutes: 120 + strategy: + fail-fast: false + + name: Build tt-xla + runs-on: ubuntu-latest + + container: + image: ghcr.io/${{ github.repository }}/tt-mlir-ci-ubuntu-22-04:latest #TODO update this to the correct image + options: --user root + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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 }} + + + # 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 }} + + + + # This is needed to preserve file permissions + # https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss + - 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 + + - 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 + + + # Run tests on TT hardware + + run-tests: + + timeout-minutes: 30 + needs: build-ttxla + 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: ghcr.io/${{ github.repository }}/tt-mlir-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: + fetch-depth: 0 + + - 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 }} + + # This is needed to preserve file permissions + # https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss + - 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: | + source venv/activate + pytest -v tests/ \ No newline at end of file