12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- name: Compare JS output
- on:
- pull_request_target:
- # We want all branches so we configure types to be the GH default again
- types: [opened, synchronize, reopened]
- paths:
- - 'packages/@uppy/*/src/**/*'
- - '.github/workflows/output-watcher.yml'
- permissions:
- pull-requests: write
- env:
- YARN_ENABLE_GLOBAL_CACHE: false
- DIFF_BUILDER: true
- jobs:
- compare_diff:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout sources
- uses: actions/checkout@v3
- with:
- fetch-depth: 2
- ref: refs/pull/${{ github.event.pull_request.number }}/merge
- - run: git reset HEAD^ --hard
- - name: Get yarn cache directory path
- id: yarn-cache-dir-path
- run:
- echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- - uses: actions/cache@v3
- id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- with:
- path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- restore-keys: |
- ${{ runner.os }}-yarn-
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: lts/*
- - name: Install dependencies
- run:
- corepack yarn workspaces focus $(corepack yarn workspaces list --json
- | jq -r .name | awk '/^@uppy-example/{ next } { if ($0!="uppy.io")
- print $0 }')
- env:
- # https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
- CYPRESS_INSTALL_BINARY: 0
- - run: corepack yarn build:lib
- - name: Store output file
- run: tar cf /tmp/previousVersion.tar packages/@uppy/*/lib
- - name: Fetch source from the PR
- run: git checkout FETCH_HEAD -- packages
- - run: corepack yarn build:lib
- - name: Store output file
- run: tar cf /tmp/newVersion.tar packages/@uppy/*/lib
- - name: Setup git
- run: |
- git config --global user.email "actions@github.com"
- git config --global user.name "GitHub Actions"
- git init /tmp/uppy
- echo '*.map' > /tmp/uppy/.gitignore
- - name: Extract previous version
- run: cd /tmp/uppy && tar xf /tmp/previousVersion.tar
- - name: Commit previous version
- run: cd /tmp/uppy && git add -A . && git commit -m 'previous version'
- - name: Extract new version
- run: cd /tmp/uppy && tar xf /tmp/newVersion.tar
- - name: Build diff
- id: diff
- run: |
- EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
- echo "OUTPUT_DIFF<<$EOF" >> "$GITHUB_OUTPUT"
- cd /tmp/uppy && git --no-pager diff --ignore-blank-lines >> "$GITHUB_OUTPUT"
- echo "$EOF" >> "$GITHUB_OUTPUT"
- - name: Add/update comment
- uses: marocchino/sticky-pull-request-comment@v2
- with:
- message: |
- <details><summary>Diff output files</summary>
- ```diff
- ${{ steps.diff.outputs.OUTPUT_DIFF || 'No diff' }}
- ```
- </details>
|