-
Notifications
You must be signed in to change notification settings - Fork 30
Improved healt.sh, added health.ps, added instruction for use under win #922
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| $ErrorActionPreference= 'silentlycontinue' | ||
|
|
||
| [regex]$regex = "\d+\.\d+\.*\d*" | ||
| $yes = "`u{2714} " | ||
| $no = "`u{274c}" | ||
|
|
||
| $allChecks = $true | ||
|
|
||
| Write-Host "Starting Build Tools for VMware Aria Checks..." | ||
|
|
||
| # version should be at lest <major.minor> | ||
| # OpenSSL is not following the guidelines | ||
| @( | ||
| @{ name = "Java"; cmd="java --version"; min="17.0"; max="24.0" }, | ||
| @{ name = "Maven"; cmd="mvn --version"; min="3.2"; max="4.0" }, | ||
| @{ name = "Node.js"; cmd="node --version"; min="12.0"; max="24.0" }, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For node currently the officially supported version is 22. Some lower versions might work in specific use cases but it is situational so that cannot be officially supported. |
||
| @{ name = "Python"; cmd="python --version"; min="3.2"; max="3.14" }, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python and pip are not required by default. Have in mind that the prereqs are not for building BTVA project itself but for building the projects generated by it's archetypes, e.g. vro js, vro ts, vra-ng, etc. So based on that I need to check with the team on how we want to handle this - throwing an error for missing python dependency on a regular JS based project would be misleading. maybe we can add a warning message for python and powershell that they might be required for polyglot project types. |
||
| @{ name = "Pip"; cmd="pip --version"; min="25.0"; max="26.0" }, | ||
| @{ name = "OpenSSL"; cmd="openssl version"; min="10.0"; max="17.0" } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think openssl shouldn't be required. If you encountered it in the instructions for generating an certificates for signing the Orchestrator packages this is meant to be just an example on how you can generate it. The prereq is having that certificate for signing packages and is only for Orchestrator projects but they can be generated in other ways including from external system and may also not be present on the system that is building the project but can be located in an artifactory. |
||
| ) | ForEach-Object { | ||
| $name = $_.name | ||
| $command = $_.cmd | ||
| $min = [Version]::Parse($_.min) | ||
| $max = [Version]::Parse($_.max) | ||
|
|
||
| $result = (Invoke-Expression $command) | ||
| if ($result -eq $null) | ||
| { | ||
| Write-Host "$no $name is not installed" -ForegroundColor Red | ||
| $allChecks = $false | ||
| return | ||
| } | ||
|
|
||
| $versionString = $result.Split([Environment]::NewLine)[0] | ||
| $version = [Version]::Parse($regex.Matches($versionString)[0].Value) | ||
|
|
||
| if ($version.CompareTo($min) -ge 0 -and $version.CompareTo($max) -le 0) | ||
| { | ||
| Write-Host "$yes $name version '$version' is within the required range ($min - $max)." -ForegroundColor Green | ||
| } else { | ||
| $allChecks=$false | ||
| Write-Host "$no $name version '$version' is outside of the range ($min - $max)." -ForegroundColor Red | ||
| } | ||
| $result = $null | ||
| } | ||
|
|
||
| if ( $all_checks_passed ) { | ||
| Write-Host "All checks passed successfully." -ForegroundColor Green | ||
| } else { | ||
| Write-Host "Some checks failed. Please review the above messages." -ForegroundColor Red | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,83 +1,67 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Required Versions Ranges | ||
| MIN_NODE_VERSION="22" | ||
| MAX_NODE_VERSION="22" | ||
| MIN_MAVEN_VERSION="3.9" | ||
| MIN_JAVA_VERSION="17" | ||
| MAX_JAVA_VERSION="24" | ||
|
|
||
| # Color Codes | ||
| GREEN="\033[0;32m" | ||
| RED="\033[0;31m" | ||
| NC="\033[0m" # No Color | ||
| NC="\033[0m" | ||
|
|
||
| # Success flags | ||
| all_checks_passed=true | ||
| regex="[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+" | ||
|
|
||
| # Helper function to compare versions | ||
| version_ge() { | ||
| # Returns 0 if $1 >= $2, 1 otherwise | ||
| printf '%s\n%s\n' "$2" "$1" | sort -C -V | ||
| } | ||
|
|
||
| # Check Node.js Version Range (22.x to 22.x) | ||
| check_node_version() { | ||
| node_version=$(node -v 2>/dev/null | sed 's/v//') | ||
| node_major_version=$(echo "$node_version" | cut -d. -f1) | ||
| # OpenSSL is not following the guidelines | ||
| declare -a prerequisites=( | ||
| "Java java --version 17 24" | ||
| "Maven mvn --version 3.2" | ||
| "Node.js nodejs --version 12 24" | ||
| "Python python --version 3.2 3.14" | ||
| "Pip pip --version 25.0 26.0" | ||
| "OpenSSL openssl version 10 17.0" | ||
| ) | ||
|
|
||
| if [ -z "$node_version" ]; then | ||
| echo -e "${RED}✘ Node.js is not installed.${NC}" | ||
| all_checks_passed=false | ||
| elif [ "$node_major_version" -ge "$MIN_NODE_VERSION" ] && [ "$node_major_version" -le "$MAX_NODE_VERSION" ]; then | ||
| echo -e "${GREEN}✔ Node.js version $node_version is within the required range ($MIN_NODE_VERSION - $MAX_NODE_VERSION).${NC}" | ||
| else | ||
| echo -e "${RED}✘ Node.js version $node_version is outside the required range ($MIN_NODE_VERSION - $MAX_NODE_VERSION).${NC}" | ||
| all_checks_passed=false | ||
| fi | ||
| v_compare() { | ||
| # Returns 0 if $1 >= $2, 1 otherwise | ||
| printf '%s\n%s\n' "$2" "$1" | sort -C -V | ||
| } | ||
|
|
||
| # Check Maven Version (3.9.x or newer) | ||
| check_maven_version() { | ||
| maven_version=$(mvn -v 2>/dev/null | awk '/Apache Maven/ {print $3}') | ||
| echo "Starting Build Tools for VMware Aria Checks..." | ||
|
|
||
| if [ -z "$maven_version" ]; then | ||
| echo -e "${RED}✘ Maven is not installed.${NC}" | ||
| all_checks_passed=false | ||
| elif version_ge "$maven_version" "$MIN_MAVEN_VERSION"; then | ||
| echo -e "${GREEN}✔ Maven version $maven_version meets the minimum requirement (>= $MIN_MAVEN_VERSION).${NC}" | ||
| else | ||
| echo -e "${RED}✘ Maven version $maven_version is older than the required version (>= $MIN_MAVEN_VERSION).${NC}" | ||
| all_checks_passed=false | ||
| fi | ||
| } | ||
| for prerequisite in "${prerequisites[@]}"; do | ||
| # uses default whitespace IFS | ||
| read -a properties <<< "$prerequisite" | ||
|
|
||
| # Check Java Version (must be between 17 and 21) | ||
| check_java_version() { | ||
| java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') | ||
| java_major_version=$(echo "$java_version" | cut -d. -f1) | ||
| name=${properties[0]} | ||
| command=${properties[1]} | ||
| action=${properties[2]} | ||
| min=${properties[3]} | ||
| max=${properties[4]:-default} | ||
|
|
||
| if [ -z "$java_version" ]; then | ||
| echo -e "${RED}✘ Java is not installed.${NC}" | ||
| all_checks_passed=false | ||
| elif [ "$java_major_version" -ge "$MIN_JAVA_VERSION" ] && [ "$java_major_version" -le "$MAX_JAVA_VERSION" ]; then | ||
| echo -e "${GREEN}✔ Java version $java_version is within the required range ($MIN_JAVA_VERSION - $MAX_JAVA_VERSION).${NC}" | ||
| else | ||
| echo -e "${RED}✘ Java version $java_version is outside the required range ($MIN_JAVA_VERSION - $MAX_JAVA_VERSION).${NC}" | ||
| all_checks_passed=false | ||
| fi | ||
| } | ||
| # first line is containing version | ||
| actual=$($command $action 2>/dev/null | head -n 1) | ||
|
|
||
| # Run all checks | ||
| echo "Starting Build Tools for VMware Aria Checks..." | ||
| if [[ $actual =~ $regex ]]; then | ||
| actualVersion=${BASH_REMATCH[0]} | ||
| is_min_ok=false | ||
| is_max_ok=false | ||
|
|
||
| if v_compare "$actualVersion" "$min"; then | ||
| is_min_ok=true | ||
| fi | ||
|
|
||
| if v_compare "$max" "$actualVersion"; then | ||
| is_max_ok=true | ||
| fi | ||
|
|
||
| check_node_version | ||
| check_maven_version | ||
| check_java_version | ||
| if $is_min_ok && $is_max_ok; then | ||
| echo -e "${GREEN}✔ ${name} version '${actualVersion}' is within the required range (${min} - ${max}).${NC}" | ||
| else | ||
| all_checks_passed=false | ||
| echo -e "${RED}✘ ${name} version '${actualVersion}' is outside of the range (${min} - ${max}).${NC}" | ||
| fi | ||
| else | ||
| echo -e "${RED}✘ ${name} is not installed.${NC}" | ||
| all_checks_passed=false | ||
| fi | ||
| done | ||
|
|
||
| # Display summary | ||
| if [ "$all_checks_passed" = true ]; then | ||
| echo -e "${GREEN}All checks passed successfully.${NC}" | ||
| echo -e "${GREEN}All checks passed successfully.${NC}" | ||
| else | ||
| echo -e "${RED}Some checks failed. Please review the above messages.${NC}" | ||
| echo -e "${RED}Some checks failed. Please review the above messages.${NC}" | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For maven it is a bit hard to say since maven seems to be more flexible, I've tested with 3.6 - 3.9. but don't know about other versions.