Skip to content

Commit

Permalink
ci: add shellcheck gh action, lint fixes, parallel acts
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 <[email protected]>
  • Loading branch information
rockett-m committed Aug 7, 2024
1 parent f6e5401 commit f18e92e
Show file tree
Hide file tree
Showing 18 changed files with 446 additions and 360 deletions.
26 changes: 19 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,23 @@ 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 Build Tools
run: sudo ./scripts/install-build-tools.sh
- name: Lint with Shellcheck
run: ./scripts/shellcheck.sh view
unit-and-integration-test:
name: Unit and Integration Tests
runs-on: ubuntu-22.04
Expand All @@ -74,7 +87,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 +97,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 +127,3 @@ jobs:
name: OpenCBDC Transaction Processor docs for ${{ steps.vars.outputs.sha_short }}
path: ./doxygen_generated/html/*
retention-days: 7

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ CMakeFiles/
plots/
.deps/
.libs/
.cache/

# Database
blocks.dat
Expand Down
9 changes: 5 additions & 4 deletions scripts/benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Exit script on failure.
set -e

Expand Down Expand Up @@ -42,13 +42,13 @@ do
-d|--build-dir)
shift
ARG="$1"
if [[ $ARG == "" || ${ARG:0:1} == "-" ]]
if [[ "$ARG" == "" || ${ARG:0:1} == "-" ]]
then
echo -n "ERROR: The -d flag was used, "
echo "but a valid build folder was not given."
exit 1
fi
BUILD_DIR=$ARG
BUILD_DIR="$ARG"
shift
;;
*)
Expand Down Expand Up @@ -78,7 +78,8 @@ fi
# If the build folder is a relative path, convert it to an absolute path
# to avoid potential relative path errors and to improve readability
# if the path is written to stdout.
export BUILD_DIR=$(cd "$BUILD_DIR"; pwd)
BUILD_DIR=$(cd "${BUILD_DIR}"; pwd)
export BUILD_DIR
echo "Build folder: '${BUILD_DIR}'"
echo

Expand Down
8 changes: 4 additions & 4 deletions scripts/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DOCKER_IMAGE_TAG_TWOPHASE=${DOCKER_IMAGE_TAG:-opencbdc-tx-twophase}
git submodule init && git submodule update

# Build docker image
docker build --target base -t $DOCKER_IMAGE_TAG_BASE -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
docker build --target builder --build-arg BASE_IMAGE=base -t $DOCKER_IMAGE_TAG_BUILDER -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
docker build --target twophase --build-arg BASE_IMAGE=base -t $DOCKER_IMAGE_TAG_TWOPHASE -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
docker build --target atomizer --build-arg BASE_IMAGE=base -t $DOCKER_IMAGE_TAG_ATOMIZER -f $SCRIPT_DIR/../Dockerfile $SCRIPT_DIR/..
docker build --target base -t "$DOCKER_IMAGE_TAG_BASE" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..
docker build --target builder --build-arg BASE_IMAGE=base -t "$DOCKER_IMAGE_TAG_BUILDER" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..
docker build --target twophase --build-arg BASE_IMAGE=base -t "$DOCKER_IMAGE_TAG_TWOPHASE" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..
docker build --target atomizer --build-arg BASE_IMAGE=base -t "$DOCKER_IMAGE_TAG_ATOMIZER" -f "$SCRIPT_DIR"/../Dockerfile "$SCRIPT_DIR"/..
28 changes: 16 additions & 12 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

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

if [ $# -gt 0 ]; then
if [[ $# -gt 0 ]]; then
case "$1" in
Release|--release|-r) CMAKE_BUILD_TYPE="Release";;
Profiling|--profiling|-p) CMAKE_BUILD_TYPE="Profiling";;
Debug|--debug|-d) CMAKE_BUILD_TYPE="Debug";;
--help|-h) help;;
*) help $1;;
*) help "$1";;
esac
fi

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

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

mkdir -p $BUILD_DIR
cd $BUILD_DIR
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

CMAKE_FLAGS=-DCMAKE_PREFIX_PATH="${PREFIX}"
CMAKE_FLAGS=-DCMAKE_PREFIX_PATH=${PREFIX}
CPUS=1
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
CPUS=$(grep -c ^processor /proc/cpuinfo)
elif [[ "$OSTYPE" == "darwin"* ]]; then
CPUS=$(sysctl -n hw.ncpu)
XCODE_CMDLINE_DIR=$(xcode-select -p)
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"
CMAKE_FLAGS+=" -DCMAKE_C_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang"
CMAKE_FLAGS+=" -DCMAKE_CXX_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang++"
CMAKE_FLAGS+=" -DCMAKE_CXX_FLAGS=-isystem\ /usr/local/include"
CMAKE_FLAGS+=" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
fi

if [[ -z $CMAKE_BUILD_TYPE ]]; then
if [[ -z "$CMAKE_BUILD_TYPE" ]]; then
echo "CMAKE_BUILD_TYPE not set, defaulting to debug"
CMAKE_BUILD_TYPE="Debug"
fi

echo "Building $CMAKE_BUILD_TYPE"
echo "Building ${CMAKE_BUILD_TYPE}"
eval "cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_FLAGS} .."
make -j$CPUS
make -j"$CPUS"

echo; echo "Build complete"; echo
14 changes: 6 additions & 8 deletions scripts/create-e2e-report.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#!/usr/bin/env bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TESTRUN_PATH=$1

function readAndFormatLogs() {
logdir="$1"
message=""
if [[ ! -d $logdir ]]; then
if [[ ! -d "$logdir" ]]; then
echo "$logdir does not exist"
return
fi

for logfile in $(ls $logdir); do
logfile_path="$logdir/$logfile"
logfile_content=$(cat $logfile_path)
message+="\n<details>\n<summary>$logfile</summary>\n\n\`\`\`\n$logfile_content\n\`\`\`\n</details>\n"
for logfile in "$logdir"/*; do
logfile_content=$(cat "$logfile")
message+="\n<details>\n<summary>${logfile}</summary>\n\n\`\`\`\n${logfile_content}\n\`\`\`\n</details>\n"
done
echo "$message"
}

testrun_logs="\n<details>\n<summary>View Testrun</summary>\n\n\`\`\`\n$(cat $TESTRUN_PATH/testrun.log)\n\`\`\`\n</details>\n\n"
container_logs=$(readAndFormatLogs $TESTRUN_PATH/logs)
testrun_logs="\n<details>\n<summary>View Testrun</summary>\n\n\`\`\`\n$(cat "$TESTRUN_PATH"/testrun.log)\n\`\`\`\n</details>\n\n"
container_logs=$(readAndFormatLogs "$TESTRUN_PATH"/logs)

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

0 comments on commit f18e92e

Please sign in to comment.