api_diff_report.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: API Diff Report
  2. on: [pull_request, workflow_dispatch]
  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. env:
  16. FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
  17. steps:
  18. - name: Checkout PR branch
  19. uses: actions/checkout@v4
  20. with:
  21. fetch-depth: 2
  22. - name: Copy diff report tools
  23. run: cp -a scripts/api_diff_report/. ~/api_diff_report
  24. - id: get_changed_files
  25. name: Get changed file list
  26. run: |
  27. echo "file_list=$(git diff --name-only -r HEAD^1 HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT
  28. - name: Setup python
  29. uses: actions/setup-python@v5
  30. with:
  31. python-version: '3.11'
  32. - name: Install Prerequisites
  33. run: ~/api_diff_report/prerequisite.sh
  34. - name: Clean Diff Report Comment in PR
  35. run: |
  36. python ~/api_diff_report/pr_commenter.py \
  37. --stage ${{ env.STAGE_PROGRESS }} \
  38. --token ${{github.token}} \
  39. --pr_number ${{github.event.pull_request.number}} \
  40. --commit $GITHUB_SHA \
  41. --run_id ${{github.run_id}}
  42. - name: Generate API files for PR branch
  43. run: |
  44. python ~/api_diff_report/api_info.py \
  45. --file_list ${{ steps.get_changed_files.outputs.file_list }} \
  46. --output_dir ${{ env.PR_API_OUTPUT }}
  47. - name: Checkout Base branch
  48. run: git checkout HEAD^
  49. - name: Generate API files for Base branch
  50. run: |
  51. python ~/api_diff_report/api_info.py \
  52. --file_list ${{ steps.get_changed_files.outputs.file_list }} \
  53. --output_dir ${{ env.BASE_API_OUTPUT }}
  54. - name: Generate API Diff Report
  55. run: |
  56. python ~/api_diff_report/api_diff_report.py \
  57. --pr_branch ${{ env.PR_API_OUTPUT }} \
  58. --base_branch ${{ env.BASE_API_OUTPUT }} \
  59. --output_dir ${{ env.DIFF_REPORT_OUTPUT }}
  60. - name: Update Diff Report Comment in PR
  61. run: |
  62. python ~/api_diff_report/pr_commenter.py \
  63. --stage ${{ env.STAGE_END }} \
  64. --report ${{ env.DIFF_REPORT_OUTPUT }} \
  65. --token ${{github.token}} \
  66. --pr_number ${{github.event.pull_request.number}} \
  67. --commit $GITHUB_SHA \
  68. --run_id ${{github.run_id}}
  69. - uses: actions/upload-artifact@v4
  70. if: ${{ !cancelled() }}
  71. with:
  72. name: api_info_and_report
  73. path: ci_outputs
  74. retention-days: 1