Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move shfmt execution from the super linter to pre-commit #17913

Merged
merged 2 commits into from Apr 29, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/super-linter.yml
Expand Up @@ -73,7 +73,6 @@ jobs:
VALIDATE_JSON: true
VALIDATE_MD: true
VALIDATE_POWERSHELL: true
VALIDATE_SHELL_SHFMT: true
VALIDATE_TYPESCRIPT_ES: true
VALIDATE_YAML: true
DISABLE_ERRORS: false
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -33,6 +33,11 @@ repos:
hooks:
- id: prettier
types_or: [ini, json, toml, yaml]
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
- id: shfmt
args: ["--diff", "--write", "-i", "2"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand Down
5 changes: 4 additions & 1 deletion activated.sh
Expand Up @@ -2,7 +2,10 @@

set -o errexit

SCRIPT_DIRECTORY=$(cd -- "$(dirname -- "$0")"; pwd)
SCRIPT_DIRECTORY=$(
cd -- "$(dirname -- "$0")"
pwd
)
# shellcheck disable=SC1091
. "${SCRIPT_DIRECTORY}/venv/bin/activate"

Expand Down
15 changes: 7 additions & 8 deletions build_scripts/build_license_directory.sh
Expand Up @@ -13,22 +13,21 @@ printf "%s\n" "$sum"
license_list=$(license-checker --json | jq -r '.[].licenseFile' | grep -v null)

# Split the license list by newline character into an array
IFS=$'\n' read -rd '' -a licenses_array <<< "$license_list"
IFS=$'\n' read -rd '' -a licenses_array <<<"$license_list"

#print the contents of the array
printf '%s\n' "${licenses_array[@]}"

for i in "${licenses_array[@]}"; do
dirname="licenses/$(dirname "$i" | awk -F'/' '{print $NF}')"
mkdir -p "$dirname"
echo "$dirname"
cp "$i" "$dirname"
dirname="licenses/$(dirname "$i" | awk -F'/' '{print $NF}')"
mkdir -p "$dirname"
echo "$dirname"
cp "$i" "$dirname"
done

mv licenses/ ../build_scripts/dist/daemon
cd ../build_scripts || exit 1


# PULL IN THE LICENSES FROM PIP-LICENSE
pip install pip-licenses || pip3 install pip-licenses

Expand All @@ -40,8 +39,8 @@ license_path_array=()

# read the output line by line into the array
while IFS= read -r line; do
license_path_array+=("$line")
done <<< "$output"
license_path_array+=("$line")
done <<<"$output"

# create a dir for each license and copy the license file over
for i in "${license_path_array[@]}"; do
Expand Down
8 changes: 4 additions & 4 deletions build_scripts/build_linux_deb-1-gui.sh
Expand Up @@ -19,8 +19,8 @@ npm ci
npm run build
LAST_EXIT_CODE=$?
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "npm run build failed!"
exit $LAST_EXIT_CODE
echo >&2 "npm run build failed!"
exit $LAST_EXIT_CODE
fi

# Remove unused packages
Expand All @@ -40,8 +40,8 @@ rm -rf packages/wallets
cd ./packages/gui/node_modules || exit 1
echo "Remove unused node_modules in the gui package to make cache slim more"
rm -rf electron/dist # ~186MB
rm -rf "@mui" # ~71MB
rm -rf typescript # ~63MB
rm -rf "@mui" # ~71MB
rm -rf typescript # ~63MB

# Remove `packages/gui/node_modules/@chia-network` because it causes an error on later `electron-packager` command
rm -rf "@chia-network"
24 changes: 12 additions & 12 deletions build_scripts/build_linux_deb-2-installer.sh
Expand Up @@ -4,11 +4,11 @@ set -o errexit

if [ ! "$1" ]; then
echo "This script requires either amd64 of arm64 as an argument"
exit 1
exit 1
elif [ "$1" = "amd64" ]; then
PLATFORM="amd64"
PLATFORM="amd64"
else
PLATFORM="arm64"
PLATFORM="arm64"
fi
export PLATFORM

Expand All @@ -19,8 +19,8 @@ git submodule
# set, this will attempt to Notarize the signed DMG

if [ ! "$CHIA_INSTALLER_VERSION" ]; then
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
CHIA_INSTALLER_VERSION="0.0.0"
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
CHIA_INSTALLER_VERSION="0.0.0"
fi
echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION"
export CHIA_INSTALLER_VERSION
Expand All @@ -39,16 +39,15 @@ SPEC_FILE=$(python -c 'import sys; from pathlib import Path; path = Path(sys.arg
pyinstaller --log-level=INFO "$SPEC_FILE"
LAST_EXIT_CODE=$?
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "pyinstaller failed!"
exit $LAST_EXIT_CODE
echo >&2 "pyinstaller failed!"
exit $LAST_EXIT_CODE
fi

# Creates a directory of licenses
echo "Building pip and NPM license directory"
pwd
bash ./build_license_directory.sh


# Builds CLI only .deb
# need j2 for templating the control file
format_deb_version_string() {
Expand All @@ -64,7 +63,8 @@ mkdir -p "dist/$CLI_DEB_BASE/opt/chia"
mkdir -p "dist/$CLI_DEB_BASE/usr/bin"
mkdir -p "dist/$CLI_DEB_BASE/DEBIAN"
mkdir -p "dist/$CLI_DEB_BASE/etc/systemd/system"
CHIA_DEB_CONTROL_VERSION=$(format_deb_version_string "$CHIA_INSTALLER_VERSION"); export CHIA_DEB_CONTROL_VERSION
CHIA_DEB_CONTROL_VERSION=$(format_deb_version_string "$CHIA_INSTALLER_VERSION")
export CHIA_DEB_CONTROL_VERSION
j2 -o "dist/$CLI_DEB_BASE/DEBIAN/control" assets/deb/control.j2
cp assets/systemd/*.service "dist/$CLI_DEB_BASE/etc/systemd/system/"
cp -r dist/daemon/* "dist/$CLI_DEB_BASE/opt/chia/"
Expand All @@ -80,7 +80,7 @@ cd ../chia-blockchain-gui/packages/gui || exit 1

# sets the version for chia-blockchain in package.json
cp package.json package.json.orig
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json > temp.json && mv temp.json package.json
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json >temp.json && mv temp.json package.json

echo "Building Linux(deb) Electron app"
PRODUCT_NAME="chia"
Expand Down Expand Up @@ -126,8 +126,8 @@ ls -l dist/linux*-unpacked/resources
mv package.json.orig package.json

if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "electron-builder failed!"
exit $LAST_EXIT_CODE
echo >&2 "electron-builder failed!"
exit $LAST_EXIT_CODE
fi

GUI_DEB_NAME=chia-blockchain_${CHIA_INSTALLER_VERSION}_${PLATFORM}.deb
Expand Down
8 changes: 4 additions & 4 deletions build_scripts/build_linux_rpm-1-gui.sh
Expand Up @@ -18,8 +18,8 @@ npm ci
npm run build
LAST_EXIT_CODE=$?
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "npm run build failed!"
exit $LAST_EXIT_CODE
echo >&2 "npm run build failed!"
exit $LAST_EXIT_CODE
fi

# Remove unused packages
Expand All @@ -39,8 +39,8 @@ rm -rf packages/wallets
cd ./packages/gui/node_modules || exit 1
echo "Remove unused node_modules in the gui package to make cache slim more"
rm -rf electron/dist # ~186MB
rm -rf "@mui" # ~71MB
rm -rf typescript # ~63MB
rm -rf "@mui" # ~71MB
rm -rf typescript # ~63MB

# Remove `packages/gui/node_modules/@chia-network` because it causes an error on later `electron-packager` command
rm -rf "@chia-network"
22 changes: 11 additions & 11 deletions build_scripts/build_linux_rpm-2-installer.sh
Expand Up @@ -7,19 +7,19 @@ git submodule

if [ ! "$1" ]; then
echo "This script requires either amd64 of arm64 as an argument"
exit 1
exit 1
elif [ "$1" = "amd64" ]; then
export REDHAT_PLATFORM="x86_64"
export REDHAT_PLATFORM="x86_64"
else
export REDHAT_PLATFORM="arm64"
export REDHAT_PLATFORM="arm64"
fi

# If the env variable NOTARIZE and the username and password variables are
# set, this will attempt to Notarize the signed DMG

if [ ! "$CHIA_INSTALLER_VERSION" ]; then
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
CHIA_INSTALLER_VERSION="0.0.0"
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
CHIA_INSTALLER_VERSION="0.0.0"
fi
echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION"

Expand All @@ -37,8 +37,8 @@ SPEC_FILE=$(python -c 'import sys; from pathlib import Path; path = Path(sys.arg
pyinstaller --log-level=INFO "$SPEC_FILE"
LAST_EXIT_CODE=$?
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "pyinstaller failed!"
exit $LAST_EXIT_CODE
echo >&2 "pyinstaller failed!"
exit $LAST_EXIT_CODE
fi

# Creates a directory of licenses
Expand Down Expand Up @@ -90,10 +90,10 @@ cd ../chia-blockchain-gui/packages/gui || exit 1

# sets the version for chia-blockchain in package.json
cp package.json package.json.orig
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json > temp.json && mv temp.json package.json
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json >temp.json && mv temp.json package.json

export FPM_EDITOR="cat >../../../build_scripts/dist/gui.spec <"
jq '.rpm.fpm |= . + ["--edit"]' ../../../build_scripts/electron-builder.json > temp.json && mv temp.json ../../../build_scripts/electron-builder.json
jq '.rpm.fpm |= . + ["--edit"]' ../../../build_scripts/electron-builder.json >temp.json && mv temp.json ../../../build_scripts/electron-builder.json

echo "Building Linux(rpm) Electron app"
OPT_ARCH="--x64"
Expand All @@ -118,8 +118,8 @@ ls -l dist/linux*-unpacked/resources
mv package.json.orig package.json

if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "electron-builder failed!"
exit $LAST_EXIT_CODE
echo >&2 "electron-builder failed!"
exit $LAST_EXIT_CODE
fi

GUI_RPM_NAME="chia-blockchain-${CHIA_INSTALLER_VERSION}-1.${REDHAT_PLATFORM}.rpm"
Expand Down
8 changes: 4 additions & 4 deletions build_scripts/build_macos-1-gui.sh
Expand Up @@ -19,8 +19,8 @@ npm ci
npm run build
LAST_EXIT_CODE=$?
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "npm run build failed!"
exit $LAST_EXIT_CODE
echo >&2 "npm run build failed!"
exit $LAST_EXIT_CODE
fi

# Remove unused packages
Expand All @@ -40,8 +40,8 @@ rm -rf packages/wallets
cd ./packages/gui/node_modules || exit 1
echo "Remove unused node_modules in the gui package to make cache slim more"
rm -rf electron/dist # ~186MB
rm -rf "@mui" # ~71MB
rm -rf typescript # ~63MB
rm -rf "@mui" # ~71MB
rm -rf typescript # ~63MB

# Remove `packages/gui/node_modules/@chia-network` because it causes an error on later `electron-packager` command
rm -rf "@chia-network"
35 changes: 17 additions & 18 deletions build_scripts/build_macos-2-installer.sh
Expand Up @@ -9,8 +9,8 @@ git submodule
# set, this will attempt to Notarize the signed DMG.

if [ ! "$CHIA_INSTALLER_VERSION" ]; then
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
CHIA_INSTALLER_VERSION="0.0.0"
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
CHIA_INSTALLER_VERSION="0.0.0"
fi
echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION"

Expand All @@ -28,11 +28,10 @@ SPEC_FILE=$(python -c 'import sys; from pathlib import Path; path = Path(sys.arg
pyinstaller --log-level=INFO "$SPEC_FILE"
LAST_EXIT_CODE=$?
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "pyinstaller failed!"
exit $LAST_EXIT_CODE
echo >&2 "pyinstaller failed!"
exit $LAST_EXIT_CODE
fi


# Creates a directory of licenses
echo "Building pip and NPM license directory"
pwd
Expand All @@ -45,7 +44,7 @@ cd ../chia-blockchain-gui/packages/gui || exit 1
# sets the version for chia-blockchain in package.json
brew install jq
cp package.json package.json.orig
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json > temp.json && mv temp.json package.json
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json >temp.json && mv temp.json package.json

echo "Building macOS Electron app"
OPT_ARCH="--x64"
Expand All @@ -54,14 +53,14 @@ if [ "$(arch)" = "arm64" ]; then
fi
PRODUCT_NAME="Chia"
if [ "$NOTARIZE" == true ]; then
echo "Setting credentials for signing"
export CSC_LINK=$APPLE_DEV_ID_APP
export CSC_KEY_PASSWORD=$APPLE_DEV_ID_APP_PASS
export PUBLISH_FOR_PULL_REQUEST=true
export CSC_FOR_PULL_REQUEST=true
echo "Setting credentials for signing"
export CSC_LINK=$APPLE_DEV_ID_APP
export CSC_KEY_PASSWORD=$APPLE_DEV_ID_APP_PASS
export PUBLISH_FOR_PULL_REQUEST=true
export CSC_FOR_PULL_REQUEST=true
else
echo "Not on ci or no secrets so not signing"
export CSC_IDENTITY_AUTO_DISCOVERY=false
echo "Not on ci or no secrets so not signing"
export CSC_IDENTITY_AUTO_DISCOVERY=false
fi
echo npx electron-builder build --mac "${OPT_ARCH}" --config.productName="$PRODUCT_NAME" --config.mac.minimumSystemVersion="11" --config ../../../build_scripts/electron-builder.json
npx electron-builder build --mac "${OPT_ARCH}" --config.productName="$PRODUCT_NAME" --config.mac.minimumSystemVersion="11" --config ../../../build_scripts/electron-builder.json
Expand All @@ -72,8 +71,8 @@ ls -l dist/mac*/chia.app/Contents/Resources/app.asar
mv package.json.orig package.json

if [ "$LAST_EXIT_CODE" -ne 0 ]; then
echo >&2 "electron-builder failed!"
exit $LAST_EXIT_CODE
echo >&2 "electron-builder failed!"
exit $LAST_EXIT_CODE
fi

mv dist/* ../../../build_scripts/dist/
Expand All @@ -90,13 +89,13 @@ mv dist/"$DMG_NAME" final_installer/
ls -lh final_installer

if [ "$NOTARIZE" == true ]; then
echo "Notarize $DMG_NAME on ci"
cd final_installer || exit 1
echo "Notarize $DMG_NAME on ci"
cd final_installer || exit 1
xcrun notarytool submit --wait --apple-id "$APPLE_NOTARIZE_USERNAME" --password "$APPLE_NOTARIZE_PASSWORD" --team-id "$APPLE_TEAM_ID" "$DMG_NAME"
xcrun stapler staple "$DMG_NAME"
echo "Notarization step complete"
else
echo "Not on ci or no secrets so skipping Notarize"
echo "Not on ci or no secrets so skipping Notarize"
fi

# Notes on how to manually notarize
Expand Down
6 changes: 3 additions & 3 deletions build_scripts/build_win_license_dir.sh
Expand Up @@ -13,7 +13,7 @@ printf "%s\n" "$sum"
license_list=$(license-checker --json | jq -r '.[].licenseFile' | grep -v null)

# Split the license list by newline character into an array
IFS=$'\n' read -rd '' -a licenses_array <<< "$license_list"
IFS=$'\n' read -rd '' -a licenses_array <<<"$license_list"

#print the contents of the array
printf '%s\n' "${licenses_array[@]}"
Expand All @@ -39,8 +39,8 @@ license_path_array=()

# read the output line by line into the array
while IFS= read -r line; do
license_path_array+=("$line")
done <<< "$output"
license_path_array+=("$line")
done <<<"$output"

# create a dir for each license and copy the license file over
for i in "${license_path_array[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion build_scripts/clean-runner.sh
Expand Up @@ -15,7 +15,7 @@ rm -rf chia-blockchain-gui/build || true
rm -rf chia-blockchain-gui/daemon || true
rm -rf chia-blockchain-gui/node_modules || true
rm chia-blockchain-gui/temp.json || true
( cd "$PWD/chia-blockchain-gui" && git checkout HEAD -- package-lock.json ) || true
(cd "$PWD/chia-blockchain-gui" && git checkout HEAD -- package-lock.json) || true
cd "$PWD" || true

# Clean up old globally installed node_modules that might conflict with the current build
Expand Down