-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Convert Windows CPU CI Pipeline to Github Actions #23996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 19 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
cf19a6f
update
53b8e0f
update
a30afb0
update
ea3eec8
update
d6e1c7a
update
97d6881
update
f2fa9d9
update
514de88
update
40c077b
update
dfc4282
update
54ee8fc
update
96f2894
update
9e8ee41
update
5645323
update
182023c
update
a77ce74
update
f332db4
update
c137d03
Convert
5269719
update
be1e9ce
update
924523a
update
42d5721
format code
3b061c1
update
236e2ee
update
85ed800
update
f8a91ea
update
9042cb2
update
2c20d28
update
77c52ab
Update tools/ci_build/build.py
fce632f
update
38799be
update
fbfcb38
update
e4686d9
update
beb540b
update
202afef
update
93c995f
update
caab691
update
450c22d
update
29675e5
update
ea30035
Merge remote-tracking branch 'origin/main' into snnn/gha
8012037
fix
c922a68
update
2c952a0
revert
dd62738
update
9167709
Merge remote-tracking branch 'origin/main' into snnn/gha
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
30 changes: 30 additions & 0 deletions
30
.github/actions/locate-vcvarsall-and-setup-env/locate_vcvarsall.bat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
35 changes: 35 additions & 0 deletions
35
.github/actions/locate-vcvarsall-and-setup-env/update_environment.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import os | ||
|
|
||
| import re | ||
|
|
||
| def read_env_file(filepath): | ||
| env_vars = {} | ||
| with open(filepath, 'r') as f: | ||
|
|
||
| for line in f: | ||
| match = re.match(r'^(.*?)=(.*)$', line.strip()) | ||
| if match: | ||
|
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') | ||
|
|
||
|
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] | ||
|
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: | ||
|
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") | ||
|
snnn marked this conversation as resolved.
Outdated
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # .github/workflows/build_x64_asan.yml | ||
| name: build_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 | ||
| env: | ||
| VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | ||
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # .github/workflows/build_x86_asan.yml | ||
| name: build_x86_asan | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, 'rel-*'] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build_x86: | ||
| 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: x86 | ||
|
|
||
| - name: Locate vcvarsall and Setup Env | ||
| uses: ./.github/actions/locate-vcvarsall-and-setup-env # Use the composite action | ||
| with: | ||
| architecture: x86 | ||
|
|
||
| - 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 | ||
| env: | ||
| VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | ||
| run: | | ||
| @echo off | ||
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.