[WIP] New Memo() function in Go SDK for durable tasks
#87
This file contains hidden or 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: ruby | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - ".github/**" | |
| - "api/**" | |
| - "api-contracts/**" | |
| - "internal/**" | |
| - "pkg/**" | |
| - "sdks/ruby/**" | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "sdks/ruby/**" | |
| defaults: | |
| run: | |
| working-directory: ./sdks/ruby/src | |
| jobs: | |
| lint: | |
| runs-on: ubicloud-standard-4 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.2" | |
| bundler-cache: true | |
| working-directory: ./sdks/ruby/src | |
| - name: Run RuboCop | |
| run: bundle exec rubocop | |
| - name: Run RBS validate | |
| run: rbs -I sig validate | |
| - name: Test gem build | |
| run: gem build hatchet-sdk.gemspec | |
| test: | |
| runs-on: ubicloud-standard-4 | |
| strategy: | |
| matrix: | |
| ruby-version: ${{ github.event_name == 'pull_request' && fromJSON('["3.2"]') || fromJSON('["3.2", "3.3"]') }} | |
| optimistic-scheduling: ["true", "false"] | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Protoc | |
| uses: arduino/setup-protoc@v3 | |
| with: | |
| version: "25.1" | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Task | |
| uses: arduino/setup-task@v2 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: "1.25" | |
| - name: Start Docker dependencies | |
| working-directory: . | |
| run: docker compose up -d | |
| - name: Generate | |
| working-directory: . | |
| run: | | |
| export DATABASE_URL="postgresql://hatchet:hatchet@127.0.0.1:5431/hatchet" | |
| go run ./cmd/hatchet-migrate | |
| - name: Setup | |
| working-directory: . | |
| run: | | |
| export SEED_DEVELOPMENT=true | |
| export SERVER_PORT=8080 | |
| export SERVER_URL=http://localhost:8080 | |
| export SERVER_AUTH_COOKIE_DOMAIN=localhost | |
| export SERVER_AUTH_COOKIE_INSECURE=true | |
| export SERVER_DEFAULT_ENGINE_VERSION=V1 | |
| export SERVER_MSGQUEUE_RABBITMQ_URL="amqp://user:password@localhost:5672/" | |
| export SERVER_OPTIMISTIC_SCHEDULING_ENABLED=${{ matrix.optimistic-scheduling }} | |
| go run ./cmd/hatchet-admin quickstart | |
| go run ./cmd/hatchet-engine --config ./generated/ > engine.log 2>&1 & | |
| go run ./cmd/hatchet-api --config ./generated/ > api.log 2>&1 & | |
| sleep 30 | |
| - name: Set up Ruby ${{ matrix.ruby-version }} | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| working-directory: ./sdks/ruby/src | |
| - name: Display Ruby version | |
| run: ruby -v | |
| - name: Generate Env File | |
| working-directory: . | |
| run: | | |
| echo "HATCHET_CLIENT_TOKEN=$(go run ./cmd/hatchet-admin token create --config ./generated/ --tenant-id 707d0855-80ab-4e1f-a156-f1c4546cbf52)" >> $GITHUB_ENV | |
| echo "HATCHET_CLIENT_TLS_ROOT_CA_FILE=../../../certs/ca.cert" >> $GITHUB_ENV | |
| echo "HATCHET_CLIENT_WORKER_HEALTHCHECK_ENABLED=true" >> $GITHUB_ENV | |
| - name: Set HATCHET_CLIENT_NAMESPACE | |
| run: | | |
| RUBY_VER=$(ruby -e "puts \"rb#{RUBY_VERSION.gsub('.','')[0..1]}\"") | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| echo "HATCHET_CLIENT_NAMESPACE=${RUBY_VER}-${SHORT_SHA}" >> $GITHUB_ENV | |
| - name: Run unit tests | |
| run: | | |
| echo "Using HATCHET_CLIENT_NAMESPACE: $HATCHET_CLIENT_NAMESPACE" | |
| bundle exec rspec --format documentation --tag ~integration | |
| - name: Run integration tests | |
| run: bundle exec rspec spec/integration/ --format documentation --tag integration | |
| - name: Set up Ruby for examples | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| working-directory: ./sdks/ruby/examples | |
| - name: Start example worker | |
| working-directory: ./sdks/ruby/examples | |
| run: bundle exec ruby worker.rb > worker.log 2>&1 & | |
| - name: Wait for worker health | |
| run: | | |
| for i in $(seq 1 30); do | |
| if curl -s http://localhost:8001/health > /dev/null 2>&1; then | |
| echo "Worker is healthy after ${i}s" | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| echo "Worker failed to start within 30s" | |
| cat ./sdks/ruby/examples/worker.log || true | |
| exit 1 | |
| - name: Run e2e tests | |
| working-directory: ./sdks/ruby/examples | |
| run: bundle exec rspec -f d --fail-fast | |
| - name: Upload worker logs | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ env.HATCHET_CLIENT_NAMESPACE }}-opt-${{ matrix.optimistic-scheduling }}-worker-logs | |
| path: ./sdks/ruby/examples/worker.log | |
| - name: Upload engine logs | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ env.HATCHET_CLIENT_NAMESPACE }}-opt-${{ matrix.optimistic-scheduling }}-engine-logs | |
| path: engine.log | |
| - name: Upload API logs | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ env.HATCHET_CLIENT_NAMESPACE }}-opt-${{ matrix.optimistic-scheduling }}-api-logs | |
| path: api.log | |
| publish: | |
| runs-on: ubicloud-standard-4 | |
| needs: [lint, test] | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.2" | |
| bundler-cache: true | |
| working-directory: ./sdks/ruby/src | |
| - name: Check if version changed | |
| id: version_check | |
| run: | | |
| NEW_VERSION=$(ruby -e "require_relative 'lib/hatchet/version'; puts Hatchet::VERSION") | |
| CURRENT_VERSION=$(gem info hatchet-sdk --remote --exact 2>/dev/null | grep -oP 'hatchet-sdk \(\K[^)]+' || echo "0.0.0") | |
| if [ "$CURRENT_VERSION" == "$NEW_VERSION" ]; then | |
| echo "Version has not changed ($NEW_VERSION). Skipping publish." | |
| echo "should_publish=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Publishing version $NEW_VERSION (current: $CURRENT_VERSION)" | |
| echo "should_publish=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Configure RubyGems credentials | |
| if: steps.version_check.outputs.should_publish == 'true' | |
| uses: rubygems/configure-rubygems-credentials@main | |
| - name: Publish to RubyGems | |
| if: steps.version_check.outputs.should_publish == 'true' | |
| run: | | |
| gem build hatchet-sdk.gemspec | |
| NEW_VERSION=$(ruby -e "require_relative 'lib/hatchet/version'; puts Hatchet::VERSION") | |
| gem push hatchet-sdk-${NEW_VERSION}.gem |