Skip to content

Commit

Permalink
meta: add output-watcher GHA to help check output diff
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 16, 2024
1 parent 4753a05 commit 366da0a
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions .github/workflows/output-watcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
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:
find packages/@uppy -path '*/lib' -type d -exec tar cf
/tmp/newVersion.tar -C {} . \;
- name: Upload artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: newVersion.tar
path: /tmp/newVersion.tar

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:
find packages/@uppy -path '*/lib' -type d -exec tar cf
/tmp/previousVersion.tar -C {} . \;
- name: Upload artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: previousVersion.tar
path: /tmp/previousVersion.tar

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
- name: Extract previous version
run: cd /tmp/uppy && tar xf /tmp/previousVersion.tar/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/newVersion.tar
- 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

0 comments on commit 366da0a

Please sign in to comment.