Skip to content

Commit 9ab2ba5

Browse files
authored
Update msvc_build.yml
1 parent 17775b9 commit 9ab2ba5

1 file changed

Lines changed: 115 additions & 89 deletions

File tree

.github/workflows/msvc_build.yml

Lines changed: 115 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,131 @@
1-
name: Check code formatting
1+
name: Build release (Windows)
22

33
on:
44
workflow_dispatch:
5-
# pull_request:
6-
# branches:
7-
# - main
85

96
env:
10-
BUILD_TYPE: Debug
7+
BUILD_CONFIGURATION: Release
8+
ARCH: x64
9+
VCPKG_ROOT: ./vcpkg
10+
VCPKG_INSTALL_FOLDER: ./vcpkg/installed
11+
CS_XSD_INSTALL_FOLDER: xsd/xsd-4.0.0-i686-windows/libxsd
12+
WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/487fd8c3-a3d8-4c22-a903-f8d54c2c57be/intel-oneapi-base-toolkit-2025.1.0.650_offline.exe
13+
WINDOWS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/0ba263f5-de00-4e91-a780-fdb9e131c1e8/intel-oneapi-hpc-toolkit-2025.1.0.665_offline.exe
14+
WINDOWS_CPP_COMPONENTS: intel.oneapi.win.cpp-dpcpp-common
15+
CACHE_NUMBER: 4
1116

1217
jobs:
13-
format_check:
14-
runs-on: ubuntu-latest
18+
build:
19+
runs-on: windows-latest
1520
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v3
21+
- uses: actions/checkout@v3
1822

19-
- name: Install clang-format
20-
uses: aminya/setup-cpp@v1
23+
- name: Install vcpkg
24+
shell: powershell
25+
run: |
26+
if (-not (Test-Path "./vcpkg")) {
27+
Write-Host "Cloning vcpkg repository..."
28+
git clone https://github.com/microsoft/vcpkg.git
29+
Write-Host "Bootstrapping vcpkg..."
30+
& .\vcpkg\bootstrap-vcpkg.bat
31+
} else {
32+
Write-Host "vcpkg is already installed."
33+
}
34+
35+
- name: Cache vcpkg packages
36+
uses: actions/cache@v3
37+
id: cache-vcpkg
2138
with:
22-
clang-format: true
39+
path: ${{ env.VCPKG_INSTALL_FOLDER }}
40+
key: ${{ runner.os }}-vcpkg-${{ hashFiles('.github/workflows/msvc_build.yml') }}
2341

24-
- name: Check formatting in repo
25-
id: fmt
26-
continue-on-error: ${{ github.event_name == 'workflow_dispatch' }}
42+
- name: Install vcpkg prerequisites
43+
shell: cmd
44+
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
2745
run: |
28-
echo "Checking formatting in repo"
29-
# Remove any previous error file.
30-
rm -f /tmp/clang_format_errors.txt
46+
.\vcpkg\vcpkg.exe update
47+
.\vcpkg\vcpkg.exe install boost-process boost-iostreams boost-spirit boost-system boost-filesystem boost-timer boost-thread boost-program-options openblas 7zip xerces-c curl --triplet=%ARCH%-windows
48+
.\vcpkg\vcpkg.exe integrate install
49+
.\vcpkg\vcpkg.exe list
3150
32-
# Find and process files using -exec.
33-
find . -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) \
34-
-exec bash -c '
35-
f="$1"
36-
echo "Processing file: $f"
37-
diff=$(clang-format --fallback-style=LLVM --style=file "$f" | diff "$f" -)
38-
echo "DEBUG: diff result for $f:"
39-
echo "$diff"
40-
if [ -n "$diff" ]; then
41-
echo "::warning file=$f::Formatting issues found"
42-
echo "- $f" >> /tmp/clang_format_errors.txt
43-
fi
44-
' bash {} \;
51+
- name: Cache Intel OneAPI
52+
id: cache-oneapi
53+
uses: actions/cache@v3
54+
with:
55+
path: |
56+
C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat
57+
C:\Program Files (x86)\Intel\oneAPI\compiler
58+
key: install-${{ env.CACHE_NUMBER }}-${{ env.WINDOWS_HPCKIT_URL }}-${{ env.WINDOWS_CPP_COMPONENTS }}-compiler-${{ hashFiles('**/scripts/cache_exclude_windows.sh') }}
4559

