Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ jobs:
- name: Run transaction Fuzzing check
run: make check-tx-fuzzing

shellcheck:
name: Shellcheck - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Install shellcheck
run: |
sudo apt update || true
sudo apt install -y shellcheck || true
- name: Run shellcheck
run: make lint-bash

hadolint:
name: Hadolint - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Documentation**: add instructions for developers using MacOS based systems,
and test the installation commands in CI
([#1247](https://github.com/o1-labs/openmina/pull/1234)).
- **Development tools**: Add shellcheck to the CI
([#1255](https://github.com/o1-labs/openmina/pull/1255))

### Changed

Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ format-md: ## Format all markdown and MDX files to wrap at 80 characters
lint: ## Run linter (clippy)
cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type

.PHONY: lint-bash
lint-bash: ## Check all shell scripts using shellcheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me.

Should we also add shellcheck into install-system-deps.sh? I'd definitely add it to the flake.nix since it's something that developers might want to run locally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point for the doc!

@echo "Running shellcheck on shell scripts..."
@find . -name "*.sh" \
-not -path "*/target/*" \
-not -path "*/node_modules/*" \
-not -path "*/website/docs/developers/scripts/setup/*" \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripts we provide to the developers should be ignored as they do not to be executables, and shellcheck will complain.

-print0 | xargs -0 shellcheck
@echo "Shellcheck completed successfully!"

.PHONY: lint-dockerfiles
lint-dockerfiles: ## Check all Dockerfiles using hadolint
@if [ "$$GITHUB_ACTIONS" = "true" ]; then \
Expand Down
32 changes: 20 additions & 12 deletions frontend/docker/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ replace_signaling_url() {
echo "Replacing signaling URL in $HTTPD_CONF..."

sed -i "s|$SIGNALING_URL|$OPENMINA_SIGNALING_URL|g" "$HTTPD_CONF"

if [[ $? -ne 0 ]]; then
sed_exit_code=$?
if [[ $sed_exit_code -ne 0 ]]; then
echo "Failed to replace the signaling URL, exiting."
exit 1
else
echo "Successfully replaced signaling URL with '$OPENMINA_SIGNALING_URL' in $HTTPD_CONF"
echo "Successfully replaced signaling URL with" \
"'$OPENMINA_SIGNALING_URL' in $HTTPD_CONF"
fi
else
echo "OPENMINA_SIGNALING_URL is not set. No replacement performed."
Expand Down Expand Up @@ -63,8 +64,11 @@ download_circuit_files() {
echo "$FILE already exists in $DOWNLOAD_DIR, skipping download."
else
echo "Downloading $FILE to $DOWNLOAD_DIR..."
curl -s -L --retry 3 --retry-delay 5 -o "$DOWNLOAD_DIR/$FILE" "$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
if [[ $? -ne 0 ]]; then
curl -s -L --retry 3 --retry-delay 5 \
-o "$DOWNLOAD_DIR/$FILE" \
"$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
curl_exit_code=$?
if [[ $curl_exit_code -ne 0 ]]; then
echo "Failed to download $FILE after 3 attempts, exiting."
exit 1
else
Expand All @@ -80,24 +84,28 @@ download_wasm_files() {
exit 1
fi

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

mkdir -p "$TARGET_DIR"

echo "Downloading WASM files from $WASM_URL..."
curl -s -L --retry 3 --retry-delay 5 -o "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" "$WASM_URL"

if [[ $? -ne 0 ]]; then
curl -s -L --retry 3 --retry-delay 5 \
-o "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" \
"$WASM_URL"
curl_exit_code=$?
if [[ $curl_exit_code -ne 0 ]]; then
echo "Failed to download the WASM file after 3 attempts, exiting."
exit 1
else
echo "WASM file downloaded successfully. Extracting to $TARGET_DIR..."

tar -xzf "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" -C "$TARGET_DIR"

# Check if the extraction was successful
if [[ $? -ne 0 ]]; then
tar -xzf "/tmp/openmina-$OPENMINA_WASM_VERSION-webnode-wasm.tar.gz" \
-C "$TARGET_DIR"
tar_exit_code=$?
if [[ $tar_exit_code -ne 0 ]]; then
echo "Failed to extract the WASM file, exiting."
exit 1
else
Expand Down
7 changes: 5 additions & 2 deletions frontend/scripts/download-webnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ download_circuit_files() {
echo "$FILE already exists in $DOWNLOAD_DIR, skipping download."
else
echo "Downloading $FILE to $DOWNLOAD_DIR..."
curl -s -L --retry 3 --retry-delay 5 -o "$DOWNLOAD_DIR/$FILE" "$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
if [[ $? -ne 0 ]]; then
curl -s -L --retry 3 --retry-delay 5 \
-o "$DOWNLOAD_DIR/$FILE" \
"$CIRCUITS_BASE_URL/$CIRCUITS_VERSION/$FILE"
curl_exit_code=$?
if [[ $curl_exit_code -ne 0 ]]; then
echo "Failed to download $FILE after 3 attempts, exiting."
exit 1
else
Expand Down
6 changes: 3 additions & 3 deletions producer-dashboard/docker/init-db/init-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ PASSWORD=${POSTGRES_PASSWORD}

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

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