Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/actions/locate-vcvarsall-and-setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 'Locate vcvarsall and Setup Environment'
description: 'Locates vcvarsall.bat, sets up the environment, and handles PATH updates.'
inputs:
architecture:
description: 'Target architecture (x64 or x86)'
required: true
default: 'x64'
outputs:
vcvarsall_path:
description: "Path to vcvarsall.bat"
value: ${{ steps.find-vcvarsall.outputs.vcvarsall_path }}
runs:
using: "composite"
steps:
- name: Find vcvarsall.bat
id: find-vcvarsall
shell: python # Use Python shell
run: |
import os
import subprocess

vswhere_path = os.path.join(os.environ["ProgramFiles(x86)"], "Microsoft Visual Studio", "Installer", "vswhere.exe")

try:
process = subprocess.run([vswhere_path, "-latest", "-property", "installationPath"], capture_output=True, text=True, check=True)
vs_install_path = process.stdout.strip()
vcvarsall_path = os.path.join(vs_install_path, "VC", "Auxiliary", "Build", "vcvarsall.bat")

if os.path.exists(vcvarsall_path):
print(f"vcvarsall found at: {vcvarsall_path}")
# Use GITHUB_OUTPUT environment variable
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f"vcvarsall_path={vcvarsall_path}\n")
else:
print(f"vcvarsall.bat not found at expected path: {vcvarsall_path}")
# Use 'exit(1)' for Python to properly signal failure to GitHub Actions
exit(1)


except subprocess.CalledProcessError as e:
print(f"Error running vswhere.exe: {e}")
print(f"vswhere output: {e.stdout}")
print(f"vswhere stderr: {e.stderr}")
exit(1) # Exit with a non-zero code on error
except FileNotFoundError:
print(f"vswhere.exe not found at: {vswhere_path}")
exit(1)


- name: Setup Environment
shell: cmd
run: |
REM Get initial environment variables
set > initial_env.txt

REM Call vcvarsall.bat using the output from the previous step
call "${{ steps.find-vcvarsall.outputs.vcvarsall_path }}" ${{ inputs.architecture }}

REM Get environment variables after calling vcvarsall.bat
set > final_env.txt

REM Call the Python script to update the GitHub Actions environment
python ${{ github.action_path }}\update_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@echo off
setlocal

set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
set vcvarsall_arch=%1
if "%vcvarsall_arch%" == "x86" (
set vcvarsall_arch=x86
) else (
set vcvarsall_arch=x64
)

for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do (
if exist "%%i\VC\Auxiliary\Build\vcvars%vcvarsall_arch%.bat" (
set "vcvarsall=%%i\VC\Auxiliary\Build\vcvars%vcvarsall_arch%.bat"
)
)

echo "Get initial environment variables"
set > initial_env.txt

echo "Call vcvarsall.bat"
call "%vcvarsall%"

echo "Get environment variables after calling vcvarsall.bat"
set > final_env.txt

echo "Call the Python script to update the GitHub Actions environment"
python "%~dp0\update_environment.py"

endlocal
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
Comment thread Fixed
Comment thread Fixed
Comment thread Fixed
import re


def read_env_file(filepath):
env_vars = {}
with open(filepath) as f:
for line in f:
match = re.match(r"^(.*?)=(.*)$", line.strip())
if match:
Comment thread
snnn marked this conversation as resolved.
env_vars[match.group(1).upper()] = match.group(2)
return env_vars


initial_env = read_env_file("initial_env.txt")
final_env = read_env_file("final_env.txt")

Comment thread
snnn marked this conversation as resolved.
for key, value in final_env.items():
if key not in initial_env or initial_env[key] != value:
if key.startswith("_"):
continue
if key.upper() == "PATH":
new_paths = value.split(";")
initial_paths = initial_env.get("PATH", "").split(";")
added_paths = [p for p in new_paths if p not in initial_paths and p]
Comment thread
snnn marked this conversation as resolved.

if added_paths:
print("Adding paths")
with open(os.environ["GITHUB_PATH"], "a") as f:
for path in added_paths:
Comment thread
snnn marked this conversation as resolved.
print(f"Adding PATH: {path}")
f.write(path + os.linesep)
else:
# Use GITHUB_ENV
with open(os.environ["GITHUB_ENV"], "a") as f:
print(f"Setting {key}={value}\n")
f.write(f"{key}={value}\n")
44 changes: 0 additions & 44 deletions .github/workflows/windows.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/windows_build_x64_asan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# .github/workflows/build_x64_asan.yml
name: windows_x64_asan

on:
push:
branches: [ main, 'rel-*']
pull_request:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_x64:
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-vs2022-mms"]
timeout-minutes: 300

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: false

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
architecture: x64

