Skip to content

Commit

Permalink
Merge pull request #1 from tenstorrent/aknezevic/github
Browse files Browse the repository at this point in the history
Added ci docker image
  • Loading branch information
AleksKnezevic authored Sep 17, 2024
2 parents 5500475 + f4e00a1 commit 68a3730
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && apt-get install -y \
software-properties-common \
build-essential \
python3-dev \
python3-venv \
python3-pip \
git \
git-lfs \
libhwloc-dev \
pandoc \
libtbb-dev \
libcapstone-dev \
pkg-config \
linux-tools-generic \
ninja-build \
wget \
libgtest-dev \
cmake \
ccache \
doxygen \
graphviz \
patchelf \
libyaml-cpp-dev \
libboost-all-dev

# Install clang 17
RUN wget https://apt.llvm.org/llvm.sh && \
chmod u+x llvm.sh && \
./llvm.sh 17 && \
apt install -y libc++-17-dev libc++abi-17-dev && \
ln -s /usr/bin/clang-17 /usr/bin/clang && \
ln -s /usr/bin/clang++-17 /usr/bin/clang++

# Install python packages
RUN pip install cmake

# Install Googletest
RUN git clone https://github.com/google/googletest.git -b release-1.12.1 && \
cd googletest && \
mkdir build && \
cd build && \
cmake .. -DBUILD_GMOCK=OFF && \
make && \
make install && \
cd ../.. && \
rm -rf googletest
65 changes: 65 additions & 0 deletions .github/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ARG GIT_SHA
ARG FROM_TAG=${GIT_SHA:-latest}

FROM ghcr.io/tenstorrent/tt-xla/tt-xla-base-ubuntu-22-04:${FROM_TAG} AS ci-build
SHELL ["/bin/bash", "-c"]

# Create a directory for the build and toolchain
ARG GIT_SHA
ENV PROJECT_NAME=tt-xla
ENV BUILD_DIR=/home/build
ENV TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain

RUN echo "Building $PROJECT_NAME at $GIT_SHA"

RUN mkdir -p $BUILD_DIR && \
mkdir -p $TTMLIR_TOOLCHAIN_DIR

# Clone tt-mlir
RUN git clone [email protected]:tenstorrent/tt-mlir.git $BUILD_DIR/$PROJECT_NAME && \
cd $BUILD_DIR/$PROJECT_NAME && \
git checkout $GIT_SHA

# Build the toolchain
WORKDIR $BUILD_DIR/$PROJECT_NAME
RUN source env/activate && \
cmake -B env/build env && \
cmake --build env/build

# Self-test

# Build project to test the container
RUN source env/activate && \
cmake -G Ninja \
-B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DTTMLIR_ENABLE_RUNTIME=ON \
-DTTMLIR_ENABLE_RUNTIME_TESTS=ON \
-DTTMLIR_ENABLE_STABLEHLO=ON

RUN source env/activate && \
cmake --build build --config Release

RUN source env/activate && \
cmake --build build -- ttrt

# Run clang-tidy
RUN source env/activate && \
cmake --build build -- clang-tidy

# Run the tests
RUN source env/activate && \
cmake --build build -- check-ttmlir

# Final stage
FROM ghcr.io/tenstorrent/tt-xla/tt-xla-base-ubuntu-22-04:${FROM_TAG} AS ci

# Copy the TTMLIR_TOOLCHAIN_DIR from the previous stage
ENV TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain
RUN echo "Copying from ci-build stage $TTMLIR_TOOLCHAIN_DIR"
COPY --from=ci-build $TTMLIR_TOOLCHAIN_DIR $TTMLIR_TOOLCHAIN_DIR

RUN du -h --max-depth=2 $TTMLIR_TOOLCHAIN_DIR
94 changes: 94 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build and Publish Docker Image

on:
workflow_dispatch:
workflow_call:

jobs:
build:

runs-on:
- in-service
- builder

env:
BASE_IMAGE_NAME: ghcr.io/${{ github.repository }}/tt-xla-base-ubuntu-22-04
CI_IMAGE_NAME: ghcr.io/${{ github.repository }}/tt-xla-ci-ubuntu-22-04

steps:

- name: Fix permissions
run: sudo chmod 777 -R $GITHUB_WORKSPACE

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build images

- name: Build and export base Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.base
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.BASE_IMAGE_NAME}}:${{ github.sha }}
- name: Build and export CI Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:${{ github.sha }}
- name: Build and export IRD Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.ird
push: true
build-args: |
GIT_SHA=${{ github.sha }}
FROM_IMAGE=ci
tags: |
${{ env.IRD_IMAGE_NAME}}:${{ github.sha }}
# Tag images as latest

- name: Build and push base Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.base
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.BASE_IMAGE_NAME}}:latest
- name: Build and push CI Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:latest

0 comments on commit 68a3730

Please sign in to comment.