Skip to content
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

googletest のテスト結果を成功、失敗含めて azure pipelines の Web サイトで確認できるようにする #837

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions azure-pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- [Azure Pipelines の設定ファイルの構成](#azure-pipelines-の設定ファイルの構成)
- [Azure Pipelines の template ファイルの命名規則](#azure-pipelines-の-template-ファイルの命名規則)
- [Azure Pipelines のJOB の構成](#azure-pipelines-のjob-の構成)
- [Azure Pipelines の TIPS](#azure-pipelines-の-tips)
- [step または JOB の実行条件](#step-または-job-の実行条件)

<!-- /TOC -->

Expand Down Expand Up @@ -76,3 +78,26 @@ https://azure.microsoft.com/ja-jp/services/devops/pipelines/ にアクセスし
|doxygen | doxygen を行う | [ci/azure-pipelines/template.job.doxygen.yml](ci/azure-pipelines/template.job.doxygen.yml) |
|checkEncoding | 文字コードのチェックを行う | [ci/azure-pipelines/template.job.checkEncoding.yml](ci/azure-pipelines/template.job.checkEncoding.yml) |
|script_check | python のコンパイルのチェックを行う | [ci/azure-pipelines/template.job.python-check.yml](ci/azure-pipelines/template.job.python-check.yml) |

## Azure Pipelines の TIPS

### step または JOB の実行条件

googletest でテストを実施するにあたって、googletest のテスト結果にかからわず、テスト結果の公開を行いたい。(参考: [#837](https://github.com/sakura-editor/sakura/pull/837) )

[Specify conditions](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml) で説明されているように
[condition](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml) を指定することで指定した JOB または step を
実行する条件を指定することができる。

以下の例では `succeededOrFailed()` を指定しているので、前段の step が成功しても、失敗しても実行される。(ただし JOB がキャンセルされたときには実行しない)

```
- task: CopyFiles@1
condition: succeededOrFailed()
displayName: Copy to ArtifactStagingDirectory
inputs:
contents: '**.zip'
targetFolder: $(Build.ArtifactStagingDirectory)
```


23 changes: 23 additions & 0 deletions ci/azure-pipelines/template.job.build-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,38 @@ jobs:
displayName: Unit test

# see https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-files?view=azure-devops&tabs=yaml
#
# "condition:" に関しては以下を参照
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml
#
# "succeededOrFailed()" に関しては以下を参照
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml#job-status-functions
#
- task: CopyFiles@1
condition: succeededOrFailed()
displayName: Copy to ArtifactStagingDirectory
inputs:
contents: '**.zip'
targetFolder: $(Build.ArtifactStagingDirectory)

# see https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=yaml
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
displayName: Publish ArtifactStagingDirectory
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: $(BuildPlatform)_$(Configuration)

# see https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=yaml
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/*-googletest-*.xml'
#searchFolder: '$(System.DefaultWorkingDirectory)' # Optional
#mergeTestResults: false # Optional
#failTaskOnFailedTests: false # Optional
#testRunTitle: # Optional
#buildPlatform: # Optional
#buildConfiguration: # Optional
#publishRunAttachments: true # Optional
4 changes: 2 additions & 2 deletions tests/run-tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ for /r %%i in (tests*.exe) do (
@echo %%i --gtest_list_tests
%%i --gtest_list_tests || set ERROR_RESULT=1

@echo %%i | "%FILTER_BAT%"
%%i | "%FILTER_BAT%" || set ERROR_RESULT=1
@echo %%i --gtest_output=xml:%%i-googletest-%platform%-%configuration%.xml ^| "%FILTER_BAT%"
%%i --gtest_output=xml:%%i-googletest-%platform%-%configuration%.xml | "%FILTER_BAT%" || set ERROR_RESULT=1
)
popd
popd
Expand Down