Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test against SDK main

# Exercises the example app against the unreleased Castle Ruby SDK (main
# branch). This is the permanent test/sdk-main branch: every push to it runs
# the suite against the latest main. Nightly/manual runs require this file to
# also live on the default branch (GitHub only honours schedule/workflow_dispatch
# from the default branch).
on:
push:
branches: [test/sdk-main]
workflow_dispatch:
schedule:
- cron: "0 6 * * *"

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false

- name: Point the app at the SDK main branch
run: ./scripts/set-sdk-version.sh main

- name: Install dependencies
run: bundle install

- name: Set up the test database
run: |
cp config/database.yml.example config/database.yml
bundle exec rails db:test:prepare

- name: Run the test suite
run: bundle exec rspec
28 changes: 28 additions & 0 deletions scripts/set-sdk-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Point the example app at a specific Castle Ruby SDK source.
#
# set-sdk-version.sh main -> track the SDK's main branch (pre-release testing)
# set-sdk-version.sh 9.3.0 -> pin the released ~> 9.3 gem from RubyGems
#
# Rewrites the castle-rb line in the Gemfile and regenerates Gemfile.lock.
set -euo pipefail

target="${1:?usage: set-sdk-version.sh <main|X.Y.Z>}"

ruby - "$target" <<'RUBY'
target = ARGV[0]
path = "Gemfile"
content = File.read(path)
pattern = /^\s*gem ['"]castle-rb['"].*$/
abort "no castle-rb gem line found in #{path}" unless content.match?(pattern)
line =
if target == "main"
"gem 'castle-rb', github: 'castle/castle-ruby', branch: 'main'"
else
minor = target.split(".")[0, 2].join(".")
"gem 'castle-rb', '~> #{minor}'"
end
File.write(path, content.gsub(pattern, line))
RUBY

bundle lock