name: Ruby SDK Test Suite

on:
  pull_request:
    branches:
      - main
    paths:
      - apps/ruby-sdk/**
      - .github/workflows/test-ruby-sdk.yml
  push:
    branches:
      - main
    paths:
      - apps/ruby-sdk/**
  workflow_dispatch:

jobs:
  build-and-test:
    name: Build and Test
    runs-on: blacksmith-4vcpu-ubuntu-2404
    if: >-
      github.event_name == 'workflow_dispatch' ||
      github.event_name == 'pull_request' ||
      (github.event_name == 'push' && github.ref == 'refs/heads/main')
    steps:
      - uses: actions/checkout@v4

      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.3"
          bundler-cache: true
          working-directory: ./apps/ruby-sdk

      - name: Install dependencies
        working-directory: ./apps/ruby-sdk
        run: bundle install

      - name: Run unit tests
        working-directory: ./apps/ruby-sdk
        run: bundle exec rake test
