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

ENH Copy files that failed git diff to artifacts dir #22

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
13 changes: 13 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,24 @@ runs:
echo "git diff found modified files when it should not have:"
echo $GIT_DIFF
echo "sha1sum of files that are different:"
COPIED_COUNT=0
for FILEPATH in $(git diff --cached --name-only); do
if [[ -f $FILEPATH ]]; then
sha1sum $FILEPATH
# Only copy if the file is less than 10 megabytes to prevent malicous behaviour
# Only copy a max of 10 files, also to prevent malicious behaviour
MEGABYTES=$(ls -l --b=M "$DIST_DIR/$FILEPATH" | cut -d " " -f5 | sed "s/M//")
if (($MEGABYTES >= 10)); then
echo "File $FILEPATH is larger than 10 megabytes, not copying"
elif (($COPIED_COUNT >= 10)); then
echo "More than 10 files have been copied, not copying $FILEPATH"
Comment on lines +230 to +231

Choose a reason for hiding this comment

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

If the limit is 10, how would it ever copy more than 10 as the message suggests?

Copy link
Member

Choose a reason for hiding this comment

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

The message is slightly off - same with the MB thing - but it's just for debugging an intermittent problem we're having when the dist file built by CI doesn't match what we have locally. The main thing for this message is "too many files", not the actual number.

else
cp "$DIST_DIR/$FILEPATH" artifacts
COPIED_COUNT=$((COPIED_COUNT+1))
fi
fi
done
echo "Files that are different have been copied to artifacts directory"
exit 1
fi
fi
Expand Down
Loading