Skip to content

Commit

Permalink
Merge branch 'trunk' into cicd/python-linting
Browse files Browse the repository at this point in the history
Signed-off-by: Morgan Rockett <[email protected]>
  • Loading branch information
rockett-m authored Jul 1, 2024
2 parents 8f9f378 + d792c5e commit 4ce9a02
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 45 deletions.
12 changes: 8 additions & 4 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ $ git push --force origin <your-branch-name>
Absolutely!
However, we only officially support the included docker compose files (as they mirror our automated test environment).

After cloning the code, ``scripts/configure.sh`` will attempt to configure your environment.
After cloning the code, ``scripts/install-build-tools.sh`` needs to be ran just once. It will attempt to install the necessary software tools upon which the project relies on.

**Note:** ``scripts/configure.sh`` only supports Ubuntu-based linux distributions and macOS (which depends on [Homebrew](https://brew.sh/)).
Then, ``scripts/setup-dependencies.sh`` should be run to install libraries and dependencies
to will attempt to configure your environment.

**Note:** ``scripts/install-build-tools.sh`` only supports Ubuntu-based linux distributions and macOS (which depends on [Homebrew](https://brew.sh/)).
However, it can be used as a guide to understand what you must do to get your environment setup.

In short, ``scripts/configure.sh`` does the following:
In short, ``scripts/install-build-tools.sh`` does the following:

* installs a couple packages needed for building and testing (e.g., clang, LLVM, cmake, make, lcov, googletest, git)
* installs the external dependencies:
Expand All @@ -127,7 +130,8 @@ However, here are several things you can do to make review as easy and quick as

* Keep your working branch up-to-date with our main branch and free of merge conflicts
* Run ``./scripts/lint.sh`` and ``./scripts/test.sh`` and ensure both succeed before committing changes
* You can use a tool like [`act`](https://github.com/nektos/act) to run the CI locally and see if your changes would pass automated-review
* Run ``pylint $(git ls-files '*.py')`` for python code and seek scores close to 10.0.
* You can use a tool like [`act`](https://github.com/nektos/act) to run the CI locally and see if your changes would pass automated-review. ``act --list`` to see workflow jobs.
* Author [good commits](#what-does-a-good-commit-look-like)

</details>
Expand Down
3 changes: 2 additions & 1 deletion docs/parsec_user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ If you are using MacOS or an Ubuntu-like distribution, you can run the system wi

Build and run the system:
```console
$ ./scripts/configure.sh # only necessary on initial setup
# ./scripts/install-build-tools.sh # only necessary on initial setup
$ ./scripts/setup-dependencies.sh # only necessary on initial setup
$ ./scripts/build.sh
$ ./scripts/parsec-run-local.sh [OPTIONS] # use --help flag for help
```
Expand Down
1 change: 1 addition & 0 deletions scripts/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
PYTHON_PATH=$(which "python${PY_INSTALLED}")
create_venv_install_python "${PYTHON_PATH}" ${PY_INSTALLED}
fi

fi

echo "To activate the virtual env to run python, run 'source ./scripts/activate-venv.sh'"
Expand Down
19 changes: 10 additions & 9 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ if [ -n "$newline_files" ] ; then
fi

if [ -n "$whitespace_files" ] || [ -n "$newline_files" ] ; then
exit 1
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[@]}

if ! command -v clang-tidy &>/dev/null; then
echo "clang-tidy does not appear to be installed. Please run ./scripts/configure.sh to install dependencies or install manually."
exit 1
echo "clang-tidy does not appear to be installed"
echo "Please run ./scripts/setup-dependencies.sh to install dependencies or install manually."
exit 1
fi

if [ -z ${BUILD_DIR+x} ]; then
echo "BUILD_DIR environment variable not found. Assuming default: build"
export BUILD_DIR=build
if [ ! -d "${BUILD_DIR}" ]; then
echo "${BUILD_DIR} directory not found. Please set BUILD_DIR or run \`export BUILD_DIR=${BUILD_DIR}; build.sh\` before linting."
exit 1
fi
echo "BUILD_DIR environment variable not found. Assuming default: build"
export BUILD_DIR=build
if [ ! -d "${BUILD_DIR}" ]; then
echo "${BUILD_DIR} directory not found. Please set BUILD_DIR or run \`export BUILD_DIR=${BUILD_DIR}; build.sh\` before linting."
exit 1
fi
fi

python3 /usr/local/bin/run-clang-tidy.py -p ${BUILD_DIR} "tests/.*/.*\.cpp|src/.*/.*\.cpp|tools/.*/.*\.cpp"
48 changes: 24 additions & 24 deletions scripts/setup-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ mkdir -p "$PREFIX"/{lib,include}

CMAKE_BUILD_TYPE="Debug"
if [[ "$BUILD_RELEASE" == "1" ]]; then
CMAKE_BUILD_TYPE="Release"
CMAKE_BUILD_TYPE="Release"
fi

CPUS=1
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
CPUS=$(grep -c ^processor /proc/cpuinfo)
CPUS=$(grep -c ^processor /proc/cpuinfo)
elif [[ "$OSTYPE" == "darwin"* ]]; then
CPUS=$(sysctl -n hw.ncpu)
CPUS=$(sysctl -n hw.ncpu)
fi

LEVELDB_VERSION="1.23"
Expand All @@ -49,12 +49,12 @@ mv NuRaft-${NURAFT_VERSION} "NuRaft-${NURAFT_VERSION}-${CMAKE_BUILD_TYPE}"
cd "NuRaft-${NURAFT_VERSION}-${CMAKE_BUILD_TYPE}"
./prepare.sh
if [[ "$BUILD_RELEASE" == "1" ]]; then
# If we're doing a release build, remove the examples and tests
rm -rf examples tests
mkdir examples
mkdir tests
touch examples/CMakeLists.txt
touch tests/CMakeLists.txt
# If we're doing a release build, remove the examples and tests
rm -rf examples tests
mkdir examples
mkdir tests
touch examples/CMakeLists.txt
touch tests/CMakeLists.txt
fi
mkdir -p build
cd build
Expand All @@ -77,18 +77,18 @@ make INSTALL_TOP=$PREFIX install
cd ..

if [[ "$OSTYPE" != "darwin"* ]]; then
# <NOTE> For Mac Silicon: this curl install creates problems for building tools/bench/parsec/evm/
CURL_VERSION="7.83.1"
wget https://curl.se/download/curl-${CURL_VERSION}.tar.gz
rm -rf curl-${CURL_VERSION}
tar xzvf curl-${CURL_VERSION}.tar.gz
rm -rf curl-${CURL_VERSION}.tar.gz
mkdir -p curl-${CURL_VERSION}/build
cd curl-${CURL_VERSION}/build
../configure --prefix="${PREFIX}" --disable-shared --without-ssl --without-libpsl --without-libidn2 --without-brotli --without-zstd --without-zlib
make -j$CPUS
make install
cd ../..
# <NOTE> For Mac Silicon: this curl install creates problems for building tools/bench/parsec/evm/
CURL_VERSION="7.83.1"
wget https://curl.se/download/curl-${CURL_VERSION}.tar.gz
rm -rf curl-${CURL_VERSION}
tar xzvf curl-${CURL_VERSION}.tar.gz
rm -rf curl-${CURL_VERSION}.tar.gz
mkdir -p curl-${CURL_VERSION}/build
cd curl-${CURL_VERSION}/build
../configure --prefix="${PREFIX}" --disable-shared --without-ssl --without-libpsl --without-libidn2 --without-brotli --without-zstd --without-zlib
make -j$CPUS
make install
cd ../..
fi

JSONCPP_VERSION="1.9.5"
Expand Down Expand Up @@ -129,10 +129,10 @@ rm -rf evmc
mv ../evmc-${EVMC_VER} ./evmc
mkdir ./evmc/.git
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac Silicon: clang 'ar' does not allow empty member list, fails w/ -DBUILD_SHARED_LIBS=OFF
cmake -S . -B build -DCMAKE_INSTALL_PREFIX="${PREFIX}"
# Mac Silicon: clang 'ar' does not allow empty member list, fails w/ -DBUILD_SHARED_LIBS=OFF
cmake -S . -B build -DCMAKE_INSTALL_PREFIX="${PREFIX}"
else
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${PREFIX}"
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${PREFIX}"
fi
cmake --build build --parallel
cd build
Expand Down
14 changes: 7 additions & 7 deletions scripts/test-e2e-minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ BUILD_DOCKER=${TESTRUN_BUILD_DOCKER:-1}
# Make sure we have the necessary tools installed
required_executables=(minikube docker go helm kubectl)
for e in ${required_executables[@]}; do
if ! command -v $e &> /dev/null; then
echo "'$e' command not be found! This is required to run. Please install it."
exit 1
fi
if ! command -v $e &> /dev/null; then
echo "'$e' command not be found! This is required to run. Please install it."
exit 1
fi
done

# Start minikube cluster with opencbdc profile
minikube_status=$(minikube -p $MINIKUBE_PROFILE status | grep apiserver | awk '{ print $2 }')
if [ "$minikube_status" != "Running" ]; then
echo "🔄 Starting minkube cluster with profile '$MINIKUBE_PROFILE'..."
minikube -p $MINIKUBE_PROFILE start
echo "🔄 Starting minkube cluster with profile '$MINIKUBE_PROFILE'..."
minikube -p $MINIKUBE_PROFILE start
else
echo "✅ minikube cluster with profile '$MINIKUBE_PROFILE' is currently running."
echo "✅ minikube cluster with profile '$MINIKUBE_PROFILE' is currently running."
fi

# Update Kubernetes context to default to this minikube cluster profile
Expand Down

0 comments on commit 4ce9a02

Please sign in to comment.