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

chore: fix reset hard in assert-changed-files (#29328) #29677

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ jobs:
shell: powershell.exe
steps:
- checkout
- run:
command: ./scripts/assert-changed-files.sh "packages/*|(e2e|integration)-tests/*|.circleci/*|yarn.lock"
shell: bash.exe
# Restoring cache takes as long as installing node modules, so skipping
# - restore_cache:
# keys:
Expand All @@ -482,9 +485,6 @@ jobs:
# paths:
# - C:\Users\circleci\AppData\Local\Yarn\Cache
# key: yarn-packages-v2-{{ checksum "yarn.lock" }}
- run:
command: ./scripts/assert-changed-files.sh "packages/*|(e2e|integration)-tests/*|.circleci/*"
shell: bash.exe
- run: yarn npm-run-all -s check-versions "lerna-prepare --concurrency=4 --stream"
- run:
name: "Run Tests"
Expand Down
12 changes: 10 additions & 2 deletions scripts/assert-changed-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ if [ "$IS_CI" = true ]; then
if [ $? -ne 0 ]; then
echo "Branch has conflicts with master, rolling back test."
git merge --abort

if [ $? -ne 0]; then
# seems like we can't abort merge - script doesn't really handle that, we should fail this step because something is wonky
echo "Something went wrong, we could not abort our merge command. Please re-run the test."
exit 1
fi
fi

git config --local --unset user.name
Expand All @@ -23,8 +29,10 @@ fi

FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r "$CIRCLE_BRANCH" origin/master | grep -E "$GREP_PATTERN" -c)"

# reset to previous state
git reset --hard HEAD@{1}
if [ "$IS_CI" = true ]; then
# reset to previous state
git reset --hard $CIRCLE_SHA1
fi

if [ "$FILES_COUNT" -eq 0 ]; then
echo "0 files matching '$GREP_PATTERN'; exiting and marking successful."
Expand Down