Skip to content

Commit

Permalink
add shellcheck to CI (#1423)
Browse files Browse the repository at this point in the history
* add shellcheck to CI

* fix shellcheck warnings

* rename shellcheck to shell in workflow
  • Loading branch information
LesnyRumcajs authored Feb 10, 2022
1 parent f7141b4 commit e2a7a3e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Shell

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run shellcheck
uses: ludeeus/[email protected]
22 changes: 11 additions & 11 deletions scripts/add_license.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
#
# Checks if the source code contains required license and adds it if necessary.
# Returns 1 if there was a missing license, 0 otherwise.

PAT_APA="^// Copyright 2019-2022 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT$"
PAT_APA="^// Copyright 2019-2022 ChainSafe Systems// SPDX-License-Identifier: Apache-2.0, MIT$"

valid=true
for file in $(find . -type f -not -path "./target/*" -not -path "./blockchain/beacon/src/drand_api/*" -not -path "./ipld/graphsync/src/message/proto/message.rs" | egrep '\.(rs)$'); do
header=$(echo $(head -3 $file))
ret=0
for file in $(find . -type f -not -path "./target/*" -not -path "./blockchain/beacon/src/drand_api/*" -not -path "./ipld/graphsync/src/message/proto/message.rs" | grep -E '\.(rs)$'); do
header=$(head -2 "$file" | tr -d '\n')
if ! echo "$header" | grep -q "$PAT_APA"; then
echo "$file was missing header"
cat ./scripts/copyright.txt $file > temp
mv temp $file
valid=false
cat ./scripts/copyright.txt "$file" > temp
mv temp "$file"
ret=1
fi
done

# if a header is incorrect, return an OS exit code
if [ "$valid" = false ] ; then
exit 1
fi
exit $ret
8 changes: 4 additions & 4 deletions scripts/smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GREEN='\033[0;32m'
NC='\033[0m'

# extract token from auth api-info output
TOKEN="$(cut -d':' -f1 <<< $FULL_ADDR)"
TOKEN="$(cut -d':' -f1 <<< "$FULL_ADDR")"
TOKEN=${TOKEN#"FULLNODE_API_INFO=\""}

# set headers for http requests
Expand Down Expand Up @@ -59,15 +59,15 @@ RPC_ENDPOINTS+=("StateMinerInitialPledgeCollateral" "MinerGetBaseInfo")


# send requests programmatically
for endpoint in ${RPC_ENDPOINTS[@]}; do
for endpoint in "${RPC_ENDPOINTS[@]}"; do
METHOD="Filecoin.${endpoint}"
REQUEST_BODY="{\"jsonrpc\": \"2.0\", \"method\": \"$METHOD\", \"params\":[], \"id\": 0}"

RESPONSE_CODE=$(curl -w "%{http_code}" -s -o /dev/null -X POST -H "$CONTENT_TYPE_HEADER" -H "$AUTH_HEADER" -d "$REQUEST_BODY" http://127.0.0.1:1234/rpc/v0)

# a response is a response and considered a passing test
# we are not passing params to endpoints so some methods will fail due to lack of params
if [ $RESPONSE_CODE = '200' ] || [ $RESPONSE_CODE = '500' ]; then
if [ "$RESPONSE_CODE" = '200' ] || [ "$RESPONSE_CODE" = '500' ]; then
echo -e "${METHOD} ${GREEN} OK ${NC}"
else
echo -e "${METHOD} ${RED} FAIL ${RESPONSE_CODE} ${NC}"
Expand All @@ -76,4 +76,4 @@ for endpoint in ${RPC_ENDPOINTS[@]}; do
done

# Kill forest daemon
ps -ef | grep forest | grep -v grep | awk '{print $2}' | xargs kill
pgrep forest | xargs kill

0 comments on commit e2a7a3e

Please sign in to comment.