Explorar o código

meta: improve output watcher diff (#4876)

Antoine du Hamel hai 1 ano
pai
achega
34ce4dfe7a
Modificáronse 2 ficheiros con 16 adicións e 5 borrados
  1. 15 2
      .github/workflows/output-watcher.yml
  2. 1 3
      bin/build-lib.js

+ 15 - 2
.github/workflows/output-watcher.yml

@@ -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
@@ -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

+ 1 - 3
bin/build-lib.js

@@ -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'),