Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve output of check-dist workflow #521

Merged
merged 6 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,10 +43,18 @@ 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
# 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 "❗️ 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
else
echo "✅ No uncommitted changes detected after build."
fi
id: diff

Expand Down
Loading