Skip to content

Commit 9c5ec61

Browse files
committed
ci: add shellcheck gh action, lint fixes, parallel acts
This commit made with the assistance of github copilot Signed-off-by: Morgan Rockett <[email protected]>
1 parent f6e5401 commit 9c5ec61

18 files changed

+449
-363
lines changed

.github/workflows/ci.yml

+19-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v4
2626
with:
2727
submodules: recursive
28-
- name: Setup Build Env
28+
- name: Install Build Tools
2929
run: sudo ./scripts/install-build-tools.sh
3030
- name: Setup Local Dependencies
3131
run: ./scripts/setup-dependencies.sh
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@v4
3939
with:
4040
submodules: recursive
41-
- name: Setup Build Env
41+
- name: Install Build Tools
4242
run: sudo ./scripts/install-build-tools.sh
4343
- name: Setup Local Dependencies
4444
run: ./scripts/setup-dependencies.sh
@@ -50,7 +50,7 @@ jobs:
5050
name: Pylint
5151
runs-on: ubuntu-22.04
5252
continue-on-error: true
53-
timeout-minutes: 10
53+
timeout-minutes: 5
5454
strategy:
5555
matrix:
5656
python-version: ["3.10"]
@@ -62,10 +62,23 @@ jobs:
6262
uses: actions/setup-python@v5
6363
with:
6464
python-version: ${{ matrix.python-version }}
65-
- name: Setup Build Env
65+
- name: Install Build Tools
6666
run: sudo ./scripts/install-build-tools.sh
6767
- name: Lint with Pylint
6868
run: ./scripts/pylint.sh
69+
shellcheck:
70+
name: Shellcheck
71+
runs-on: ubuntu-22.04
72+
continue-on-error: true
73+
timeout-minutes: 5
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
submodules: recursive
78+
- name: Install Build Tools
79+
run: sudo ./scripts/install-build-tools.sh
80+
- name: Lint with Shellcheck
81+
run: ./scripts/shellcheck.sh view
6982
unit-and-integration-test:
7083
name: Unit and Integration Tests
7184
runs-on: ubuntu-22.04
@@ -74,7 +87,7 @@ jobs:
7487
- uses: actions/checkout@v4
7588
with:
7689
submodules: recursive
77-
- name: Setup Build Env
90+
- name: Install Build Tools
7891
run: sudo ./scripts/install-build-tools.sh
7992
- name: Setup Local Dependencies
8093
run: ./scripts/setup-dependencies.sh
@@ -84,7 +97,7 @@ jobs:
8497
run: ./scripts/test.sh
8598
- name: Shorten SHA
8699
id: vars
87-
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
100+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
88101
- uses: actions/upload-artifact@v4
89102
if: ${{ !env.ACT }}
90103
name: Archive Test Results
@@ -114,4 +127,3 @@ jobs:
114127
name: OpenCBDC Transaction Processor docs for ${{ steps.vars.outputs.sha_short }}
115128
path: ./doxygen_generated/html/*
116129
retention-days: 7
117-

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ CMakeFiles/
5050
plots/
5151
.deps/
5252
.libs/
53+
.cache/
5354

5455
# Database
5556
blocks.dat

scripts/benchmarks.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Exit script on failure.
33
set -e
44

@@ -42,13 +42,13 @@ do
4242
-d|--build-dir)
4343
shift
4444
ARG="$1"
45-
if [[ $ARG == "" || ${ARG:0:1} == "-" ]]
45+
if [[ "$ARG" == "" || ${ARG:0:1} == "-" ]]
4646
then
4747
echo -n "ERROR: The -d flag was used, "
4848
echo "but a valid build folder was not given."
4949
exit 1
5050
fi
51-
BUILD_DIR=$ARG
51+
BUILD_DIR="$ARG"
5252
shift
5353
;;
5454
*)
@@ -78,7 +78,8 @@ fi
7878
# If the build folder is a relative path, convert it to an absolute path
7979
# to avoid potential relative path errors and to improve readability
8080
# if the path is written to stdout.
81-
export BUILD_DIR=$(cd "$BUILD_DIR"; pwd)
81+
BUILD_DIR=$(cd "${BUILD_DIR}"; pwd)
82+
export BUILD_DIR
8283
echo "Build folder: '${BUILD_DIR}'"
8384
echo
8485

scripts/build-docker.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DOCKER_IMAGE_TAG_TWOPHASE=${DOCKER_IMAGE_TAG:-opencbdc-tx-twophase}
1212
git submodule init && git submodule update
1313

1414
# Build docker image
15-
docker build --target base -t $DOCKER_IMAGE_TAG_BASE -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
16-
docker build --target builder --build-arg BASE_IMAGE=base -t $DOCKER_IMAGE_TAG_BUILDER -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
17-
docker build --target twophase --build-arg BASE_IMAGE=base -t $DOCKER_IMAGE_TAG_TWOPHASE -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
18-
docker build --target atomizer --build-arg BASE_IMAGE=base -t $DOCKER_IMAGE_TAG_ATOMIZER -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
15+
docker build --target base -t "$DOCKER_IMAGE_TAG_BASE" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..
16+
docker build --target builder --build-arg BASE_IMAGE=base -t "$DOCKER_IMAGE_TAG_BUILDER" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..
17+
docker build --target twophase --build-arg BASE_IMAGE=base -t "$DOCKER_IMAGE_TAG_TWOPHASE" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..
18+
docker build --target atomizer --build-arg BASE_IMAGE=base -t "$DOCKER_IMAGE_TAG_ATOMIZER" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..

scripts/build.sh

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

55
help() {
6-
if [ $# -gt 0 ]; then
6+
if [[ $# -gt 0 ]]; then
77
printf 'Unexpected Argument (%s)\n' "$1"
88
fi
99
printf 'HELP: Usage: %s [Debug|Release|Profiling]\n' "$0"
@@ -21,13 +21,13 @@ elif [[ "$BUILD_PROFILING" == "1" ]]; then
2121
CMAKE_BUILD_TYPE="Profiling"
2222
fi
2323

24-
if [ $# -gt 0 ]; then
24+
if [[ $# -gt 0 ]]; then
2525
case "$1" in
2626
Release|--release|-r) CMAKE_BUILD_TYPE="Release";;
2727
Profiling|--profiling|-p) CMAKE_BUILD_TYPE="Profiling";;
2828
Debug|--debug|-d) CMAKE_BUILD_TYPE="Debug";;
2929
--help|-h) help;;
30-
*) help $1;;
30+
*) help "$1";;
3131
esac
3232
fi
3333

@@ -36,29 +36,33 @@ echo "Building..."
3636
# see PREFIX in ./scripts/setup-dependencies.sh
3737
PREFIX="$(cd "$(dirname "$0")"/.. && pwd)/prefix"
3838

39-
if [ -z ${BUILD_DIR+x} ]; then
39+
if [[ -z ${BUILD_DIR+x} ]]; then
4040
export BUILD_DIR=build
4141
fi
4242

43-
mkdir -p $BUILD_DIR
44-
cd $BUILD_DIR
43+
mkdir -p "$BUILD_DIR"
44+
cd "$BUILD_DIR"
4545

46-
CMAKE_FLAGS=-DCMAKE_PREFIX_PATH="${PREFIX}"
46+
CMAKE_FLAGS=-DCMAKE_PREFIX_PATH=${PREFIX}
4747
CPUS=1
4848
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
4949
CPUS=$(grep -c ^processor /proc/cpuinfo)
5050
elif [[ "$OSTYPE" == "darwin"* ]]; then
5151
CPUS=$(sysctl -n hw.ncpu)
5252
XCODE_CMDLINE_DIR=$(xcode-select -p)
53-
CMAKE_FLAGS+=" -DCMAKE_C_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang -DCMAKE_CXX_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang++ -DCMAKE_CXX_FLAGS=-isystem\ /usr/local/include -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
53+
CMAKE_FLAGS+=" -DCMAKE_C_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang"
54+
CMAKE_FLAGS+=" -DCMAKE_CXX_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang++"
55+
CMAKE_FLAGS+=" -DCMAKE_CXX_FLAGS=-isystem\ /usr/local/include"
56+
CMAKE_FLAGS+=" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
5457
fi
5558

56-
if [[ -z $CMAKE_BUILD_TYPE ]]; then
59+
if [[ -z "$CMAKE_BUILD_TYPE" ]]; then
5760
echo "CMAKE_BUILD_TYPE not set, defaulting to debug"
5861
CMAKE_BUILD_TYPE="Debug"
5962
fi
6063

61-
echo "Building $CMAKE_BUILD_TYPE"
64+
echo "Building ${CMAKE_BUILD_TYPE}"
6265
eval "cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_FLAGS} .."
63-
make -j$CPUS
66+
make -j"$CPUS"
6467

68+
echo; echo "Build complete"; echo

scripts/create-e2e-report.sh

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
#!/usr/bin/env bash
22
set -e
3-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4-
TESTRUN_PATH=$1
3+
TESTRUN_PATH="$1"
54

65
function readAndFormatLogs() {
76
logdir="$1"
87
message=""
9-
if [[ ! -d $logdir ]]; then
8+
if [[ ! -d "$logdir" ]]; then
109
echo "$logdir does not exist"
1110
return
1211
fi
1312

14-
for logfile in $(ls $logdir); do
15-
logfile_path="$logdir/$logfile"
16-
logfile_content=$(cat $logfile_path)
17-
message+="\n<details>\n<summary>$logfile</summary>\n\n\`\`\`\n$logfile_content\n\`\`\`\n</details>\n"
13+
for logfile in "$logdir"/*; do
14+
logfile_content=$(cat "$logfile")
15+
message+="\n<details>\n<summary>${logfile}</summary>\n\n\`\`\`\n${logfile_content}\n\`\`\`\n</details>\n"
1816
done
1917
echo "$message"
2018
}
2119

22-
testrun_logs="\n<details>\n<summary>View Testrun</summary>\n\n\`\`\`\n$(cat $TESTRUN_PATH/testrun.log)\n\`\`\`\n</details>\n\n"
23-
container_logs=$(readAndFormatLogs $TESTRUN_PATH/logs)
20+
testrun_logs="\n<details>\n<summary>View Testrun</summary>\n\n\`\`\`\n$(cat "$TESTRUN_PATH"/testrun.log)\n\`\`\`\n</details>\n\n"
21+
container_logs=$(readAndFormatLogs "$TESTRUN_PATH"/logs)
2422

2523
printf "# E2E Results\n# TestRun Logs\n%b\n\n# Container Logs\n%b\n" "$testrun_logs" "$container_logs"

0 commit comments

Comments
 (0)