diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b83b2b3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,49 @@ +name: brew test-bot + +on: + push: + branches: + - main + pull_request: + +jobs: + test-bot: + name: Test formula on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories + os: [ubuntu-latest, macos-13, macos-latest] + steps: + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@master + + - name: Cache Homebrew Bundler RubyGems + uses: actions/cache@v4 + with: + path: ${{ steps.set-up-homebrew.outputs.gems-path }} + key: ${{ matrix.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} + restore-keys: ${{ matrix.os }}-rubygems- + + - run: brew test-bot --only-cleanup-before + + - run: brew test-bot --only-setup + + - run: brew test-bot --only-tap-syntax + + - run: brew test-bot --only-formulae + if: github.event_name == 'pull_request' + + - name: Install latest version of formula + run: brew install logchange/tap/logchange + + - name: Run formula tests + run: brew test logchange/tap/logchange + + - name: Upload bottles as artifact + if: always() && github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: bottles_${{ matrix.os }} + path: '*.bottle.*' diff --git a/Formula/logchange.rb b/Formula/logchange.rb index f9a7b0a..81b744b 100755 --- a/Formula/logchange.rb +++ b/Formula/logchange.rb @@ -32,4 +32,9 @@ def install chmod 0755, "#{libexec}/logchange-#{os_arch}/logchange" bin.write_exec_script "#{libexec}/logchange-#{os_arch}/logchange" end + + test do + output = shell_output("#{bin}/logchange --version") + assert_match version.to_s, output + end end