Skip to content

Commit

Permalink
meta: improve output watcher diff (#4876)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Jan 19, 2024
1 parent f43ff47 commit 34ce4df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/output-watcher.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
name: Compare JS output

on:
pull_request:
# We want all branches so we configure types to be the GH default again
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/output-watcher.yml'
- 'bin/build-lib.js'
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
Expand Down Expand Up @@ -62,18 +67,26 @@ jobs:
git config --global user.name "GitHub Actions"
git init /tmp/uppy
echo '*.map' > /tmp/uppy/.gitignore
- name: Install dformat
run: |
curl -fsSL https://dprint.dev/install.sh | sh
cd /tmp/uppy && echo '{"plugins":[]}' > dprint.json && "$HOME/.dprint/bin/dprint" config add typescript
- name: Extract previous version
run: cd /tmp/uppy && tar xf /tmp/previousVersion.tar
- name: Format previous output code
run: cd /tmp/uppy && "$HOME/.dprint/bin/dprint" fmt **/*.js
- 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: Format new output code
run: cd /tmp/uppy && "$HOME/.dprint/bin/dprint" fmt **/*.js
- 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-all-space -U0 | grep -Ev "^\+\s*$" >> "$GITHUB_OUTPUT"
cd /tmp/uppy && git --no-pager diff >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Add/update comment
uses: marocchino/sticky-pull-request-comment@v2
Expand Down
4 changes: 1 addition & 3 deletions bin/build-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ async function buildLib () {
const { code, map } = await babel.transformFileAsync(file, {
sourceMaps: true,
plugins,
// compact and no comments because https://github.com/transloadit/uppy/pull/4868#issuecomment-1897717779
// no comments because https://github.com/transloadit/uppy/pull/4868#issuecomment-1897717779
comments: !process.env.DIFF_BUILDER,
compact: !!process.env.DIFF_BUILDER,
retainLines: !!process.env.DIFF_BUILDER,
})
const [{ default: chalk }] = await Promise.all([
import('chalk'),
Expand Down

0 comments on commit 34ce4df

Please sign in to comment.