Skip to content

Commit 808144d

Browse files
authored
Merge pull request #1255 from o1-labs/dw/add-shellcheck
CI: add shellcheck
2 parents 234425b + 64ed658 commit 808144d

File tree

6 files changed

+55
-17
lines changed

6 files changed

+55
-17
lines changed

.github/workflows/lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ jobs:
5555
- name: Run transaction Fuzzing check
5656
run: make check-tx-fuzzing
5757

58+
shellcheck:
59+
name: Shellcheck - ${{ matrix.os }}
60+
runs-on: ${{ matrix.os }}
61+
strategy:
62+
matrix:
63+
os: [ubuntu-latest]
64+
steps:
65+
- uses: actions/checkout@v4
66+
- name: Install shellcheck
67+
run: |
68+
sudo apt update || true
69+
sudo apt install -y shellcheck || true
70+
- name: Run shellcheck
71+
run: make lint-bash
72+
5873
hadolint:
5974
name: Hadolint - ${{ matrix.os }}
6075
runs-on: ${{ matrix.os }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
- **Documentation**: add instructions for developers using MacOS based systems,
3939
and test the installation commands in CI
4040
([#1247](https://github.com/o1-labs/openmina/pull/1234)).
41+
- **Development tools**: Add shellcheck to the CI
42+
([#1255](https://github.com/o1-labs/openmina/pull/1255))
4143

4244
### Changed
4345

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ format-md: ## Format all markdown and MDX files to wrap at 80 characters
162162
lint: ## Run linter (clippy)
163163
cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type
164164

165+
.PHONY: lint-bash
166+
lint-bash: ## Check all shell scripts using shellcheck
167+
@echo "Running shellcheck on shell scripts..."
168+
@find . -name "*.sh" \
169+
-not -path "*/target/*" \
170+
-not -path "*/node_modules/*" \
171+
-not -path "*/website/docs/developers/scripts/setup/*" \
172+
-print0 | xargs -0 shellcheck
173+
@echo "Shellcheck completed successfully!"
174+
165175
.PHONY: lint-dockerfiles
166176
lint-dockerfiles: ## Check all Dockerfiles using hadolint
167177
@if [ "$$GITHUB_ACTIONS" = "true" ]; then \

frontend/docker/startup.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ replace_signaling_url() {
1010
echo "Replacing signaling URL in $HTTPD_CONF..."
1111

1212
sed -i "s|$SIGNALING_URL|$OPENMINA_SIGNALING_URL|g" "$HTTPD_CONF"
13-
14-
if [[ $? -ne 0 ]]; then
13+
sed_exit_code=$?
14+
if [[ $sed_exit_code -ne 0 ]]; then
1515
echo "Failed to replace the signaling URL, exiting."
1616
exit 1
1717
else
18-
echo "Successfully replaced signaling URL with '$OPENMINA_SIGNALING_URL' in $HTTPD_CONF"
18+
echo "Successfully replaced signaling URL with" \
19+
"'$OPENMINA_SIGNALING_URL' in $HTTPD_CONF"
1920
fi
2021
else
2122
echo "OPENMINA_SIGNALING_URL is not set. No replacement performed."
@@ -63,8 +64,11 @@ download_circuit_files() {
6364
echo "$FILE already exists in $DOWNLOAD_DIR, skipping download."
6465
else
6566
echo "Downloading $FILE to $DOWNLOAD_DIR..."
66-
curl -s -L --retry 3 --retry-delay 5 -o "$DOWNLOAD_DIR/$FILE" "$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
67-
if [[ $? -ne 0 ]]; then
67+
curl -s -L --retry 3 --retry-delay 5 \
68+
-o "$DOWNLOAD_DIR/$FILE" \
69+
"$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
70+
curl_exit_code=$?
71+
if [[ $curl_exit_code -ne 0 ]]; then
6872
echo "Failed to download $FILE after 3 attempts, exiting."
6973
exit 1
7074
else
@@ -80,24 +84,28 @@ download_wasm_files() {
8084
exit 1
8185
fi
8286

83-
WASM_URL="$OPENMINA_BASE_URL/openmina/releases/download/$OPENMINA_WASM_VERSION/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz"
87+
WASM_URL="$OPENMINA_BASE_URL/openmina/releases/download/\
88+
$OPENMINA_WASM_VERSION/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz"
8489
TARGET_DIR="/usr/local/apache2/htdocs/assets/webnode/pkg"
8590

8691
mkdir -p "$TARGET_DIR"
8792

8893
echo "Downloading WASM files from $WASM_URL..."
89-
curl -s -L --retry 3 --retry-delay 5 -o "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" "$WASM_URL"
90-
91-
if [[ $? -ne 0 ]]; then
94+
curl -s -L --retry 3 --retry-delay 5 \
95+
-o "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" \
96+
"$WASM_URL"
97+
curl_exit_code=$?
98+
if [[ $curl_exit_code -ne 0 ]]; then
9299
echo "Failed to download the WASM file after 3 attempts, exiting."
93100
exit 1
94101
else
95102
echo "WASM file downloaded successfully. Extracting to $TARGET_DIR..."
96103

97-
tar -xzf "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" -C "$TARGET_DIR"
98-
99104
# Check if the extraction was successful
100-
if [[ $? -ne 0 ]]; then
105+
tar -xzf "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" \
106+
-C "$TARGET_DIR"
107+
tar_exit_code=$?
108+
if [[ $tar_exit_code -ne 0 ]]; then
101109
echo "Failed to extract the WASM file, exiting."
102110
exit 1
103111
else

frontend/scripts/download-webnode.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ download_circuit_files() {
4545
echo "$FILE already exists in $DOWNLOAD_DIR, skipping download."
4646
else
4747
echo "Downloading $FILE to $DOWNLOAD_DIR..."
48-
curl -s -L --retry 3 --retry-delay 5 -o "$DOWNLOAD_DIR/$FILE" "$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
49-
if [[ $? -ne 0 ]]; then
48+
curl -s -L --retry 3 --retry-delay 5 \
49+
-o "$DOWNLOAD_DIR/$FILE" \
50+
"$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
51+
curl_exit_code=$?
52+
if [[ $curl_exit_code -ne 0 ]]; then
5053
echo "Failed to download $FILE after 3 attempts, exiting."
5154
exit 1
5255
else

producer-dashboard/docker/init-db/init-db.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ PASSWORD=${POSTGRES_PASSWORD}
1010

1111
# Wait for PostgreSQL to become available
1212
echo "Waiting for postgres..."
13-
while ! pg_isready -h $HOST -p $PORT -U $USER; do
13+
while ! pg_isready -h "$HOST" -p "$PORT" -U "$USER"; do
1414
sleep 2;
1515
done
1616

1717
# Check if the database exists, and create it if it doesn't
18-
if ! PGPASSWORD=$PASSWORD psql -h $HOST -U $USER -lqt | cut -d \| -f 1 | grep -qw $DB; then
18+
if ! PGPASSWORD=$PASSWORD psql -h "$HOST" -U "$USER" -lqt | cut -d \| -f 1 | grep -qw "$DB"; then
1919
echo "Database $DB does not exist. Creating..."
2020
PGPASSWORD="$PASSWORD" createdb -h "$HOST" -U "$USER" "$DB"
2121
# Load the schema into the database
@@ -24,7 +24,7 @@ if ! PGPASSWORD=$PASSWORD psql -h $HOST -U $USER -lqt | cut -d \| -f 1 | grep -q
2424
# PGPASSWORD=$PASSWORD psql -h $HOST -U $USER -d $DB < create_schema.sql
2525
# TODO
2626
cd /dumps
27-
PGPASSWORD=$PASSWORD psql -h $HOST -U $USER -d $DB < dump.sql
27+
PGPASSWORD=$PASSWORD psql -h "$HOST" -U "$USER" -d "$DB" < dump.sql
2828
exit 1
2929
else
3030
echo "Database $DB already exists."

0 commit comments

Comments
 (0)