From 23a466f0a17b5f75d5c6aa50690b3dbbe9e90122 Mon Sep 17 00:00:00 2001 From: Cam McHenry Date: Mon, 18 Mar 2024 19:30:03 +0000 Subject: [PATCH 1/6] Improve check-dist output --- .github/workflows/check-dist.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 0a6e852c..a8b71125 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -15,6 +15,11 @@ on: paths-ignore: - '**.md' +env: + # A pipe-separated array of files to ignore when comparing the expected and actual dist/ directories, + # which are used as a regular expression filter in the `grep` command. + FILES_TO_IGNORE: 'index.js.map|sourcemap-register.js' + jobs: check-dist: runs-on: ubuntu-latest @@ -38,9 +43,12 @@ jobs: - name: Compare the expected and actual dist/ directories run: | - if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes after build. See status below:" - git diff + CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE") + if [ -n "$CHANGED_FILES" ]; then + echo "Detected uncommitted changes after build (see diff output below)." >&2 + echo "This indicates that the dist/ directory is out of sync with the checked-in index.js." >&2 + # Run `git diff` for each line/file in $CHANGED_FILES: + echo "$CHANGED_FILES" | xargs -I {} git diff --ignore-space-at-eol --text -- {} exit 1 fi id: diff From 831555bfab92caaf220f0cc7907347900e42408f Mon Sep 17 00:00:00 2001 From: Cam McHenry Date: Mon, 18 Mar 2024 19:33:29 +0000 Subject: [PATCH 2/6] Add help instructions --- .github/workflows/check-dist.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index a8b71125..87a0eac7 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -45,8 +45,9 @@ jobs: run: | CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE") if [ -n "$CHANGED_FILES" ]; then - echo "Detected uncommitted changes after build (see diff output below)." >&2 + echo "❗️ Detected uncommitted changes after build (see diff output below)." >&2 echo "This indicates that the dist/ directory is out of sync with the checked-in index.js." >&2 + echo "⭐️ If the changes below are expected, run 'npm run build:compile && npm run build:package' and commit the output files." >&2 # Run `git diff` for each line/file in $CHANGED_FILES: echo "$CHANGED_FILES" | xargs -I {} git diff --ignore-space-at-eol --text -- {} exit 1 From 3c0dc2fb2499d8f3e6dcb213654a0486d31355f3 Mon Sep 17 00:00:00 2001 From: Cam McHenry Date: Mon, 18 Mar 2024 19:40:17 +0000 Subject: [PATCH 3/6] Improve message --- .github/workflows/check-dist.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 87a0eac7..f65ec31b 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -45,9 +45,9 @@ jobs: run: | CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE") if [ -n "$CHANGED_FILES" ]; then - echo "❗️ Detected uncommitted changes after build (see diff output below)." >&2 - echo "This indicates that the dist/ directory is out of sync with the checked-in index.js." >&2 - echo "⭐️ If the changes below are expected, run 'npm run build:compile && npm run build:package' and commit the output files." >&2 + echo "\n❗️ Detected uncommitted changes after build (see diff output below)." >&2 + echo "This indicates that the dist/ directory is out of sync with the checked-in index.js.\n" >&2 + echo "⭐️ If the changes below are expected, run 'npm run build:compile && npm run build:package' and commit the output files.\n" >&2 # Run `git diff` for each line/file in $CHANGED_FILES: echo "$CHANGED_FILES" | xargs -I {} git diff --ignore-space-at-eol --text -- {} exit 1 From 032c0af29a414db4b81b82de82cf5208944fa006 Mon Sep 17 00:00:00 2001 From: Cam McHenry Date: Mon, 18 Mar 2024 19:45:59 +0000 Subject: [PATCH 4/6] Remove blank lines --- .github/workflows/check-dist.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index f65ec31b..7c025838 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -43,7 +43,9 @@ jobs: - name: Compare the expected and actual dist/ directories run: | - CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE") + # Get a list of files that are different between the checked-in dist/ directory and the generated dist/ directory, + # then trim the list to remove any leading or trailing whitespace. + CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') if [ -n "$CHANGED_FILES" ]; then echo "\n❗️ Detected uncommitted changes after build (see diff output below)." >&2 echo "This indicates that the dist/ directory is out of sync with the checked-in index.js.\n" >&2 From 34dcf6150685f855bdda75fe64d7650126e62707 Mon Sep 17 00:00:00 2001 From: Cam McHenry Date: Mon, 18 Mar 2024 19:49:02 +0000 Subject: [PATCH 5/6] Add success message and remove newlines --- .github/workflows/check-dist.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 7c025838..58767084 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -47,12 +47,14 @@ jobs: # then trim the list to remove any leading or trailing whitespace. CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') if [ -n "$CHANGED_FILES" ]; then - echo "\n❗️ Detected uncommitted changes after build (see diff output below)." >&2 + echo "❗️ Detected uncommitted changes after build (see diff output below)." >&2 echo "This indicates that the dist/ directory is out of sync with the checked-in index.js.\n" >&2 - echo "⭐️ If the changes below are expected, run 'npm run build:compile && npm run build:package' and commit the output files.\n" >&2 + echo "⭐️ If the changes below are expected, run 'npm run build:compile && npm run build:package' and commit the output files." >&2 # Run `git diff` for each line/file in $CHANGED_FILES: echo "$CHANGED_FILES" | xargs -I {} git diff --ignore-space-at-eol --text -- {} exit 1 + else + echo "✅ No uncommitted changes detected after build." fi id: diff From 7df57347bd0eab10a9c71b60f7c6d9c1cb1179a2 Mon Sep 17 00:00:00 2001 From: Cam McHenry Date: Mon, 18 Mar 2024 19:52:39 +0000 Subject: [PATCH 6/6] Remove stray newline --- .github/workflows/check-dist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 58767084..5d1f26f4 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -48,7 +48,7 @@ jobs: CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') if [ -n "$CHANGED_FILES" ]; then echo "❗️ Detected uncommitted changes after build (see diff output below)." >&2 - echo "This indicates that the dist/ directory is out of sync with the checked-in index.js.\n" >&2 + echo "This indicates that the dist/ directory is out of sync with the checked-in index.js." >&2 echo "⭐️ If the changes below are expected, run 'npm run build:compile && npm run build:package' and commit the output files." >&2 # Run `git diff` for each line/file in $CHANGED_FILES: echo "$CHANGED_FILES" | xargs -I {} git diff --ignore-space-at-eol --text -- {}