@@ -104,9 +104,71 @@ jobs:
104104 - name : Add msbuild to PATH
105105 uses : microsoft/setup-msbuild@v3
106106
107+ # SonarQubeのBuild Wrapperをインストールする
108+ - name : Install Build Wrapper
109+ if : ${{ matrix.platform == 'x64' && matrix.config == 'Debug' }}
110+ uses : SonarSource/sonarqube-scan-action/install-build-wrapper@713881670b6b3676cda39549040e2d88c70d582e # v8.2.0
111+
112+ # OpenCppCoverageをインストールする
113+ - name : Install OpenCppCoverage (winget)
114+ id : install_opencppcoverage_winget
115+ if : ${{ matrix.config == 'Debug' }}
116+ continue-on-error : true
117+ run : |
118+ winget install `
119+ --id OpenCppCoverage.OpenCppCoverage `
120+ --exact `
121+ --accept-package-agreements `
122+ --accept-source-agreements
123+ shell : pwsh
124+
125+ # wingetは失敗することがあるので、インストーラー方式も残しておく。
126+ - name : Install OpenCppCoverage (installer)
127+ if : ${{ matrix.config == 'Debug' && steps.install_opencppcoverage_winget.outcome == 'failure' }}
128+ working-directory : ${{ runner.temp }}
129+ run : |
130+ $installer = '.\OpenCppCoverageSetup.exe'
131+ Invoke-WebRequest `
132+ -Uri "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe" `
133+ -OutFile $installer
134+ $expectedSha256 = '2295a733da39412c61e4f478677519dd0bb1893d88313ce56b468c9e50517888'
135+ $actualSha256 = (Get-FileHash $installer -Algorithm SHA256).Hash.ToLowerInvariant()
136+ if ($actualSha256 -ne $expectedSha256.ToLowerInvariant()) {
137+ throw "SHA256 mismatch: expected=$expectedSha256 actual=$actualSha256"
138+ }
139+ Start-Process `
140+ -FilePath $installer `
141+ -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES" `
142+ -Wait
143+ echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
144+ shell : pwsh
145+
107146 - name : Set up Python
108- if : ${{ matrix.platform == 'x64' }}
109147 uses : actions/setup-python@v6
148+ with :
149+ python-version : ${{ vars.PYTHON_VERSION || '3.14.3' }}
150+ cache : ' pip'
151+ - run : pip install -r requirements.txt
152+
153+ - name : Copy github-event.json
154+ run : |
155+ Copy-Item "$env:GITHUB_EVENT_PATH" github-event.json
156+ shell : pwsh
157+
158+ - name : Generate sonar metadata
159+ if : ${{ matrix.platform == 'x64' && matrix.config == 'Debug' }}
160+ env :
161+ PR_HEAD_REF : ${{ github.event.pull_request.head.ref }}
162+ PR_BASE_REF : ${{ github.event.pull_request.base.ref }}
163+ run : |
164+ [ordered]@{
165+ event_name = '${{ github.event_name }}'
166+ ref_name = '${{ github.ref_name }}'
167+ pr_number = '${{ github.event.pull_request.number }}'
168+ pr_head_ref = $env:PR_HEAD_REF
169+ pr_base_ref = $env:PR_BASE_REF
170+ } | ConvertTo-Json | Set-Content sonar-metadata.json
171+ shell : pwsh
110172
111173 - name : Setup PR environment variables
112174 if : github.event_name == 'pull_request'
@@ -117,7 +179,13 @@ jobs:
117179 echo "GITHUB_PR_HEAD_SHORT_COMMIT=$('${{ github.event.pull_request.head.sha }}'.SubString(0, 8))" >> $env:GITHUB_ENV
118180 shell : pwsh
119181
182+ - name : Build with Build-Wrapper
183+ if : ${{ matrix.platform == 'x64' && matrix.config == 'Debug' }}
184+ run : build-wrapper-win-x86-64.exe --out-dir bw-output MsBuild.exe /p:Platform=${{ matrix.platform }} /p:Configuration=${{ matrix.config }}
185+ shell : cmd
186+
120187 - name : MSBuild
188+ if : ${{ matrix.platform != 'x64' || matrix.config != 'Debug' }}
121189 run : build-sln.bat ${{ matrix.platform }} ${{ matrix.config }}
122190 shell : cmd
123191
@@ -128,10 +196,30 @@ jobs:
128196 path : help
129197
130198 - name : Run unit tests
131- run : .\tests1.exe --gtest_output=xml:${{github.workspace}}\tests1.exe-googletest-${{matrix.platform}}-${{matrix.config}}.xml
132- working-directory : ${{github.workspace}}\${{matrix.platform}}\${{matrix.config}}
199+ run : ctest
200+ --test-dir build/${{ matrix.platform }}/CMakeTools
201+ -C ${{ matrix.config }}
202+ --output-on-failure
133203 shell : pwsh
134204
205+ - name : Upload test result
206+ uses : EnricoMi/publish-unit-test-result-action/windows@v2
207+ with :
208+ files : |
209+ *-googletest.xml
210+
211+ - name : Upload sonar-input artifact
212+ if : ${{ matrix.platform == 'x64' && matrix.config == 'Debug' }}
213+ uses : actions/upload-artifact@v7
214+ with :
215+ name : sonar-input
216+ path : |
217+ bw-output/
218+ tests*-coverage.xml
219+ tests*-googletest.xml
220+ sonar-metadata.json
221+ github-event.json
222+
135223 # Toolbar Bitmap Split/Mux
136224 - run : build-bmp-tools.bat ${{matrix.config}}
137225 name : Bitmap Split/Mux
@@ -181,98 +269,3 @@ jobs:
181269 with :
182270 name : Dev ${{ matrix.platform }} ${{ matrix.config }}
183271 path : ' sakura-*-Dev.zip'
184-
185- sonar-build :
186- name : MSBuild for SonarCloud (x64/Debug)
187- runs-on : windows-latest
188-
189- env :
190- BUILD_PLATFORM : x64
191- BUILD_CONFIGURATION : Debug
192-
193- steps :
194- - uses : actions/checkout@v7
195- with :
196- fetch-depth : 0
197- submodules : true
198-
199- - name : Add msbuild to PATH
200- uses : microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # v3
201-
202- - name : Set up Python
203- uses : actions/setup-python@v6
204-
205- - name : Install AutoHotKey
206- run : |
207- $AutohotkeyDir = "$HOME\autohotkey"
208- if (!(Test-Path $AutohotkeyDir)) { New-Item -ItemType Directory -Path $AutohotkeyDir }
209- $ProgressPreference = 'SilentlyContinue'
210- Invoke-WebRequest -Uri https://github.com/AutoHotkey/AutoHotkey/releases/download/v2.0.19/AutoHotkey_2.0.19.zip -OutFile "AutoHotkey.zip"
211- Expand-Archive -Path "AutoHotkey.zip" -DestinationPath $AutohotkeyDir -Force
212- echo "AutoHotKey=$HOME\autohotkey\AutoHotkey32.exe" >> $env:GITHUB_ENV
213-
214- - name : Install Locale Emulator
215- run : |
216- $LEExpandDir = "${{ github.workspace }}\tools\LocaleEmulator"
217- $LEInitScript = "${{ github.workspace }}\tools\LocaleEmulator\init-locale-emulator.ahk"
218- Expand-Archive "${{ github.workspace }}\externals\LocaleEmulator\locale-emulator.zip" "${LEExpandDir}"
219- Start-Process $env:AutoHotKey "${LEInitScript}"
220- Start-Process "${LEExpandDir}\LEInstaller.exe"
221- echo "${LEExpandDir}" >> $env:GITHUB_PATH
222- shell : pwsh
223-
224- - name : Install Build Wrapper
225- uses : SonarSource/sonarqube-scan-action/install-build-wrapper@713881670b6b3676cda39549040e2d88c70d582e # v8.2.0
226-
227- - name : Build with Build-Wrapper
228- run : build-wrapper-win-x86-64.exe --out-dir bw-output MsBuild.exe /p:Platform=%BUILD_PLATFORM% /p:Configuration=%BUILD_CONFIGURATION% /t:ReBuild
229- shell : cmd
230-
231- - name : Install OpenCppCoverage
232- working-directory : ${{ runner.temp }}
233- run : |
234- $ProgressPreference = 'SilentlyContinue'
235- Invoke-WebRequest -Uri "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe" -OutFile OpenCppCoverageSetup.exe
236- Start-Process -FilePath .\OpenCppCoverageSetup.exe -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES" -Wait
237- echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
238- shell : pwsh
239-
240- - name : Run Tests with coverage
241- run : |
242- $env:CMD_TESTS1 = $(Get-ChildItem -Recurse tests1.exe)[0].FullName
243- OpenCppCoverage.exe `
244- --export_type cobertura:tests1-coverage.xml `
245- --modules $env:CMD_TESTS1 `
246- --sources ${{ github.workspace }} `
247- --working_dir ${{ github.workspace }}\${{ env.BUILD_PLATFORM }}\${{ env.BUILD_CONFIGURATION }} `
248- --cover_children `
249- -- `
250- $env:CMD_TESTS1 `
251- --gtest_output=xml:${{ github.workspace }}\tests1-googletest.xml
252- shell : pwsh
253-
254- - name : Save sonar metadata
255- env :
256- PR_HEAD_REF : ${{ github.event.pull_request.head.ref }}
257- PR_BASE_REF : ${{ github.event.pull_request.base.ref }}
258- run : |
259- [ordered]@{
260- event_name = '${{ github.event_name }}'
261- ref_name = '${{ github.ref_name }}'
262- pr_number = '${{ github.event.pull_request.number }}'
263- pr_head_ref = $env:PR_HEAD_REF
264- pr_base_ref = $env:PR_BASE_REF
265- } | ConvertTo-Json | Set-Content sonar-metadata.json
266- Copy-Item "$env:GITHUB_EVENT_PATH" github-event.json
267- shell : pwsh
268-
269- - name : Upload sonar-input artifact
270- uses : actions/upload-artifact@v7
271- with :
272- name : sonar-input
273- path : |
274- bw-output/
275- tests1-coverage.xml
276- tests1-googletest.xml
277- sonar-metadata.json
278- github-event.json
0 commit comments