output-watcher.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. name: Compare JS output
  2. on:
  3. pull_request_target:
  4. # We want all branches so we configure types to be the GH default again
  5. types: [opened, synchronize, reopened]
  6. paths:
  7. - 'packages/@uppy/*/src/**/*'
  8. - '.github/workflows/output-watcher.yml'
  9. permissions:
  10. pull-requests: write
  11. env:
  12. YARN_ENABLE_GLOBAL_CACHE: false
  13. DIFF_BUILDER: true
  14. jobs:
  15. compare_diff:
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Checkout sources
  19. uses: actions/checkout@v3
  20. with:
  21. fetch-depth: 2
  22. ref: refs/pull/${{ github.event.pull_request.number }}/merge
  23. - run: git reset HEAD^ --hard
  24. - name: Get yarn cache directory path
  25. id: yarn-cache-dir-path
  26. run:
  27. echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
  28. - uses: actions/cache@v3
  29. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  30. with:
  31. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  32. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  33. restore-keys: |
  34. ${{ runner.os }}-yarn-
  35. - name: Install Node.js
  36. uses: actions/setup-node@v3
  37. with:
  38. node-version: lts/*
  39. - name: Install dependencies
  40. run:
  41. corepack yarn workspaces focus $(corepack yarn workspaces list --json
  42. | jq -r .name | awk '/^@uppy-example/{ next } { if ($0!="uppy.io")
  43. print $0 }')
  44. env:
  45. # https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
  46. CYPRESS_INSTALL_BINARY: 0
  47. - run: corepack yarn build:lib
  48. - name: Store output file
  49. run: tar cf /tmp/previousVersion.tar packages/@uppy/*/lib
  50. - name: Fetch source from the PR
  51. run: git checkout FETCH_HEAD -- packages
  52. - run: corepack yarn build:lib
  53. - name: Store output file
  54. run: tar cf /tmp/newVersion.tar packages/@uppy/*/lib
  55. - name: Setup git
  56. run: |
  57. git config --global user.email "actions@github.com"
  58. git config --global user.name "GitHub Actions"
  59. git init /tmp/uppy
  60. echo '*.map' > /tmp/uppy/.gitignore
  61. - name: Extract previous version
  62. run: cd /tmp/uppy && tar xf /tmp/previousVersion.tar
  63. - name: Commit previous version
  64. run: cd /tmp/uppy && git add -A . && git commit -m 'previous version'
  65. - name: Extract new version
  66. run: cd /tmp/uppy && tar xf /tmp/newVersion.tar
  67. - name: Build diff
  68. id: diff
  69. run: |
  70. EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
  71. echo "OUTPUT_DIFF<<$EOF" >> "$GITHUB_OUTPUT"
  72. cd /tmp/uppy && git --no-pager diff --ignore-blank-lines >> "$GITHUB_OUTPUT"
  73. echo "$EOF" >> "$GITHUB_OUTPUT"
  74. - name: Add/update comment
  75. uses: marocchino/sticky-pull-request-comment@v2
  76. with:
  77. message: |
  78. <details><summary>Diff output files</summary>
  79. ```diff
  80. ${{ steps.diff.outputs.OUTPUT_DIFF || 'No diff' }}
  81. ```
  82. </details>