diff --git a/.github/workflows/test-formula.yml b/.github/workflows/test-formula.yml new file mode 100644 index 0000000..13db344 --- /dev/null +++ b/.github/workflows/test-formula.yml @@ -0,0 +1,49 @@ +name: Test Homebrew Formulas + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + # Check out the repository + - name: Check out code + uses: actions/checkout@v3 + + # Set up Homebrew + - name: Set up Homebrew + run: | + sudo apt-get update + sudo apt-get install -y build-essential curl file git + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + + # Tap tech-thinker/tap + - name: Tap tech-thinker/tap + run: | + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + brew tap tech-thinker/tap + + # Install and test all formulas in the Formula directory + - name: Test all formulas + run: | + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + # Find all formula files in the Formula directory + FORMULAS=$(find Formula -name "*.rb") + + # Loop through each formula + for formula in $FORMULAS; do + formula_name=$(basename $formula .rb) + echo "Testing $formula_name..." + brew install --build-from-source ./Formula/$formula_name.rb + brew test ./Formula/$formula_name.rb + brew uninstall $formula_name + done diff --git a/Formula/gnote.rb b/Formula/gnote.rb index d0ea76f..9a31621 100644 --- a/Formula/gnote.rb +++ b/Formula/gnote.rb @@ -45,4 +45,9 @@ def install end end end + + test do + # Check if the `gnote` binary executes and displays the help message + assert_match "Version", shell_output("#{bin}/gnote version") + end end diff --git a/Formula/sws.rb b/Formula/sws.rb index 5949491..f763f93 100644 --- a/Formula/sws.rb +++ b/Formula/sws.rb @@ -44,4 +44,9 @@ def install end end end + + test do + # Check if the `sws` binary executes and displays the help message + assert_match "sws", shell_output("#{bin}/sws --version") + end end diff --git a/Formula/tasks.rb b/Formula/tasks.rb index 2888fff..757749b 100644 --- a/Formula/tasks.rb +++ b/Formula/tasks.rb @@ -44,4 +44,9 @@ def install end end end + + test do + # Check if the `tasks` binary executes and displays the help message + assert_match "tasks", shell_output("#{bin}/tasks version") + end end