api_diff_report.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. name: API Diff Report
  2. on: [pull_request]
  3. concurrency:
  4. group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
  5. cancel-in-progress: true
  6. env:
  7. STAGE_PROGRESS: progress
  8. STAGE_END: end
  9. PR_API_OUTPUT: ci_outputs/pr_branch_api
  10. BASE_API_OUTPUT: ci_outputs/base_branch_api
  11. DIFF_REPORT_OUTPUT: ci_outputs/diff_report
  12. jobs:
  13. diff_report:
  14. runs-on: macos-latest
  15. steps:
  16. - name: Checkout PR branch
  17. uses: actions/checkout@v3
  18. with:
  19. fetch-depth: 2
  20. - name: Copy diff report tools
  21. run: cp -a scripts/api_diff_report/. ~/api_diff_report
  22. - id: get_changed_files
  23. name: Get changed file list
  24. run: |
  25. echo "file_list=$(git diff --name-only -r HEAD^1 HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT
  26. - name: Setup python
  27. uses: actions/setup-python@v4
  28. with:
  29. python-version: 3.7
  30. - name: Install Prerequisites
  31. run: ~/api_diff_report/prerequisite.sh
  32. - name: Clean Diff Report Comment in PR
  33. run: |
  34. python ~/api_diff_report/pr_commenter.py \
  35. --stage ${{ env.STAGE_PROGRESS }} \
  36. --token ${{github.token}} \
  37. --pr_number ${{github.event.pull_request.number}} \
  38. --commit $GITHUB_SHA \
  39. --run_id ${{github.run_id}}
  40. - name: Generate API files for PR branch
  41. run: |
  42. python ~/api_diff_report/api_info.py \
  43. --file_list ${{ steps.get_changed_files.outputs.file_list }} \
  44. --output_dir ${{ env.PR_API_OUTPUT }}
  45. - name: Checkout Base branch
  46. run: git checkout HEAD^
  47. - name: Generate API files for Base branch
  48. run: |
  49. python ~/api_diff_report/api_info.py \
  50. --file_list ${{ steps.get_changed_files.outputs.file_list }} \
  51. --output_dir ${{ env.BASE_API_OUTPUT }}
  52. - name: Generate API Diff Report
  53. run: |
  54. python ~/api_diff_report/api_diff_report.py \
  55. --pr_branch ${{ env.PR_API_OUTPUT }} \
  56. --base_branch ${{ env.BASE_API_OUTPUT }} \
  57. --output_dir ${{ env.DIFF_REPORT_OUTPUT }}
  58. - name: Update Diff Report Comment in PR
  59. run: |
  60. python ~/api_diff_report/pr_commenter.py \
  61. --stage ${{ env.STAGE_END }} \
  62. --report ${{ env.DIFF_REPORT_OUTPUT }} \
  63. --token ${{github.token}} \
  64. --pr_number ${{github.event.pull_request.number}} \
  65. --commit $GITHUB_SHA \
  66. --run_id ${{github.run_id}}
  67. - uses: actions/upload-artifact@v3
  68. if: ${{ !cancelled() }}
  69. with:
  70. name: api_info_and_report
  71. path: ci_outputs
  72. retention-days: 1