-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta: add
output-watcher
GHA to help check output diff
- Loading branch information
Showing
1 changed file
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
name: Compare JS output | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
# We want all branches so we configure types to be the GH default again | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- 'packages/@uppy/*/src/**/*' | ||
- 'bin/*' | ||
- '.github/workflows/output-watcher.yml' | ||
|
||
env: | ||
YARN_ENABLE_GLOBAL_CACHE: false | ||
|
||
jobs: | ||
build_new_version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
- 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: ${{matrix.node-version}} | ||
- 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 czf /tmp/newVersion.tar.gz packages/@uppy/*/lib | ||
- name: Upload artifact | ||
if: success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: newVersion.tar.gz | ||
path: /tmp/newVersion.tar.gz | ||
retention-days: 5 | ||
|
||
build_previous_version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
- 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: ${{matrix.node-version}} | ||
- 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 czf /tmp/previousVersion.tar.gz packages/@uppy/*/lib | ||
- name: Upload artifact | ||
if: success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: previousVersion.tar.gz | ||
path: /tmp/previousVersion.tar.gz | ||
retention-days: 1 | ||
|
||
compare: | ||
needs: [build_new_version, build_previous_version] | ||
name: Compare output files for both versions | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download tarballs | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: /tmp/ | ||
- 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 xzf | ||
/tmp/previousVersion.tar.gz/previousVersion.tar.gz | ||
- 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 xzf /tmp/newVersion.tar.gz/newVersion.tar.gz | ||
- name: Commit new version | ||
run: | ||
cd /tmp/uppy && git add -A . && git commit -m 'new version' | ||
--allow-empty | ||
- name: Show diff | ||
run: cd /tmp/uppy && git --no-pager diff HEAD^..HEAD | ||
- run: cd /tmp/uppy && git format-patch HEAD^ -o /tmp/patch | ||
- name: Upload artifact | ||
if: success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: diff | ||
path: /tmp/patch |