Skip to content

Commit

Permalink
chore: fix reset hard in assert-changed-files (#29328) (#29677)
Browse files Browse the repository at this point in the history
* reset only when CI

* update circle

* fail when aborts errors

(cherry picked from commit 79518c4)

Co-authored-by: Ward Peeters <[email protected]>
  • Loading branch information
ascorbic and wardpeet authored Feb 22, 2021
1 parent be9d9f9 commit 255b565
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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

0 comments on commit 255b565

Please sign in to comment.