Skip to content

Commit 6e2f888

Browse files
committed
[Task] : Add ci for windows build.
1 parent fd65a66 commit 6e2f888

File tree

5 files changed

+101
-6
lines changed

5 files changed

+101
-6
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,62 @@ jobs:
7979
if: ${{ matrix.torch-version == 'nightly' }}
8080
run: |
8181
bash build_tools/ci/check_generated_sources.sh
82+
83+
build-test-windows:
84+
strategy:
85+
fail-fast: true
86+
matrix:
87+
torch-version: [nightly]
88+
name: Build (Windows, torch-${{ matrix.torch-version }})
89+
runs-on: windows-latest
90+
defaults:
91+
run:
92+
shell: bash
93+
env:
94+
CACHE_DIR: ${{ github.workspace }}\.container-cache
95+
steps:
96+
- name: "Checking out repository"
97+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
98+
with:
99+
submodules: true
100+
101+
- name: Setup workspace
102+
uses: ./.github/actions/setup-build
103+
104+
- name: Enable cache
105+
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
106+
with:
107+
path: ${{ env.CACHE_DIR }}
108+
key: build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-${{ github.sha }}
109+
restore-keys: |
110+
build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-
111+
112+
- name: "Configuring MSVC"
113+
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
114+
115+
- name: Install python deps (torch-${{ matrix.torch-version }})
116+
run: |
117+
./build_tools/ci/install_python_deps.sh ${{ matrix.torch-version }}
118+
119+
- name: ccache
120+
uses: hendrikmuhs/ccache-action@53911442209d5c18de8a31615e0923161e435875 # v1.2.16
121+
with:
122+
key: ${{ github.job }}-${{ matrix.torch-version }}
123+
save: ${{ needs.setup.outputs.write-caches == 1 }}
124+
125+
- name: Build project
126+
run: |
127+
cache_dir="${{ env.CACHE_DIR }}" \
128+
./build_tools/python_deploy/build_windows_ci.sh
129+
130+
- name: Save cache
131+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
132+
if: ${{ !cancelled() }}
133+
with:
134+
path: ${{ env.CACHE_DIR }}
135+
key: build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-${{ github.sha }}
136+
137+
# todo: enable when use of `signal` for timeout is enhanced to be platform-agnostic
138+
# - name: Integration tests (torch-${{ matrix.torch-version }})
139+
# run: |
140+
# ./build_tools/ci/test_posix.sh ${{ matrix.torch-version }}

build_tools/python_deploy/build_windows_ci.sh

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
#!/usr/bin/env bash
2-
set -eo pipefail
2+
set -eu -o errtrace
33

44
echo "Building torch-mlir"
55

6+
cache_dir="${cache_dir:-}"
7+
this_dir="$(cd $(dirname $0) && pwd)"
8+
repo_root="$(cd ${this_dir}/../.. && pwd)"
9+
10+
# Setup cache dir.
11+
if [ -z "${cache_dir}" ]; then
12+
cache_dir="${repo_root}/.build-cache"
13+
mkdir -p "${cache_dir}"
14+
cache_dir="$(cd ${cache_dir} && pwd)"
15+
fi
16+
17+
echo "Caching to ${cache_dir}"
18+
mkdir -p "${cache_dir}/ccache"
19+
mkdir -p "${cache_dir}/pip"
20+
21+
export CCACHE_DIR="${cache_dir}/ccache"
22+
export CCACHE_MAXSIZE="350M"
23+
24+
# Clear ccache stats.
25+
ccache -z
26+
27+
echo "::group::CMake configure"
628
cmake -GNinja -Bbuild \
729
-DCMAKE_BUILD_TYPE=Release \
830
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
@@ -14,9 +36,23 @@ cmake -GNinja -Bbuild \
1436
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
1537
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
1638
-DPython3_EXECUTABLE="$(which python)" \
39+
-DPython_EXECUTABLE="$(which python)" \
1740
-DTORCH_MLIR_ENABLE_STABLEHLO=OFF \
18-
$GITHUB_WORKSPACE/externals/llvm-project/llvm
41+
-DTORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS=ON \
42+
-DTORCH_MLIR_ENABLE_LTC=OFF \
43+
-DTORCH_MLIR_ENABLE_JIT_IR_IMPORTER=ON \
44+
$repo_root/externals/llvm-project/llvm
45+
echo "::endgroup::"
1946

20-
cmake --build build --config Release
47+
echo "::group::Build"
48+
cmake --build $repo_root/build --target tools/torch-mlir/all -- -k 0
49+
echo "::endgroup::"
2150

2251
echo "Build completed successfully"
52+
53+
echo "::group::Unit tests"
54+
cmake --build $repo_root/build --target check-torch-mlir
55+
echo "::endgroup::"
56+
57+
# Show ccache stats.
58+
ccache --show-stats

test/python/fx_importer/sparsity/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ config.unsupported = True
22

33
try:
44
import torch
5-
if "2.5.0" <= str(torch.__version__):
5+
if "2.5.0" <= str(torch.__version__) and "Windows" not in config.host_os:
66
print("Enabling sparsity propagation tests")
77
config.unsupported = False
88

test/python/fx_importer/v2.3/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ config.unsupported = True
22

33
try:
44
import torch
5-
if torch.__version__ >= "2.3.0":
5+
if torch.__version__ >= "2.3.0" and "Windows" not in config.host_os:
66
print("Enabling Torch v2.3+ tests")
77
config.unsupported = False
88
except ModuleNotFoundError:

test/python/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
if not config.enable_bindings_python:
1+
if not config.enable_bindings_python or "Windows" in config.host_os:
22
config.unsupported = True

0 commit comments

Comments
 (0)