windows-build-and-test.yml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. name: Windows Build and Test
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request:
  7. types: [opened, synchronize, reopened]
  8. jobs:
  9. build:
  10. name: Build
  11. runs-on: windows-2019
  12. env:
  13. CRAFT_TARGET: windows-msvc2019_64-cl
  14. COBERTURA_COVERAGE_FILE: ${{ github.workspace }}\cobertura_coverage\coverage.xml
  15. CRAFT_MASTER_LOCATION: ${{ github.workspace }}\CraftMaster
  16. CRAFT_MASTER_CONFIG: ${{ github.workspace }}\craftmaster.ini
  17. steps:
  18. - uses: actions/checkout@v2
  19. with:
  20. fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
  21. - name: Install Craft Master with Nextcloud Client Deps
  22. shell: pwsh
  23. run: |
  24. & cmd /C "git clone -q --depth=1 https://invent.kde.org/packaging/craftmaster.git ${{ env.CRAFT_MASTER_LOCATION }} 2>&1"
  25. function craft() {
  26. python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args
  27. if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
  28. }
  29. craft --add-blueprint-repository [git]https://github.com/nextcloud/desktop-client-blueprints.git
  30. craft craft
  31. craft --install-deps nextcloud-client
  32. - name: Cache Install OpenCppCoverage
  33. id: cache-install-opencppcoverage
  34. uses: actions/cache@v3
  35. with:
  36. path: C:\Program Files\OpenCppCoverage
  37. key: ${{ runner.os }}-cache-install-opencppcoverage
  38. - name: Install OpenCppCoverage
  39. if: steps.cache-install-opencppcoverage.outputs.cache-hit != 'true'
  40. shell: pwsh
  41. run: |
  42. choco install opencppcoverage
  43. - name: Setup PATH
  44. shell: pwsh
  45. run: |
  46. echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  47. echo "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  48. - name: Compile
  49. shell: pwsh
  50. run: |
  51. function craft() {
  52. python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args
  53. if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
  54. }
  55. craft --src-dir ${{ github.workspace }} nextcloud-client
  56. - name: Run tests
  57. shell: pwsh
  58. run: |
  59. function runTestsAndCreateCoverage() {
  60. $buildFolder = "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\build\nextcloud-client\work\build"
  61. cd $buildFolder
  62. $binFolder = "$buildFolder\bin"
  63. & OpenCppCoverage.exe --quiet --sources ${{ github.workspace }} --modules $binFolder\*.dll* --export_type cobertura:${{ env.COBERTURA_COVERAGE_FILE }} --cover_children -- ctest --output-on-failure --timeout 300
  64. }
  65. runTestsAndCreateCoverage
  66. - name: Upload coverage to Codecov
  67. uses: codecov/codecov-action@v3
  68. with:
  69. token: ${{ secrets.CODECOV_TOKEN }}
  70. directory: ${{ github.workspace }}\cobertura_coverage
  71. fail_ci_if_error: true