46-
ERRORS=$(cat /tmp/clang_format_errors.txt 2>/dev/null)
47-
echo "DEBUG: Accumulated errors:"
48-
echo "$ERRORS"
49-
echo "errors<<EOF" >> $GITHUB_OUTPUT
50-
echo -e "$ERRORS" >> $GITHUB_OUTPUT
51-
echo "EOF" >> $GITHUB_OUTPUT
52-
echo "DEBUG: Contents of GITHUB_OUTPUT file:"
53-
cat "$GITHUB_OUTPUT"
54-
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
55-
exit 0
56-
else
57-
if [ -n "$ERRORS" ]; then
58-
exit 1
59-
else
60-
exit 0
61-
fi
62-
fi
60+
- name: Install Intel OneAPI
61+
if: steps.cache-oneapi.outputs.cache-hit != 'true'
62+
shell: powershell
63+
run: |
64+
Write-Host "Installing Intel OneAPI..."
65+
$url = $env:WINDOWS_HPCKIT_URL
66+
$components = $env:WINDOWS_CPP_COMPONENTS
67+
$tempExe = Join-Path $env:TEMP "webimage.exe"
68+
69+
Write-Host "Downloading installer from $url..."
70+
curl.exe -L $url -o $tempExe
71+
72+
Write-Host "Extracting installer..."
73+
$installerArgs = "-s -x -f webimage_extracted --log extract.log"
74+
$proc = Start-Process -FilePath $tempExe -ArgumentList $installerArgs -NoNewWindow -Wait -PassThru
75+
if ($proc.ExitCode -ne 0) {
76+
throw "Installer execution failed with exit code $($proc.ExitCode)"
77+
}
78+
79+
Remove-Item $tempExe -Force
80+
81+
if ([string]::IsNullOrEmpty($components)) {
82+
$bootstrapArgs = "-s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=."
83+
} else {
84+
$bootstrapArgs = "-s --action install --components=$components --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=."
85+
}
86+
87+
Write-Host "Running bootstrapper..."
88+
$bootstrapperPath = Join-Path -Path (Join-Path $PWD "webimage_extracted") "bootstrapper.exe"
89+
if (-Not (Test-Path $bootstrapperPath)) {
90+
throw "Bootstrapper not found at $bootstrapperPath"
91+
}
92+
$procBootstrap = Start-Process -FilePath $bootstrapperPath -ArgumentList $bootstrapArgs -NoNewWindow -Wait -PassThru
93+
if ($procBootstrap.ExitCode -ne 0) {
94+
throw "Bootstrapper installation failed with exit code $($procBootstrap.ExitCode)"
95+
}
96+
97+
Remove-Item -Recurse -Force "webimage_extracted"
6398
64-
- name: Post comment on PR
65-
if: ${{ github.event_name == 'pull_request' && steps.fmt.outputs.errors != '' }}
66-
uses: actions/github-script@v6
67-
with:
68-
script: |
69-
const err = `${{ steps.fmt.outputs.errors }}`;
70-
const msg = `### Code Formatting Issues\nThe following files do not adhere to the clang-format style:\n${err}`;
71-
github.rest.issues.createComment({
72-
issue_number: context.issue.number,
73-
owner: context.repo.owner,
74-
repo: context.repo.repo,
75-
body: msg
76-
});
99+
- name: Find solution file
100+
id: find_sln
101+
shell: powershell
102+
run: |
103+
$sln = Get-ChildItem -Path $env:GITHUB_WORKSPACE -Filter *.sln -Recurse | Select-Object -First 1
104+
if (-not $sln) { Write-Error "Solution file not found" }
105+
Write-Host "Solution file: $($sln.FullName)"
106+
echo "::set-output name=sln::$($sln.FullName)"
77107
78-
- name: Create Annotations for Formatting Issues
79-
if: ${{ github.event_name == 'workflow_dispatch' && steps.fmt.outputs.errors != '' }}
80-
uses: actions/github-script@v6
81-
with:
82-
script: |
83-
const errors = `${{ steps.fmt.outputs.errors }}`.trim()
84-
.split('\n')
85-
.filter(e => e);
86-
if (errors.length === 0) return;
87-
github.rest.checks.create({
88-
owner: context.repo.owner,
89-
repo: context.repo.repo,
90-
name: 'Check code formatting',
91-
head_sha: context.sha,
92-
status: 'completed',
93-
conclusion: 'failure',
94-
output: {
95-
title: 'Formatting Issues',
96-
summary: `Formatting issues detected in the following files:\n${errors.join('\n')}`,
97-
annotations: errors.map(f => ({
98-
path: f.replace(/^- /, ''),
99-
start_line: 1,
100-
end_line: 1,
101-
annotation_level: 'failure',
102-
message: 'Formatting issues found'
103-
}))
104-
}
105-
});
108+
- name: Add MSBuild to PATH
109+
uses: microsoft/setup-msbuild@v1.0.2
110+
111+
- name: Restore NuGet packages
112+
working-directory: ${{ env.GITHUB_WORKSPACE }}
113+
run: nuget restore "${{ steps.find_sln.outputs.sln }}"
114+
115+
- name: Download and install xsd
116+
shell: powershell
117+
run: |
118+
curl.exe -L "https://www.codesynthesis.com/download/xsd/latest/windows/i686/xsd-latest-i686-windows.zip" -o "./xsd-latest-i686-windows.zip"
119+
Write-Host "Extracting xsd..."
120+
& "7z" x "xsd-latest-i686-windows.zip" -y -o"./xsd"
121+
122+
- name: Build DynAdjust
123+
shell: cmd
124+
working-directory: ${{ env.GITHUB_WORKSPACE }}
125+
run: |
126+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
127+
set DEPS_DIR=%VCPKG_INSTALL_FOLDER%\%ARCH%-windows\include
128+
set XSD_DIR=%GITHUB_WORKSPACE%\%CS_XSD_INSTALL_FOLDER%
129+
set PATH=%DEPS_DIR%;%XSD_DIR%;%PATH%
130+
echo %PATH%
131+
msbuild /m /p:Configuration=%BUILD_CONFIGURATION% /p:Platform=%ARCH% /p:"VCBuildAdditionalOptions= /useenv" "${{ steps.find_sln.outputs.sln }}"

0 commit comments

Comments
 (0)