1+ name : " windows_x86_64"
2+ on :
3+ push :
4+ tags :
5+ - v*..
6+ pull_request :
7+ branches :
8+ - main
9+ schedule :
10+ - cron : " 0 10 * * *" # Run at 2am PST (10am UTC) every day to refresh the cache.
11+ workflow_dispatch : # Manual trigger
12+ inputs :
13+ REFRESH_CACHE :
14+ description : ' Refresh cache to remove unused files'
15+ type : boolean
16+ default : true
17+
18+
19+ concurrency :
20+ group : ${{ github.workflow }}-${{ github.head_ref || github.ref }}
21+ cancel-in-progress : true
22+
23+
24+ jobs :
25+ presubmit :
26+ name : " Presubmit-Win"
27+ runs-on : windows-latest
28+ permissions :
29+ actions : write # For gh cache delete.
30+ contents : read
31+ env :
32+ # Clear ANDROID_NDK_HOME as windows-latest has NDK where jobs don't have permission for
33+ # androidndk rulesto create symlinks.
34+ ANDROID_NDK_HOME :
35+ LITERT_MODELS : " "
36+ GH_TOKEN : ${{ github.token }}
37+ REFRESH_CACHE : ${{ github.event_name == 'schedule' ||
38+ (github.event_name == 'workflow_dispatch' && inputs.REFRESH_CACHE) }}
39+ steps :
40+ - name : Checkout code
41+ uses : actions/checkout@v4
42+
43+
44+ - name : Setup Python
45+ uses : actions/setup-python@v5
46+ with :
47+ python-version : " 3.11"
48+
49+
50+ - name : Configure tensorflow & python path
51+ run : |
52+ $env:PYTHON_BIN_PATH = (Get-Command python).Source
53+ $env:PYTHON_LIB_PATH = (python -c 'import site; print(site.getsitepackages()[0])')
54+ $env:TF_NEED_ROCM = 0
55+ $env:TF_NEED_CUDA = 0
56+ $env:TF_SET_ANDROID_WORKSPACE = 0
57+ $env:CC_OPT_FLAGS = '-Wno-sign-compare'
58+ python configure.py
59+ - name : Set up cache keys and bazel output base.
60+ id : cache-keys
61+ run : |
62+ $CACHE_RESTORE_KEY_2="${{ github.workflow }}"
63+ $CACHE_RESTORE_KEY_1="$CACHE_RESTORE_KEY_2-${{ hashFiles('**/WORKSPACE', '**/.bazelrc') }}"
64+ $CACHE_RESTORE_KEY_0="$CACHE_RESTORE_KEY_1-${{ hashFiles('**/BUILD*') }}"
65+ # If it's not a pull request, then it will be the same as $CACHE_RESTORE_KEY_1-.
66+ $CACHE_RESTORE_KEY_HEAD="$CACHE_RESTORE_KEY_0-${{ github.event.pull_request.base.sha }}"
67+ $CACHE_KEY="$CACHE_RESTORE_KEY_0-${{ github.sha }}"
68+ echo "CACHE_RESTORE_KEY_2=$CACHE_RESTORE_KEY_2" >> "$env:GITHUB_OUTPUT"
69+ echo "CACHE_RESTORE_KEY_1=$CACHE_RESTORE_KEY_1" >> "$env:GITHUB_OUTPUT"
70+ echo "CACHE_RESTORE_KEY_0=$CACHE_RESTORE_KEY_0" >> "$env:GITHUB_OUTPUT"
71+ echo "CACHE_RESTORE_KEY_HEAD=$CACHE_RESTORE_KEY_HEAD" >> "$env:GITHUB_OUTPUT"
72+ echo "CACHE_KEY=$CACHE_KEY" >> "$env:GITHUB_OUTPUT"
73+ # D: is faster than C: for I/O.
74+ $SHORT_SHA=$("${{ github.sha }}".SubString(0, 8))
75+ echo "BAZEL_OUTPUT_BASE=D:/w-$SHORT_SHA" >> "$env:GITHUB_ENV"
76+ - name : Clean build outputs if cache is being refreshed.
77+ if : env.REFRESH_CACHE == 'true'
78+ run : bazel --output_base="$env:BAZEL_OUTPUT_BASE" clean --expunge
79+
80+
81+ - name : Restore bazel cache if cache is not being refreshed.
82+ id : bazel-cache
83+ if : env.REFRESH_CACHE != 'true'
84+ uses : actions/cache/restore@v4
85+ with :
86+ path : ~/.cache/bazel-windows
87+ key : ${{ steps.cache-keys.outputs.CACHE_KEY }}
88+ restore-keys : |
89+ ${{ steps.cache-keys.outputs.CACHE_RESTORE_KEY_HEAD }}
90+ ${{ steps.cache-keys.outputs.CACHE_RESTORE_KEY_0 }}-
91+ ${{ steps.cache-keys.outputs.CACHE_RESTORE_KEY_1 }}-
92+ ${{ steps.cache-keys.outputs.CACHE_RESTORE_KEY_2 }}-
93+ - name : Check cache hit
94+ run : |
95+ echo "Cache Hit: ${{ steps.bazel-cache.outputs.cache-hit }}"
96+ echo "Cache Primary Key: ${{ steps.bazel-cache.outputs.cache-primary-key }}"
97+ echo "Cache Matched Key: ${{ steps.bazel-cache.outputs.cache-matched-key }}"
98+ - name : Run bazel test on Windows for litert
99+ run : |
100+ bazel test --disk_cache=~/.cache/bazel-windows --config=windows -- //litert/c:litert_common_test //litert/c:litert_compiled_model_test //litert/c:litert_custom_op_test //litert/c:litert_environment_options_test //litert/c:litert_logging_test //litert/c:litert_model_test //litert/c:litert_opaque_options_test //litert/c:litert_options_test //litert/c:litert_profiler_test //litert/c:litert_rewriter_test //litert/c:litert_tensor_buffer_requirements_test //litert/c/internal:litert_accelerator_registration_test //litert/c/internal:litert_accelerator_test //litert/c/options:litert_cpu_options_test //litert/c/options:litert_google_tensor_options_test //litert/c/options:litert_gpu_options_test //litert/c/options:litert_mediatek_options_test //litert/c/options:litert_qualcomm_options_test //litert/c/options:litert_runtime_options_test //litert/cc:litert_any_test //litert/cc:litert_buffer_ref_test //litert/cc:litert_c_types_printing_test //litert/cc:litert_custom_op_test //litert/cc:litert_element_type_test //litert/cc:litert_environment_options_test //litert/cc:litert_environment_test //litert/cc:litert_expected_test //litert/cc:litert_handle_test //litert/cc:litert_layout_test //litert/cc:litert_logging_test //litert/cc:litert_model_test //litert/cc:litert_op_options_test //litert/cc:litert_opaque_options_test //litert/cc:litert_rewriter_test //litert/cc:litert_tensor_buffer_requirements_test //litert/cc/dynamic_runtime:litert_tensor_buffer_requirements_test //litert/cc/dynamic_runtime/options:litert_cpu_options_test //litert/cc/dynamic_runtime/options:litert_runtime_options_test //litert/cc/options:darwinn_options_test //litert/cc/options:litert_cpu_options_test //litert/cc/options:litert_gpu_options_test //litert/cc/options:litert_runtime_options_test //litert/compiler/plugin:algo_test //litert/core:build_stamp_test //litert/core:dispatch_op_schema_test //litert/core:environment_options_test //litert/core:environment_test //litert/core:error_reporter_test //litert/core:filesystem_test //litert/core:insert_order_map_test //litert/core/cache:compilation_cache_test //litert/core/model:buffer_manager_test //litert/core/model:flatbuffer_to_litert_test //litert/core/model:ir_allocator_test //litert/core/model:litert_to_flatbuffer_test //litert/core/model:model_buffer_test //litert/core/model:model_graph_test //litert/core/model:model_test //litert/core/model:rewriter_test //litert/core/util:flatbuffer_tools_test //litert/core/util:tensor_type_util_test //litert/runtime:magic_number_utils_test //litert/runtime:profiler_test //litert/runtime:tensor_buffer_registry_test //litert/runtime/dispatch:dispatch_opaque_options_test //litert/test:matchers_test //litert/tools:dump_test //litert/tools:tool_display_test //litert/tools/flags:flag_types_test //litert/tools/flags/vendors:google_tensor_flags_test //litert/tools/flags/vendors:mediatek_flags_test //litert/tools/flags/vendors:qualcomm_flags_test //litert/vendors/examples:example_common_test //litert/vendors/qualcomm/core:common_test //litert/vendors/qualcomm/core/wrappers/tests:quantize_params_wrapper_test
101+
102+ - name : Remove cache if cache is being refreshed.
103+ if : env.REFRESH_CACHE == 'true'
104+ continue-on-error : true # Ignore errors when cache is not found.
105+ run : gh cache delete ${{ steps.cache-keys.outputs.CACHE_KEY }}
106+
107+
108+ - name : Save bazel cache if it's new or being refreshed.
109+ uses : actions/cache/save@v4
110+ if : env.REFRESH_CACHE == 'true' || steps.bazel-cache.outputs.cache-hit != 'true'
111+ with :
112+ path : ~/.cache/bazel-windows
113+ key : ${{ steps.cache-keys.outputs.CACHE_KEY }}
0 commit comments