- name: Locate vcvarsall and Setup Env
uses: ./.github/actions/locate-vcvarsall-and-setup-env # Use the composite action
with:
architecture: x64

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Build and Test (Combined)
shell: cmd
run: |
@echo off
echo %PATH%
python -m pip install -r "%GITHUB_WORKSPACE%\tools\ci_build/github/windows\python\requirements.txt"
python "%GITHUB_WORKSPACE%\tools\ci_build\build.py" --config Debug --build_dir "%RUNNER_TEMP%\build" --skip_submodule_sync --parallel --use_vcpkg --use_vcpkg_ms_internal_asset_cache --cmake_generator "Visual Studio 17 2022" --disable_memleak_checker --enable_address_sanitizer
122 changes: 122 additions & 0 deletions .github/workflows/windows_x64_debug_build_x64_debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: windows_x64_debug

on:
push:
branches: [ main, 'rel-*']
pull_request:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_x64_debug:
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-vs2022-mms"]
timeout-minutes: 300

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: false

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
architecture: x64

- name: Locate vcvarsall and Setup Env
uses: ./.github/actions/locate-vcvarsall-and-setup-env # Use the composite action
with:
architecture: x64

- name: Install python modules
shell: cmd
run: python -m pip install -r "${{ github.workspace }}\tools\ci_build\github\windows\python\requirements.txt"

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
architecture: x64

- name: API Documentation Check and generate
shell: cmd
run: |
set ORT_DOXY_SRC=${{ github.workspace }}
set ORT_DOXY_OUT=${{ github.workspace }}\build\Debug\Debug
mkdir %ORT_DOXY_SRC%
mkdir %ORT_DOXY_OUT%
"C:\Program Files\doxygen\bin\doxygen.exe" ${{ github.workspace }}\tools\ci_build\github\Doxyfile_csharp.cfg
working-directory: ${{ github.workspace }}

- name: Use .NET 8.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
env:
PROCESSOR_ARCHITECTURE: x64

- name: Use Nuget 6.x
uses: nuget/setup-nuget@v1 # Use the official NuGet setup action
with:
nuget-version: '6.x'

- name: NuGet restore
shell: cmd
run: |
nuget restore ${{ github.workspace }}\packages.config -PackagesDirectory ${{ github.workspace }}\build\Debug -ConfigFile ${{ github.workspace }}\NuGet.config

- name: Build and Test
shell: pwsh
run: |
python.exe "${{ github.workspace }}\tools\ci_build\build.py" --config Debug --build_dir "${{ github.workspace }}\build" --skip_submodule_sync --build_csharp --parallel --use_binskim_compliant_compile_flags --cmake_generator "Visual Studio 17 2022" --build_shared_lib --enable_onnx_tests --build_java --build_nodejs --build_wheel --disable_memleak_checker --msbuild_extra_options "IncludeMobileTargets=false" --build_nuget --use_vcpkg --use_vcpkg_ms_internal_asset_cache
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Remove-Item "${{ github.workspace }}\build\Debug" -Include "*.obj" -Recurse
env: # Set environment variables here, applies to this step only
ALLOW_RELEASED_ONNX_OPSET_ONLY: '0'
DocUpdateNeeded: 'false' # Can be set dynamically based on build output if needed


- name: Validate C# native delegates
shell: cmd
run: python tools\ValidateNativeDelegateAttributes.py
working-directory: ${{ github.workspace }}\\csharp

- name: Install onnxruntime wheel
shell: pwsh
run: |
python -m pip uninstall -y onnxruntime onnxruntime-gpu onnxruntime-training onnxruntime-directml -qq
Get-ChildItem -Path dist/*.whl | foreach {pip --disable-pip-version-check install --upgrade $_.fullname}
working-directory: "${{ github.workspace }}\\build\\Debug\\Debug"

# Publish artifacts only on failure and if DocUpdateNeeded is true (example)
- name: Publish OperatorKernels.md (Conditional)
uses: actions/upload-artifact@v4
if: failure() && env.DocUpdateNeeded == 'true' # Use env. for step-level vars
with:
name: OperatorKernels.md
path: ${{ github.workspace }}/docs/OperatorKernels.md

- name: Publish ContribOperators.md (Conditional)
uses: actions/upload-artifact@v4
if: failure() && env.DocUpdateNeeded == 'true'
with:
name: ContribOperators.md
path: ${{ github.workspace }}/docs/ContribOperators.md

# These variables will persist for the entire job
env:
OrtPackageId: Microsoft.ML.OnnxRuntime
OnnxRuntimeBuildDirectory: ${{ github.workspace }}\build
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 'true'
Loading