Skip to content

Commit

Permalink
added script to travis build to run tab exterminator script on PRs an…
Browse files Browse the repository at this point in the history
…d push changes
  • Loading branch information
harpolea committed Feb 11, 2020
1 parent 137acb0 commit 58771cb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ matrix:
script:
- cd $TRAVIS_BUILD_DIR/Exec/science/flame_wave; scan-build -enable-checker alpha.cplusplus.IteratorRange -enable-checker alpha.security.ArrayBoundV2 -enable-checker security.FloatLoopCounter -enable-checker security.insecureAPI.UncheckedReturn make -j 2 USE_OMP=FALSE USE_MPI=FALSE USE_CUDA=FALSE DEBUG=TRUE 2>&1 | tee clang_analysis.txt
- python3 $TRAVIS_BUILD_DIR/Util/code_checker/clang_static_analysis.py clang_analysis.txt

- name: "tab exterminator"
if: type = pull_request OR type = api
script:
- ./Util/code_checker/pr_tab_remover.sh
2 changes: 1 addition & 1 deletion Util/code_checker/clang_static_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def process_analysis(filename):
print('Static analysis warnings from Castro:\n-------------------------------------\n')
print('\n'.join(bugs))
print(f'{n_warnings} bugs found')
return -1
sys.exit(1)

return True

Expand Down
43 changes: 43 additions & 0 deletions Util/code_checker/pr_tab_remover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Save some useful information
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}

# Add rsa keys to the ssh agent to push to GitHub
gpg --output ../id_maestro_rsa --batch --passphrase $DECRYPT_GITHUB_AUTH --decrypt id_maestro_rsa.enc
chmod 600 ../id_maestro_rsa
eval `ssh-agent -s`
ssh-add ../id_maestro_rsa
#ls ../id_rsa_travis

echo "Running tab exterminator script"

cd $TRAVIS_BUILD_DIR/Util/code_checker
./tab_exterminator.sh

# Now let's go have some fun with the cloned repo
cd $TRAVIS_BUILD_DIR
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"

echo "doing git add/commit/push"

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add --all

# Exit if there are no docs changes
if git diff --staged --quiet; then
echo "exiting with no changes"
exit 0
fi

# Otherwise, commit and push
git commit -m "Tabs have been converted to spaces by tab_exterminator.sh"
git push $SSH_REPO $TRAVIS_PULL_REQUEST_BRANCH
cd

# Kill the ssh-agent
ssh-agent -k

0 comments on commit 58771cb

Please sign in to comment.