Revert "Updated notes to tools and skip flag in setup" #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate macsetup.sh | |
on: [push, pull_request] | |
jobs: | |
validate-macsetup: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-latest] | |
arch: [x64, arm64] | |
fail-fast: false | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Run macsetup.sh | |
run: | | |
chmod +x macsetup.sh | |
./macsetup.sh --status --install | |
- name: Set up Homebrew | |
run: | | |
if ! command -v brew &> /dev/null; then | |
echo "Installing Homebrew..." | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
else | |
echo "Homebrew is already installed." | |
fi | |
- name: Install jq | |
run: | | |
if ! command -v jq &> /dev/null; then | |
echo "Installing jq..." | |
brew install jq | |
else | |
echo "jq is already installed." | |
fi | |
- name: Check if tools.json exists | |
run: | | |
macsetup_dir="$HOME/.macsetup" | |
if [ ! -f "$macsetup_dir/tools.json" ]; then | |
echo "tools.json not found in $macsetup_dir" | |
exit 1 | |
else | |
echo "tools.json found." | |
fi | |
- name: Validate installation | |
run: | | |
# Read validation commands from config/tools.json and run them | |
macsetup_dir="$HOME/.macsetup" | |
if [ ! -d "$macsetup_dir" ]; then | |
echo "$macsetup_dir does not exist." | |
exit 1 | |
fi | |
if [ ! -f "$macsetup_dir/tools.json" ]; then | |
echo "tools.json not found in $macsetup_dir" | |
exit 1 | |
fi | |
echo "folder and file exists" | |
all_installed=true | |
while IFS= read -r tool; do | |
skip=$(echo "$tool" | jq -r '.skip // false') | |
if [ "$skip" = true ]; then | |
echo "Skipping $(echo "$tool" | jq -r '.name')" | |
continue | |
fi | |
name=$(echo "$tool" | jq -r '.name') | |
verify_command=$(echo "$tool" | jq -r '.verify_command') | |
if [ -n "$verify_command" ]; then | |
echo "Validating $name..." | |
if eval "$verify_command"; then | |
echo "$name validation successful." | |
else | |
echo "$name validation failed." | |
all_installed=false | |
fi | |
else | |
echo "No validation command provided for $name." | |
fi | |
done < <(jq -c '.[]' "$macsetup_dir/tools.json") | |
echo "is all installed: $all_installed" | |
if [ "$all_installed" = false ]; then | |
echo "Some tools are not installed correctly." | |
exit 1 | |
else | |
echo "All tools are installed correctly." | |
fi |