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

fix(ci): whitenoise lint failed when pull request #1904

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Changes from 2 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
3 changes: 2 additions & 1 deletion tools/src/whitenoise.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
TRAILING_WHITESPACE=0
# only check changed docs in pr
for file in $(git diff --cached --name-only --diff-filter=ACRMTU $GITHUB_BASE_REF | grep "\.md"); do
git fetch
for file in $(git diff --cached --name-only --diff-filter=ACRMTU origin/$GITHUB_BASE_REF| grep "\.md"); do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking out loud, why isn't git diff --name-only good enough here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is that the GitHub Actions environment does not have the branch information for Git, which causes an error when using git diff to compare the differences. To resolve this, I simply added a git fetch command to retrieve the branch information from the remote repository. For further debugging information, you can refer to this link: https://github.com/zaunist/gateway/actions/runs/6262614026/job/17005194717.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zaunist im suggesting removing the older command and replacing with something simpler git diff --name-only which doesnt require branch info, do you see any issue with this approach ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arkodg If we don't provide branch information, how can we compare the differences between the fork and main branches? I'm not quite understanding this point. Could you provide an example, please?

if grep -r '[[:blank:]]$' "$1" > /dev/null; then
echo "trailing whitespace: ${1}" >&2
ERRORS=yes
Expand Down