Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up CI bash scripts, add docs/STYLE_GUIDE.md
- Loading branch information
Showing
6 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Style Guide | ||
|
||
The majority of our style recommendations are automatically enforced via our | ||
automated linters. This document has guidelines that are less easy to lint for. | ||
|
||
## Shell scripts | ||
|
||
Shell scripts are OK for small tasks or wrappers, but prefer to use Python for | ||
anything with a hint of complexity or in general. | ||
|
||
Shell scripts should be written against bash, starting with this shebang: | ||
``` | ||
#!/usr/bin/env bash | ||
``` | ||
|
||
Note that the version of bash available on OS X by default is quite old, so be | ||
careful when using new features. | ||
|
||
Scripts should enable a few options at the top for robustness: | ||
``` | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
``` | ||
|
||
Quote all variables, using the full form: `"${SOME_VARIABLE}"`. | ||
|
||
Use `"$(some-command)"` instead of backticks for command substitution. Note | ||
that these should be quoted as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
#!/bin/bash | ||
diff=$(git diff -- */*/Cargo.lock) | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
diff="$(git diff -- */*/Cargo.lock)" | ||
echo "$diff" | ||
[[ ! $diff ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
# Retries a given command until it passes | ||
# Run as `retry.sh N command args...` | ||
# where `N` is the maximum number of tries, and `command args...` is the | ||
# command to run, with arguments | ||
|
||
n=$1 | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
n="$1" | ||
shift; # this removes the first argument from $@ | ||
for i in `seq $n`; do | ||
for i in $(seq $n); do | ||
echo "====== RUN NUMBER: $i ======"; | ||
if $@ # run command, check if exit code is zero | ||
then | ||
exit 0 # command passed, all is well | ||
fi | ||
# Run command and exit success if return code is 0, else ignore it | ||
"$@" && exit 0 || true | ||
done | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters