ci-compat.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. name: ABI Compatibility
  2. on:
  3. pull_request_target:
  4. permissions: {}
  5. jobs:
  6. abi-head:
  7. name: ABI - HEAD
  8. runs-on: ubuntu-latest
  9. permissions: read-all
  10. steps:
  11. - name: Checkout repository
  12. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  13. with:
  14. ref: ${{ github.event.pull_request.head.sha }}
  15. repository: ${{ github.event.pull_request.head.repo.full_name }}
  16. - name: Setup .NET
  17. uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
  18. with:
  19. dotnet-version: '9.0.x'
  20. - name: Build
  21. run: |
  22. dotnet build Jellyfin.Server -o ./out
  23. - name: Upload Head
  24. uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  25. with:
  26. name: abi-head
  27. retention-days: 14
  28. if-no-files-found: error
  29. path: out/
  30. abi-base:
  31. name: ABI - BASE
  32. if: ${{ github.base_ref != '' }}
  33. runs-on: ubuntu-latest
  34. permissions: read-all
  35. steps:
  36. - name: Checkout repository
  37. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  38. with:
  39. ref: ${{ github.event.pull_request.head.sha }}
  40. repository: ${{ github.event.pull_request.head.repo.full_name }}
  41. fetch-depth: 0
  42. - name: Setup .NET
  43. uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
  44. with:
  45. dotnet-version: '9.0.x'
  46. - name: Checkout common ancestor
  47. env:
  48. HEAD_REF: ${{ github.head_ref }}
  49. run: |
  50. git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}
  51. git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules upstream +refs/heads/*:refs/remotes/upstream/* +refs/tags/*:refs/tags/*
  52. ANCESTOR_REF=$(git merge-base upstream/${{ github.base_ref }} origin/$HEAD_REF)
  53. git checkout --progress --force $ANCESTOR_REF
  54. - name: Build
  55. run: |
  56. dotnet build Jellyfin.Server -o ./out
  57. - name: Upload Head
  58. uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  59. with:
  60. name: abi-base
  61. retention-days: 14
  62. if-no-files-found: error
  63. path: out/
  64. abi-diff:
  65. permissions:
  66. pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
  67. name: ABI - Difference
  68. if: ${{ github.event_name == 'pull_request_target' }}
  69. runs-on: ubuntu-latest
  70. needs:
  71. - abi-head
  72. - abi-base
  73. steps:
  74. - name: Download abi-head
  75. uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  76. with:
  77. name: abi-head
  78. path: abi-head
  79. - name: Download abi-base
  80. uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  81. with:
  82. name: abi-base
  83. path: abi-base
  84. - name: Setup ApiCompat
  85. run: |
  86. dotnet tool install --global Microsoft.DotNet.ApiCompat.Tool
  87. - name: Run ApiCompat
  88. id: diff
  89. run: |
  90. {
  91. echo 'body<<EOF'
  92. for file in Jellyfin.Data.dll MediaBrowser.Common.dll MediaBrowser.Controller.dll MediaBrowser.Model.dll Emby.Naming.dll Jellyfin.Extensions.dll Jellyfin.MediaEncoding.Keyframes.dll Jellyfin.Database.Implementations.dll; do
  93. COMPAT_OUTPUT="$( { apicompat --left ./abi-base/${file} --right ./abi-head/${file}; } 2>&1 )"
  94. if [ "APICompat ran successfully without finding any breaking changes." != "${COMPAT_OUTPUT}" ]; then
  95. printf "\n${file}\n${COMPAT_OUTPUT}\n"
  96. fi
  97. done
  98. echo EOF
  99. } >> $GITHUB_OUTPUT
  100. - name: Find difference comment
  101. uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
  102. id: find-comment
  103. with:
  104. issue-number: ${{ github.event.pull_request.number }}
  105. direction: last
  106. body-includes: abi-diff-workflow-comment
  107. - name: Reply or edit difference comment (changed)
  108. uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
  109. if: ${{ steps.diff.outputs.body != '' }}
  110. with:
  111. issue-number: ${{ github.event.pull_request.number }}
  112. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  113. edit-mode: replace
  114. token: ${{ secrets.JF_BOT_TOKEN }}
  115. body: |
  116. <!--abi-diff-workflow-comment-->
  117. <details>
  118. <summary>ABI Difference</summary>
  119. ```
  120. ${{ steps.diff.outputs.body }}
  121. ```
  122. </details>
  123. - name: Reply or edit difference comment (unchanged)
  124. uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
  125. if: ${{ steps.diff.outputs.body == '' && steps.find-comment.outputs.comment-id != '' }}
  126. with:
  127. issue-number: ${{ github.event.pull_request.number }}
  128. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  129. edit-mode: replace
  130. token: ${{ secrets.JF_BOT_TOKEN }}
  131. body: |
  132. <!--abi-diff-workflow-comment-->
  133. <details>
  134. <summary>ABI Difference</summary>
  135. No changes to the ABI found. See history of this comment for previous changes.
  136. </details>