Skip to content

Commit 058f385

Browse files
authored
[CI] Enable matrix CI runs different Ruby versions and OSs (#61)
* Enable matrix CI runs for ruby 2.7, 3.0 and 3.1 on ubuntu, macos and windows * Remove windows-latest for now * Add GH token to protoc step to avoid getting rate limited * Try disabling cache * Allow all to run * Bring back Rust cache * Wait for the MockServer to start in Connection integration specs * Fix signal spec for Ruby 2.7 * Use correct path for Rust cache * Use OS and Ruby version in Rust cache key to avoid overlap between jobs * Add comment describing empty hash args
1 parent 8a7ba2e commit 058f385

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,41 @@ on: # rebuild any PRs and main branch changes
1010
jobs:
1111
# Lint and test the project
1212
build-lint-test:
13-
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
ruby:
17+
- 2.7.6
18+
- 3.0.4
19+
- 3.1.2
20+
os:
21+
- ubuntu-latest
22+
- macos-latest
23+
runs-on: ${{ matrix.os }}
1424
steps:
25+
- name: Print build information
26+
run: 'echo head_ref: ${{ github.head_ref }}, ref: ${{ github.ref }}, os: ${{ matrix.os }}, ruby: ${{ matrix.ruby }}'
1527
- uses: actions/checkout@v2
1628
with:
1729
submodules: recursive
1830
- uses: actions-rs/toolchain@v1
1931
with:
2032
toolchain: stable
2133
- uses: arduino/setup-protoc@v1
34+
with:
35+
repo-token: ${{ secrets.GITHUB_TOKEN }}
2236
- uses: ruby/setup-ruby@v1
2337
with:
24-
ruby-version: 3.0
38+
ruby-version: ${{ matrix.ruby }}
2539
bundler-cache: true
2640
# Needed to compile go test server and worker
2741
- uses: actions/setup-go@v2
2842
with:
2943
go-version: "1.19"
30-
- uses: Swatinem/rust-cache@v1
44+
- uses: Swatinem/rust-cache@v2
3145
with:
32-
working-directory: bridge
46+
workspaces: bridge
47+
key: ${{ matrix.os }}-${{ matrix.ruby }}
3348
- name: Setup Golang test server caches
3449
uses: actions/cache@v3
3550
with:

spec/integration/client_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ def wait_for_server(url)
204204
input = { action_signal: 'test-signal' }
205205
handle = subject.start_workflow(workflow, input, id: id, task_queue: task_queue)
206206

207-
handle.signal('test-signal', { result: { value: 'test signal arg' } })
207+
# Empty hash as the last arg is required in Ruby 2.7 to distinguish hash argument from kwargs
208+
handle.signal('test-signal', { result: { value: 'test signal arg' } }, **{})
208209

209210
expect(handle.result).to eq('test signal arg')
210211
end

spec/integration/connection_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,27 @@
55
describe Temporal::Connection do
66
mock_address = '0.0.0.0:4444'.freeze
77

8+
def wait_for_mock_server(address, attempts, interval = 1)
9+
request = Temporal::Api::WorkflowService::V1::GetSystemInfoRequest.new
10+
attempts.times do |i|
11+
connection = described_class.new("http://#{address}")
12+
connection.get_system_info(request)
13+
break
14+
rescue StandardError => e
15+
puts "Error connecting to a mock server: #{e}. Attempt #{i + 1} / #{attempts}"
16+
raise if i + 1 == attempts # re-raise upon exhausting attempts
17+
18+
sleep interval
19+
end
20+
end
21+
822
subject { described_class.new("http://#{mock_address}") }
923

1024
# TODO: For some reason the Bridge doesn't play well with the server in the same
1125
# process throwing SegFaults in cases. Needs further investigation
1226
before(:all) do
1327
@pid = fork { MockServer.run(mock_address) }
14-
sleep 0.1 # wait for the server to boot up
28+
wait_for_mock_server(mock_address, 10)
1529
end
1630
after(:all) { Process.kill('QUIT', @pid) }
1731

0 commit comments

Comments
 (0)