From d3543e5b22412b8cee155c8c756df733caad339d Mon Sep 17 00:00:00 2001 From: Ishad-M-I-M Date: Mon, 11 Sep 2023 15:06:08 +0530 Subject: [PATCH 1/5] Initialize workflow with cpplint --- .github/workflows/code-lint.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/code-lint.yml diff --git a/.github/workflows/code-lint.yml b/.github/workflows/code-lint.yml new file mode 100644 index 000000000..5d8e92f30 --- /dev/null +++ b/.github/workflows/code-lint.yml @@ -0,0 +1,18 @@ +name: Style Check + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + style-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - run: sudo apt-get install cpplint + - name: cpplint check + if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip cpplint Check')}} + run: cpplint --linelength=120 --filter=-build,-runtime,-readability/todo,-whitespace/todo,-readability/casting,-readability/braces,-readability/fn_size,-legal/copyright --exclude=./src/util/sqlite3/ --recursive . \ No newline at end of file From 23f983117fc02b23b488fc1dde438bd85489504a Mon Sep 17 00:00:00 2001 From: Ishad-M-I-M Date: Mon, 11 Sep 2023 15:44:11 +0530 Subject: [PATCH 2/5] enable pylint check --- .github/workflows/code-lint.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-lint.yml b/.github/workflows/code-lint.yml index 5d8e92f30..0cbd0dbf0 100644 --- a/.github/workflows/code-lint.yml +++ b/.github/workflows/code-lint.yml @@ -12,7 +12,14 @@ jobs: steps: - uses: actions/checkout@v3 - - run: sudo apt-get install cpplint - name: cpplint check if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip cpplint Check')}} - run: cpplint --linelength=120 --filter=-build,-runtime,-readability/todo,-whitespace/todo,-readability/casting,-readability/braces,-readability/fn_size,-legal/copyright --exclude=./src/util/sqlite3/ --recursive . \ No newline at end of file + run: | + sudo apt-get install cpplint + cpplint --linelength=120 --filter=-build,-runtime,-readability/todo,-whitespace/todo,-readability/casting,-readability/braces,-readability/fn_size,-legal/copyright --exclude=./src/util/sqlite3/ --recursive . + + - name: pylint check + if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip pylint Check')}} + run: | + pip install install pylint + pylint --recursive=y . \ No newline at end of file From cd3e9d14c3d6d401cc0c6aacd0e9bfc433472654 Mon Sep 17 00:00:00 2001 From: thevindu-w Date: Mon, 11 Sep 2023 16:32:27 +0530 Subject: [PATCH 3/5] Add style checks for Dockerfile and shell scripts --- .github/workflows/code-lint.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code-lint.yml b/.github/workflows/code-lint.yml index 0cbd0dbf0..ee54c5642 100644 --- a/.github/workflows/code-lint.yml +++ b/.github/workflows/code-lint.yml @@ -12,14 +12,24 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install tools + run: | + sudo apt-get update && sudo apt-get install -y --no-install-recommends cpplint shfmt + sudo wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 -O /bin/hadolint && sudo chmod +x /bin/hadolint + pip install install pylint + - name: cpplint check if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip cpplint Check')}} - run: | - sudo apt-get install cpplint - cpplint --linelength=120 --filter=-build,-runtime,-readability/todo,-whitespace/todo,-readability/casting,-readability/braces,-readability/fn_size,-legal/copyright --exclude=./src/util/sqlite3/ --recursive . + run: cpplint --linelength=120 --filter=-build,-runtime,-readability/todo,-whitespace/todo,-readability/casting,-readability/braces,-readability/fn_size,-legal/copyright --exclude=./src/util/sqlite3/ --recursive . - name: pylint check if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip pylint Check')}} - run: | - pip install install pylint - pylint --recursive=y . \ No newline at end of file + run: pylint --recursive=y . + + - name: hadolint check + if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip hadolint Check')}} + run: find . -type f -name '*Dockerfile*' -print0 | xargs -0 hadolint --ignore DL3008 --ignore DL3041 -t warning + + - name: shfmt check + if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip shfmt Check')}} + run: find . -type f -name '*.sh' -print0 | xargs -0 shfmt -d -s -i 4 -ci \ No newline at end of file From f9a1de52b2ff196da264d05aa009a4469815f512 Mon Sep 17 00:00:00 2001 From: thevindu-w Date: Tue, 12 Sep 2023 23:00:37 +0530 Subject: [PATCH 4/5] Fix lint issues in Dockerfile and shell scripts --- run-docker.sh | 65 +++++++++++++++++++++----------------------------- run.sh | 46 ++++++++++++++++------------------- test-docker.sh | 11 ++++----- 3 files changed, 52 insertions(+), 70 deletions(-) diff --git a/run-docker.sh b/run-docker.sh index a2fb5baf4..5703b7ebf 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -1,78 +1,67 @@ #!/usr/bin/env bash - MODE=${MODE} MASTERIP=${MASTERIP} WORKERS=${WORKERS} WORKERIP=${WORKERIP} HOST_NAME=${HOST_NAME} -SERVER_PORT=${SERVER_PORT}; -SERVER_DATA_PORT=${SERVER_DATA_PORT}; +SERVER_PORT=${SERVER_PORT} +SERVER_DATA_PORT=${SERVER_DATA_PORT} ENABLE_NMON=${ENABLE_NMON} while [ $# -gt 0 ]; do - if [[ $1 == *"--"* ]]; then + if [[ $1 == *"--"* ]]; then param="${1/--/}" declare $param="$2" echo $1 $2 // Optional to see the parameter:value result - fi + fi - shift + shift done -if [ -z "$MODE" ] ; -then +if [ -z "$MODE" ]; then echo "MODE OF OPERATION SHOULD BE SPECIFIED" echo "Use argument 1 to start JasmineGraph in Master mode." echo "Use 2 to start in Worker mode." exit 1 fi -if [ $MODE -eq 1 ] ; -then - if [ -z "$MASTERIP" ] ; - then - echo "MASTER IP SHOULD BE SPECIFIED" - exit 1 +if [ $MODE -eq 1 ]; then + if [ -z "$MASTERIP" ]; then + echo "MASTER IP SHOULD BE SPECIFIED" + exit 1 fi - if [ -z "$WORKERS" ] ; - then - echo "Number of workers SHOULD BE SPECIFIED" - exit 1 + if [ -z "$WORKERS" ]; then + echo "Number of workers SHOULD BE SPECIFIED" + exit 1 fi - if [ -z "$WORKERIP" ] ; - then - echo "Worker IPs SHOULD BE SPECIFIED" - exit 1 + if [ -z "$WORKERIP" ]; then + echo "Worker IPs SHOULD BE SPECIFIED" + exit 1 fi else - - if [ -z "$MASTERIP" ] ; - then - echo "MASTER IP SHOULD BE SPECIFIED" - exit 1 + if [ -z "$MASTERIP" ]; then + echo "MASTER IP SHOULD BE SPECIFIED" + exit 1 fi - if [ -z "$SERVER_PORT" ] ; - then - echo "SERVER PORT SHOULD BE SPECIFIED" - exit 1 + if [ -z "$SERVER_PORT" ]; then + echo "SERVER PORT SHOULD BE SPECIFIED" + exit 1 fi - if [ -z "$SERVER_DATA_PORT" ] ; - then - echo "SERVER DATA PORT SHOULD BE SPECIFIED" - exit 1 + if [ -z "$SERVER_DATA_PORT" ]; then + echo "SERVER DATA PORT SHOULD BE SPECIFIED" + exit 1 fi fi export LD_LIBRARY_PATH=/usr/local/lib -if [ $MODE -eq 1 ] ; -then +if [ $MODE -eq 1 ]; then ./JasmineGraph "docker" $MODE $MASTERIP $WORKERS $WORKERIP $ENABLE_NMON else ./JasmineGraph "docker" $MODE $HOST_NAME $MASTERIP $SERVER_PORT $SERVER_DATA_PORT $ENABLE_NMON -fi \ No newline at end of file +fi diff --git a/run.sh b/run.sh index 15ccecc71..35ed06ad5 100755 --- a/run.sh +++ b/run.sh @@ -1,19 +1,17 @@ #!/usr/bin/env bash -JASMINEGRAPH_DIR="`dirname \"$0\"`" -PROFILE=$1; -MODE=$2; - -JASMINEGRAPH_DIR="`( cd \"$JASMINEGRAPH_DIR\" && pwd )`" -if [ -z "$JASMINEGRAPH_DIR" ] ; -then - exit 1 # fail +JASMINEGRAPH_DIR="$(dirname \"$0\")" +PROFILE=$1 +MODE=$2 + +JASMINEGRAPH_DIR="$(cd \"$JASMINEGRAPH_DIR\" && pwd)" +if [ -z "$JASMINEGRAPH_DIR" ]; then + exit 1 # fail fi export JASMINEGRAPH_HOME="$JASMINEGRAPH_DIR" -if [ -z "$MODE" ] ; -then +if [ -z "$MODE" ]; then echo "MODE OF OPERATION SHOULD BE SPECIFIED" echo "Use argument 1 to start JasmineGraph in Master mode." echo "Use 2 to start in Worker mode." @@ -22,33 +20,29 @@ fi cd $JASMINEGRAPH_DIR -if [ $MODE -eq 1 ] ; -then +if [ $MODE -eq 1 ]; then echo "STARTING MASTER MODE" - MASTER_HOST_NAME=$3; - NUMBER_OF_WORKERS=$4; - WORKER_IPS=$5; + MASTER_HOST_NAME=$3 + NUMBER_OF_WORKERS=$4 + WORKER_IPS=$5 ./JasmineGraph "native" $MODE $MASTER_HOST_NAME $NUMBER_OF_WORKERS $WORKER_IPS "false" else - WORKER_HOST=$3; - MASTER_HOST_NAME=$4; - SERVER_PORT=$5; - SERVER_DATA_PORT=$6; + WORKER_HOST=$3 + MASTER_HOST_NAME=$4 + SERVER_PORT=$5 + SERVER_DATA_PORT=$6 - if [ -z "$SERVER_PORT" ] ; - then + if [ -z "$SERVER_PORT" ]; then echo "SERVER PORT SHOULD BE SPECIFIED" exit 1 fi - if [ -z "$SERVER_DATA_PORT" ] ; - then - echo "SERVER DATA PORT SHOULD BE SPECIFIED" - exit 1 + if [ -z "$SERVER_DATA_PORT" ]; then + echo "SERVER DATA PORT SHOULD BE SPECIFIED" + exit 1 fi ./JasmineGraph "native" $MODE $WORKER_HOST $MASTER_HOST_NAME $SERVER_PORT $SERVER_DATA_PORT "false" fi - diff --git a/test-docker.sh b/test-docker.sh index 35f7ad120..b9eaebd12 100755 --- a/test-docker.sh +++ b/test-docker.sh @@ -6,7 +6,7 @@ TIMEOUT_SECONDS=600 RUN_ID="$(date +%y%m%d_%H%M%S)" LOG_DIR="${PROJECT_ROOT}/logs/${RUN_ID}" while [ -d "$LOG_DIR"]; do - tmp_id="$((${tmp_id}+1))" + tmp_id="$((tmp_id + 1))" new_run="${RUN_ID}_${tmp_id}" LOG_DIR="${PROJECT_ROOT}/logs/${RUN_ID}" done @@ -19,16 +19,15 @@ BUILD_LOG="${LOG_DIR}/build.log" RUN_LOG="${LOG_DIR}/run_master.log" TEST_LOG="${LOG_DIR}/test.log" - -stop_and_remove_containers () { +stop_and_remove_containers() { if [ "$(docker ps -q)" ]; then - docker ps -a -q | xargs docker rm -f &>/dev/null + docker ps -a -q | xargs docker rm -f &>/dev/null else echo "No containers to stop and remove." - fi + fi } -build_and_run_docker () { +build_and_run_docker() { stop_and_remove_containers cd "$PROJECT_ROOT" docker build -t jasminegraph:test . |& tee "$BUILD_LOG" From 31487409e4442b83695e1e9b4ab9c0a4d8a22a4f Mon Sep 17 00:00:00 2001 From: thevindu-w Date: Tue, 12 Sep 2023 23:48:41 +0530 Subject: [PATCH 5/5] Fix lint warning in Dockerfile --- .github/workflows/code-lint.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-lint.yml b/.github/workflows/code-lint.yml index ee54c5642..f908def3c 100644 --- a/.github/workflows/code-lint.yml +++ b/.github/workflows/code-lint.yml @@ -28,7 +28,7 @@ jobs: - name: hadolint check if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip hadolint Check')}} - run: find . -type f -name '*Dockerfile*' -print0 | xargs -0 hadolint --ignore DL3008 --ignore DL3041 -t warning + run: find . -type f -name '*Dockerfile*' -print0 | xargs -0 hadolint --ignore DL3008 -t warning - name: shfmt check if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip shfmt Check')}} diff --git a/Dockerfile b/Dockerfile index 0fa0af5d4..0e7550e89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM miyurud/jasminegraph +FROM miyurud/jasminegraph:20230909T110050 ENV HOME="/home/ubuntu" ENV JASMINEGRAPH_HOME="/home/ubuntu/software/jasminegraph"