Skip to content

Commit

Permalink
Merge branch 'main' into dependabot-github_actions-main-github-super-…
Browse files Browse the repository at this point in the history
…linter-6
  • Loading branch information
altendky committed Apr 29, 2024
2 parents 20b4992 + abb0b04 commit 07c05ab
Show file tree
Hide file tree
Showing 80 changed files with 1,718 additions and 1,051 deletions.
1 change: 0 additions & 1 deletion .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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
2 changes: 1 addition & 1 deletion .github/workflows/test-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ on:

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ inputs.concurrency_name }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
group: ${{ github.ref }}-${{ github.workflow }}-${{ inputs.concurrency_name }}-${{ github.event_name == 'workflow_dispatch' && github.run_id || '' }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true

defaults:
Expand Down
61 changes: 57 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,61 @@ on:
- "**.md"
branches:
- "**"
workflow_dispatch: null
workflow_dispatch:
inputs:
build-job-matrix-arguments:
description: "extra arguments for build-job-matrix.py"
default: ""
required: false
type: string
per:
description: "individual job scope"
default: "directory"
required: false
type: choice
options:
- directory
- file
only:
description: "only run this job"
default: ""
required: false
type: string
duplicates:
description: "times to run each job"
default: 1
required: false
type: number
run-linux:
description: "run Linux tests"
default: true
required: false
type: boolean
run-macos-intel:
description: "run macOS-intel tests"
default: true
required: false
type: boolean
run-macos-arm:
description: "run macOS-arm tests"
default: true
required: false
type: boolean
run-windows:
description: "run Windows tests"
default: true
required: false
type: boolean
full-python-matrix:
description: "run full Python version matrix"
default: false
required: false
type: boolean
schedule:
- cron: "0 13 * * *"

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}--${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'workflow_dispatch' && github.run_id || '' }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true

jobs:
Expand All @@ -40,16 +89,17 @@ jobs:
- name: Generate matrix configuration
id: configure
run: |
python chia/_tests/build-job-matrix.py --per directory --verbose > matrix.json
python chia/_tests/build-job-matrix.py --per directory --verbose ${{ inputs.only && format('--only {0}', inputs.only) || '' }} ${{ inputs.duplicates > 1 && format('--duplicates {0}', inputs.duplicates) || '' }} ${{ inputs.build-job-matrix-arguments }} > matrix.json
cat matrix.json
echo configuration=$(cat matrix.json) >> "$GITHUB_OUTPUT"
echo matrix_mode=${{ ( github.event_name == 'schedule' ) && 'all' || ( github.event_name == 'workflow_dispatch' ) && 'all' || ( github.repository_owner == 'Chia-Network' && github.repository != 'Chia-Network/chia-blockchain' ) && 'limited' || ( github.repository_owner == 'Chia-Network' && github.repository == 'Chia-Network/chia-blockchain' && github.ref == 'refs/heads/main' ) && 'main' || ( github.repository_owner == 'Chia-Network' && github.repository == 'Chia-Network/chia-blockchain' && startsWith(github.ref, 'refs/heads/release/') ) && 'all' || ( github.repository_owner == 'Chia-Network' && github.repository == 'Chia-Network/chia-blockchain' && startsWith(github.base_ref, 'release/') ) && 'all' || 'main' }} >> "$GITHUB_OUTPUT"
echo matrix_mode=${{ ( github.event_name == 'schedule' || inputs.full-python-matrix ) && 'all' || ( github.repository_owner == 'Chia-Network' && github.repository != 'Chia-Network/chia-blockchain' ) && 'limited' || ( github.repository_owner == 'Chia-Network' && github.repository == 'Chia-Network/chia-blockchain' && github.ref == 'refs/heads/main' ) && 'main' || ( github.repository_owner == 'Chia-Network' && github.repository == 'Chia-Network/chia-blockchain' && startsWith(github.ref, 'refs/heads/release/') ) && 'all' || ( github.repository_owner == 'Chia-Network' && github.repository == 'Chia-Network/chia-blockchain' && startsWith(github.base_ref, 'release/') ) && 'all' || 'main' }} >> "$GITHUB_OUTPUT"
outputs:
configuration: ${{ steps.configure.outputs.configuration }}
matrix_mode: ${{ steps.configure.outputs.matrix_mode }}

macos-intel:
if: github.event_name != 'workflow_dispatch' || inputs.run-macos-intel
uses: ./.github/workflows/test-single.yml
needs: configure
with:
Expand All @@ -63,6 +113,7 @@ jobs:
runs-on: macos-12
arch: intel
macos-arm:
if: github.event_name != 'workflow_dispatch' || inputs.run-macos-arm
uses: ./.github/workflows/test-single.yml
needs: configure
with:
Expand All @@ -77,6 +128,7 @@ jobs:
arch: arm
collect-junit: false
ubuntu:
if: github.event_name != 'workflow_dispatch' || inputs.run-linux
uses: ./.github/workflows/test-single.yml
needs: configure
with:
Expand All @@ -91,6 +143,7 @@ jobs:
arch: intel
collect-junit: false
windows:
if: github.event_name != 'workflow_dispatch' || inputs.run-windows
uses: ./.github/workflows/test-single.yml
needs: configure
with:
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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"
Loading

0 comments on commit 07c05ab

Please sign in to comment.