action.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. name: Compare gas costs
  2. description: Compare gas costs between branches
  3. inputs:
  4. token:
  5. description: GitHub token, required to access GitHub API
  6. required: true
  7. report:
  8. description: Path to the report to compare
  9. required: false
  10. default: gasReporterOutput.json
  11. out_report:
  12. description: Path to save the output report
  13. required: false
  14. default: ${{ github.ref_name }}.gasreport.json
  15. ref_report:
  16. description: Path to the reference report for comparison
  17. required: false
  18. default: ${{ github.base_ref }}.gasreport.json
  19. runs:
  20. using: composite
  21. steps:
  22. - name: Download reference report
  23. if: github.event_name == 'pull_request'
  24. run: |
  25. RUN_ID=`gh run list --repo ${{ github.repository }} --branch ${{ github.base_ref }} --workflow ${{ github.workflow }} --limit 100 --json 'conclusion,databaseId,event' --jq 'map(select(.conclusion=="success" and .event!="pull_request"))[0].databaseId'`
  26. gh run download ${RUN_ID} --repo ${{ github.repository }} -n gasreport
  27. env:
  28. GITHUB_TOKEN: ${{ inputs.token }}
  29. shell: bash
  30. continue-on-error: true
  31. id: reference
  32. - name: Compare reports
  33. if: steps.reference.outcome == 'success' && github.event_name == 'pull_request'
  34. run: |
  35. node scripts/checks/compareGasReports.js ${{ inputs.report }} ${{ inputs.ref_report }} >> $GITHUB_STEP_SUMMARY
  36. env:
  37. STYLE: markdown
  38. shell: bash
  39. - name: Rename report for upload
  40. if: github.event_name != 'pull_request'
  41. run: |
  42. mv ${{ inputs.report }} ${{ inputs.out_report }}
  43. shell: bash
  44. - name: Save report
  45. if: github.event_name != 'pull_request'
  46. uses: actions/upload-artifact@v4
  47. with:
  48. name: gasreport
  49. overwrite: true
  50. path: ${{ inputs.out_report }}