Skip to content

Commit 42eeeec

Browse files
committed
[mlir-tensorrt] Update CI to save cache after build
This PR updates mlir-tensorrt CI to save cache after each (normal and ASAN) build. Previously, cache was being saved at the end of job but this is problematic when build needs to run again (which takes long time!) just because of single test failure. Now, `cicd_build.sh` script is separated in build and test phases. Cache is saved immediately after build. This way, even when test fails, next build is faster.
1 parent 12995a1 commit 42eeeec

File tree

2 files changed

+55
-9
lines changed

2 files changed

+55
-9
lines changed

.github/workflows/mlir-tensorrt-ci.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ jobs:
112112
mkdir -p ${{ github.workspace }}/ccache
113113
mkdir -p ${{ github.workspace }}/.cache.cpm
114114
115-
# Create cache action
116-
- name: Create cache action
117-
id: core-build-cache
118-
uses: actions/cache@v4
115+
# Restore cache, if exists.
116+
- name: Restore cache
117+
id: restore-cache
118+
uses: actions/cache/restore@v4
119119
with:
120120
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
121121
restore-keys: |
@@ -125,8 +125,30 @@ jobs:
125125
${{ github.workspace }}/.cache.cpm/*
126126
!${{ github.workspace }}/.cache.cpm/tensorrt
127127
128-
# Run LIT tests with TensorRT 10
129-
- name: Run MLIR-TensorRT lit tests with TensorRT 10
128+
# TensorRT 10 tests
129+
- name: TensorRT 10 build
130+
uses: addnab/docker-run-action@v3
131+
with:
132+
image: ${{ env.DEFAULT_IMAGE }}
133+
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.cache.cpm:/.cache.cpm --gpus all
134+
registry: ${{ env.REGISTRY }}
135+
username: ${{ github.actor }}
136+
password: ${{ secrets.GITHUB_TOKEN }}
137+
run: |
138+
cd mlir-tensorrt
139+
./build_tools/scripts/cicd_build.sh --build_only
140+
141+
- name: Save cache
142+
id: save-cache
143+
uses: actions/cache/save@v4
144+
with:
145+
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
146+
path: |
147+
${{ github.workspace }}/ccache
148+
${{ github.workspace }}/.cache.cpm/*
149+
!${{ github.workspace }}/.cache.cpm/tensorrt
150+
151+
- name: TensorRT 10 test
130152
uses: addnab/docker-run-action@v3
131153
with:
132154
image: ${{ env.DEFAULT_IMAGE }}
@@ -138,8 +160,8 @@ jobs:
138160
cd mlir-tensorrt
139161
./build_tools/scripts/cicd_build.sh
140162
141-
# Run LIT tests with TensorRT 10 & ASAN
142-
- name: Run MLIR-TensorRT lit tests with TensorRT 10, ASAN enabled
163+
# TensorRT 10 & ASAN
164+
- name: TensorRT 10 ASAN test
143165
uses: addnab/docker-run-action@v3
144166
with:
145167
image: ${{ env.DEFAULT_IMAGE }}

mlir-tensorrt/build_tools/scripts/cicd_build.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
set -ex
33
set -o pipefail
44

5+
# Parse command line arguments
6+
BUILD_ONLY=false
7+
while [[ $# -gt 0 ]]; do
8+
case $1 in
9+
--build_only)
10+
BUILD_ONLY=true
11+
shift
12+
;;
13+
*)
14+
echo "Unknown option: $1"
15+
echo "Usage: $0 [--build_only]"
16+
echo " --build_only: Only build, skip tests"
17+
exit 1
18+
;;
19+
esac
20+
done
21+
522
REPO_ROOT=$(pwd)
623
BUILD_DIR="${REPO_ROOT}/build"
724
export LLVM_LIT_ARGS=${LLVM_LIT_ARGS:-"-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --timeout=1200 --time-tests -Drun_long_tests=${RUN_LONG_TESTS}"}
@@ -17,5 +34,12 @@ rm -rf ${BUILD_DIR} || true
1734

1835
cmake -B${BUILD_DIR} --preset github-cicd
1936

20-
ninja -C ${BUILD_DIR} -k 0 check-all-mlir-tensorrt
37+
if [[ "$BUILD_ONLY" == "true" ]]; then
38+
echo "🔨 Building only (skipping tests)..."
39+
ninja -C ${BUILD_DIR} -k 0 all
40+
else
41+
echo "🔨🧪 Building and testing..."
42+
ninja -C ${BUILD_DIR} -k 0 check-all-mlir-tensorrt
43+
fi
44+
2145
ccache --show-stats || true

0 commit comments

Comments
 (0)