Skip to content

Commit

Permalink
Improve CI build time (#139)
Browse files Browse the repository at this point in the history
Improve CI build time

Cache /opt/ttmlir-toolchain

- moved ttmlir-toolchain build to separate action
- build ttmlir-toolchain only if files in env/ are changed or there is no cache

Use ccache for builds

- Add ccache to build
- Ccache folder will be cached between pipeline runs

env/CMakeLists.txt

- Moved dependency versions to variables
  • Loading branch information
vmilosevic authored Jul 16, 2024
1 parent 907f53e commit 8f9799e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
29 changes: 29 additions & 0 deletions .github/actions/build_toolchain/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Build ttmlir-toolchain'
description: 'Loads the ttmlir-toolchain from cache or builds it if there is no cache hit'
inputs:
os:
description: 'Operating System'
required: true
runs:
using: 'composite'
steps:
- name: Mkdir /opt/ttmlir-toolchain
shell: bash
run: |
sudo mkdir -p /opt/ttmlir-toolchain
sudo chown -R ${USER} /opt/ttmlir-toolchain
- name: 'Cache ttmlir-toolchain'
id: cache-toolchain
uses: actions/cache@v3
with:
path: /opt/ttmlir-toolchain
key: ${{ inputs.os }}-ttmlir-toolchain-${{ hashFiles('env/**') }}

- name: 'Build ttmlir-toolchain'
if: steps.cache-toolchain.outputs.cache-hit != 'true'
shell: bash
run: |
source env/activate
cmake -B env/build env
cmake --build env/build
26 changes: 8 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,16 @@ jobs:
with:
fetch-depth: 0 # Fetch all history and tags

- name: mkdir /opt/ttmlir-toolchain
shell: bash
run: |
sudo mkdir -p /opt/ttmlir-toolchain
sudo chown -R ${USER} /opt/ttmlir-toolchain
- name: Cache ttmlir-toolchain
uses: actions/cache@v3
- name: Build and cache ttmlir-toolchain
uses: ./.github/actions/build_toolchain
with:
path: /opt/ttmlir-toolchain
key: ${{ runner.OS }}-ttmlir-toolchain-cache-${{ hashFiles('env/**') }}
restore-keys: |
${{ runner.OS }}-ttmlir-toolchain-cache-
os: ${{ matrix.os }}

- name: Build ttmlir-toolchain
shell: bash
run: |
source env/activate
cmake -B env/build env
cmake --build env/build
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
create-symlink: true
key: ${{ matrix.os }}

- name: Set reusable strings
id: strings
Expand Down
8 changes: 6 additions & 2 deletions env/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.20.0)
project(ttmlir-toolchain LANGUAGES CXX C)

set(FLATBUFFERS_VERSION "v24.3.7")
set(LLVM_PROJECT_VERSION "llvmorg-18.1.0")

include(ExternalProject)

if (NOT DEFINED ENV{TTMLIR_TOOLCHAIN_DIR})
Expand All @@ -25,7 +29,7 @@ ExternalProject_Add(
-DFLATBUFFERS_BUILD_TESTS=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON # Required for linking into shared libraries (python bindings)
GIT_REPOSITORY https://github.com/google/flatbuffers.git
GIT_TAG v24.3.7
GIT_TAG ${FLATBUFFERS_VERSION}
DEPENDS python-venv
)

Expand Down Expand Up @@ -58,7 +62,7 @@ ExternalProject_Add(
SOURCE_SUBDIR llvm
LIST_SEPARATOR ","
GIT_REPOSITORY https://github.com/llvm/llvm-project.git
GIT_TAG llvmorg-18.1.0
GIT_TAG ${LLVM_PROJECT_VERSION}
GIT_PROGRESS ON
DEPENDS python-venv
)
Expand Down

0 comments on commit 8f9799e

Please sign in to comment.