Skip to content

Commit

Permalink
ci: add shellcheck gh action; fix fatal shellcheck errors
Browse files Browse the repository at this point in the history
This commit made with the assistance of github copilot

Signed-off-by: Morgan Rockett <morgan.rockett@tufts.edu>
  • Loading branch information
rockett-m committed Aug 22, 2024
1 parent f6e5401 commit 034d69e
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 21 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Build Env
- name: Install Build Tools
run: sudo ./scripts/install-build-tools.sh
- name: Setup Local Dependencies
run: ./scripts/setup-dependencies.sh
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Build Env
- name: Install Build Tools
run: sudo ./scripts/install-build-tools.sh
- name: Setup Local Dependencies
run: ./scripts/setup-dependencies.sh
Expand All @@ -50,7 +50,7 @@ jobs:
name: Pylint
runs-on: ubuntu-22.04
continue-on-error: true
timeout-minutes: 10
timeout-minutes: 5
strategy:
matrix:
python-version: ["3.10"]
Expand All @@ -62,10 +62,25 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup Build Env
- name: Install Build Tools
run: sudo ./scripts/install-build-tools.sh
- name: Lint with Pylint
run: ./scripts/pylint.sh
shellcheck:
name: Shellcheck
runs-on: ubuntu-22.04
continue-on-error: true
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install shellcheck
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Lint with Shellcheck
run: ./scripts/shellcheck.sh -S error --color=auto
unit-and-integration-test:
name: Unit and Integration Tests
runs-on: ubuntu-22.04
Expand All @@ -74,7 +89,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Build Env
- name: Install Build Tools
run: sudo ./scripts/install-build-tools.sh
- name: Setup Local Dependencies
run: ./scripts/setup-dependencies.sh
Expand All @@ -84,7 +99,7 @@ jobs:
run: ./scripts/test.sh
- name: Shorten SHA
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
if: ${{ !env.ACT }}
name: Archive Test Results
Expand Down Expand Up @@ -114,4 +129,3 @@ jobs:
name: OpenCBDC Transaction Processor docs for ${{ steps.vars.outputs.sha_short }}
path: ./doxygen_generated/html/*
retention-days: 7

4 changes: 2 additions & 2 deletions scripts/create-e2e-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ function readAndFormatLogs() {
return
fi

for logfile in $(ls $logdir); do
for logfile in "$logdir"/*; do
logfile_path="$logdir/$logfile"
logfile_content=$(cat $logfile_path)
logfile_content=$(<"$logfile_path")
message+="\n<details>\n<summary>$logfile</summary>\n\n\`\`\`\n$logfile_content\n\`\`\`\n</details>\n"
done
echo "$message"
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

# Supporting these versions for buildflow
PYTHON_VERSIONS=("3.10" "3.11" "3.12")
echo "Python3 versions supported: ${PYTHON_VERSIONS[@]}"
echo "Python3 versions supported: ${PYTHON_VERSIONS[*]}"

# check if supported version of python3 is already installed, and save the version
PY_INSTALLED=''
Expand Down
9 changes: 6 additions & 3 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ if [ -n "$whitespace_files" ] || [ -n "$newline_files" ] ; then
exit 1
fi

check_format_files=$(git ls-files | grep -E "tools|tests|src|cmake-tests" \
| grep -E "\..*pp")
clang-format --style=file --Werror --dry-run ${check_format_files[@]}
check_format_files=$(git ls-files | \
grep -E "tools|tests|src|cmake-tests" | \
grep -E "\..*pp")

echo "${check_format_files}" | \
xargs -n1 -I{} clang-format --style=file --Werror --dry-run {}

if ! command -v clang-tidy &>/dev/null; then
echo "clang-tidy does not appear to be installed"
Expand Down
12 changes: 6 additions & 6 deletions scripts/native-system-benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ on_int() {
printf 'Interrupting all components\n'
trap '' SIGINT # avoid interrupting ourself
for i in $PIDS; do # intentionally unquoted
if [[ -n "RECORD" ]]; then
if [[ -n "$RECORD" ]]; then
kill -SIGINT -- "-$i"
else
kill -SIGINT -- "$i"
Expand Down Expand Up @@ -194,7 +194,7 @@ on_int() {

printf 'Terminating any remaining processes\n'
for i in $PIDS; do # intentionally unquoted
if [[ -n "RECORD" ]]; then
if [[ -n "$RECORD" ]]; then
kill -SIGTERM -- "-$i"
else
kill -SIGTERM -- "$i"
Expand Down Expand Up @@ -253,15 +253,15 @@ run() {
COMP=
case "$RECORD" in
perf)
$@ &> "$PROC_LOG" &
"$@" &> "$PROC_LOG" &
COMP="$!"
perf record -F 99 -a -g -o "$PNAME".perf -p "$COMP" &> "$PERF_LOG" &
PERFS="$PERFS $!";;
debug)
${DBG} "$@" &> "$PROC_LOG" &
COMP="$!";;
*)
$@ &> "$PROC_LOG" &
"$@" &> "$PROC_LOG" &
COMP="$!";;
esac

Expand Down Expand Up @@ -324,7 +324,7 @@ launch() {
"$RT"/scripts/wait-for-it.sh -q -t 5 -h localhost -p "$ep"
done
printf 'Launched logical %s %d, replica %d [PID: %d]\n' "$1" "$id" "$node" "$PID"
if [[ -n "RECORD" ]]; then
if [[ -n "$RECORD" ]]; then
PIDS="$PIDS $(getpgid $PID)"
else
PIDS="$PIDS $PID"
Expand All @@ -337,7 +337,7 @@ launch() {
"$RT"/scripts/wait-for-it.sh -q -t 5 -h localhost -p "$ep"
done
printf 'Launched %s %d [PID: %d]\n' "$1" "$id" "$PID"
if [[ -n "RECORD" ]]; then
if [[ -n "$RECORD" ]]; then
PIDS="$PIDS $(getpgid $PID)"
else
PIDS="$PIDS $PID"
Expand Down
Loading

0 comments on commit 034d69e

Please sign in to comment.