windows-build-and-test.yml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. - uses: actions/setup-python@v1
  22. with:
  23. python-version: '3.8'
  24. - name: Install Craft Master with Nextcloud Client Deps
  25. shell: pwsh
  26. run: |
  27. & cmd /C "git clone -q --depth=1 https://invent.kde.org/packaging/craftmaster.git ${{ env.CRAFT_MASTER_LOCATION }} 2>&1"
  28. function craft() {
  29. python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args
  30. if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
  31. }
  32. craft --add-blueprint-repository [git]https://github.com/nextcloud/desktop-client-blueprints.git
  33. craft craft
  34. craft --install-deps nextcloud-client
  35. - name: Cache Install OpenCppCoverage
  36. id: cache-install-opencppcoverage
  37. uses: actions/cache@v3
  38. with:
  39. path: C:\Program Files\OpenCppCoverage
  40. key: ${{ runner.os }}-cache-install-opencppcoverage
  41. - name: Install OpenCppCoverage
  42. if: steps.cache-install-opencppcoverage.outputs.cache-hit != 'true'
  43. shell: pwsh
  44. run: |
  45. choco install opencppcoverage
  46. - name: Setup PATH
  47. shell: pwsh
  48. run: |
  49. echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  50. echo "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  51. - name: Compile
  52. shell: pwsh
  53. run: |
  54. function craft() {
  55. python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args
  56. if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
  57. }
  58. craft --src-dir ${{ github.workspace }} nextcloud-client
  59. - name: Run tests
  60. shell: pwsh
  61. run: |
  62. function runTestsAndCreateCoverage() {
  63. $buildFolder = "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\build\nextcloud-client\work\build"
  64. cd $buildFolder
  65. $binFolder = "$buildFolder\bin"
  66. & OpenCppCoverage.exe --optimized_build --quiet --sources ${{ github.workspace }} --modules $binFolder\*.dll* --export_type cobertura:${{ env.COBERTURA_COVERAGE_FILE }} --cover_children -- ctest --output-on-failure --timeout 300
  67. }
  68. runTestsAndCreateCoverage
  69. - name: Upload coverage to Codecov
  70. uses: codecov/codecov-action@v3
  71. with:
  72. token: ${{ secrets.CODECOV_TOKEN }}
  73. directory: ${{ github.workspace }}\cobertura_coverage
  74. fail_ci_if_error: true