blob: 54342eaa990d2f4abf48d6d981451f36d89ecd68 [file] [log] [blame]
Mike Kruskala138e542023-02-01 16:10:43 -08001name: Ruby Tests
2
3on:
4 workflow_call:
5 inputs:
Deanna Garcia2f9cdd12024-08-14 09:07:29 -07006 continuous-run:
7 required: true
8 description: "Boolean string denoting whether this run is continuous --
9 empty string for presubmit, non-empty string for continuous."
10 type: string
Mike Kruskala138e542023-02-01 16:10:43 -080011 safe-checkout:
12 required: true
13 description: "The SHA key for the commit we want to run over"
14 type: string
Deanna Garcia2f9cdd12024-08-14 09:07:29 -070015 continuous-prefix:
16 required: true
17 description: "The string continuous-only tests should be prefixed with when displaying test
18 results."
19 type: string
20
Mike Kruskala138e542023-02-01 16:10:43 -080021
Joyce010fde92023-06-05 13:54:01 -070022permissions:
23 contents: read
24
Mike Kruskala138e542023-02-01 16:10:43 -080025jobs:
26 linux:
27 strategy:
28 fail-fast: false
29 matrix:
30 include:
Jason Lunnc52d80c2023-07-24 23:13:47 -070031 # Test both FFI and Native implementations on the highest and lowest
32 # Ruby versions for CRuby and JRuby, but only on Bazel 5.x.
Sandy Zhang360531c2024-03-05 07:53:55 -080033 - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE }
Deanna Garcia2f9cdd12024-08-14 09:07:29 -070034 - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI, continuous-only: true }
35 - { name: Ruby 3.1, ruby: ruby-3.1.0, continuous-only: true }
36 - { name: Ruby 3.2, ruby: ruby-3.2.0, continuous-only: true }
Sandy Zhang2f7b2832023-12-26 19:44:33 -080037 - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE }
Protobuf Team Bote5957492024-06-04 09:57:43 -070038 - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI }
Jason Lunn801049a2024-04-02 19:23:10 -070039 - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE }
40 - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI }
Mike Kruskala138e542023-02-01 16:10:43 -080041
Deanna Garcia2f9cdd12024-08-14 09:07:29 -070042 name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.name }} ${{ matrix.ffi == 'FFI' && ' FFI' || '' }}
Mike Kruskala138e542023-02-01 16:10:43 -080043 runs-on: ubuntu-latest
44 steps:
45 - name: Checkout pending changes
Deanna Garcia2f9cdd12024-08-14 09:07:29 -070046 if: ${{ !matrix.continuous-only || inputs.continuous-run }}
Mike Kruskalb28d9d42024-04-19 09:38:13 -070047 uses: protocolbuffers/protobuf-ci/checkout@v3
Mike Kruskala138e542023-02-01 16:10:43 -080048 with:
49 ref: ${{ inputs.safe-checkout }}
50 - name: Run tests
Deanna Garcia2f9cdd12024-08-14 09:07:29 -070051 if: ${{ !matrix.continuous-only || inputs.continuous-run }}
Mike Kruskalb28d9d42024-04-19 09:38:13 -070052 uses: protocolbuffers/protobuf-ci/bazel-docker@v3
Mike Kruskala138e542023-02-01 16:10:43 -080053 with:
Protobuf Team Bot13cf3972024-09-11 07:55:04 -070054 image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:6.4.0-{0}-27cf7b86212020d7e552bc13b1e084abb971da75', matrix.ruby) }}
Mike Kruskala138e542023-02-01 16:10:43 -080055 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
56 bazel-cache: ruby_linux/${{ matrix.ruby }}_${{ matrix.bazel }}
Jason Lunnc52d80c2023-07-24 23:13:47 -070057 bazel: test //ruby/... //ruby/tests:ruby_version --test_env=KOKORO_RUBY_VERSION --test_env=BAZEL=true ${{ matrix.ffi == 'FFI' && '--//ruby:ffi=enabled --test_env=PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION=FFI' || '' }}
Jason Lunn2088bc62024-06-17 20:50:20 -070058# Useful tool for troubleshooting, but the action introduces flakes as well,
59# e.g. https://github.com/actions/upload-artifact/issues/569
60# - name: Archive log artifacts
Deanna Garcia2f9cdd12024-08-14 09:07:29 -070061# if: ${{ matrix.presubmit || inputs.test-type == 'continuous' }}
Jason Lunn2088bc62024-06-17 20:50:20 -070062# uses: actions/upload-artifact@v4
63# with:
64# name: test-logs-${{ matrix.ruby }}_${{ matrix.ffi || 'NATIVE' }}
65# path: logs
Mike Kruskala138e542023-02-01 16:10:43 -080066
Stan Hu055c3782023-08-15 12:25:13 -070067 linux-32bit:
68 name: Linux 32-bit
Protobuf Team Bot13cf3972024-09-11 07:55:04 -070069 runs-on: ubuntu-20-4core
Stan Hu055c3782023-08-15 12:25:13 -070070 steps:
71 - name: Checkout pending changes
Mike Kruskalb28d9d42024-04-19 09:38:13 -070072 uses: protocolbuffers/protobuf-ci/checkout@v3
Stan Hu055c3782023-08-15 12:25:13 -070073 with:
74 ref: ${{ inputs.safe-checkout }}
Stan Hu055c3782023-08-15 12:25:13 -070075
76 - name: Cross compile protoc for i386
77 id: cross-compile
Mike Kruskalb28d9d42024-04-19 09:38:13 -070078 uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v3
Stan Hu055c3782023-08-15 12:25:13 -070079 with:
Protobuf Team Bot13cf3972024-09-11 07:55:04 -070080 image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.4.0-cf84e92285ca133b9c8104ad7b14d70e953cbb8e
Stan Hu055c3782023-08-15 12:25:13 -070081 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
82 architecture: linux-i386
83
84 - name: Run tests
Mike Kruskalb28d9d42024-04-19 09:38:13 -070085 uses: protocolbuffers/protobuf-ci/docker@v3
Stan Hu055c3782023-08-15 12:25:13 -070086 with:
Sandy Zhang360531c2024-03-05 07:53:55 -080087 image: i386/ruby:3.0.2-buster
Stan Hu055c3782023-08-15 12:25:13 -070088 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
89 command: >-
90 /bin/bash -cex '
Protobuf Team Bot13cf3972024-09-11 07:55:04 -070091 gem install bundler -v 2.5.13;
Stan Hu055c3782023-08-15 12:25:13 -070092 cd /workspace/ruby;
93 bundle;
94 PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} rake;
95 rake clobber_package gem;
96 PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} rake test'
97
Mike Kruskal91040752023-02-03 14:28:43 -080098 linux-aarch64:
99 name: Linux aarch64
Protobuf Team Bot13cf3972024-09-11 07:55:04 -0700100 runs-on: ubuntu-20-4core
Mike Kruskal91040752023-02-03 14:28:43 -0800101 steps:
102 - name: Checkout pending changes
Mike Kruskalb28d9d42024-04-19 09:38:13 -0700103 uses: protocolbuffers/protobuf-ci/checkout@v3
Mike Kruskal91040752023-02-03 14:28:43 -0800104 with:
105 ref: ${{ inputs.safe-checkout }}
106
107 - name: Cross compile protoc for aarch64
108 id: cross-compile
Mike Kruskalb28d9d42024-04-19 09:38:13 -0700109 uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v3
Mike Kruskal91040752023-02-03 14:28:43 -0800110 with:
Protobuf Team Bot13cf3972024-09-11 07:55:04 -0700111 image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.4.0-cf84e92285ca133b9c8104ad7b14d70e953cbb8e
Mike Kruskal91040752023-02-03 14:28:43 -0800112 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
113 architecture: linux-aarch64
114
115 - name: Run tests
Mike Kruskalb28d9d42024-04-19 09:38:13 -0700116 uses: protocolbuffers/protobuf-ci/docker@v3
Mike Kruskal91040752023-02-03 14:28:43 -0800117 with:
Sandy Zhang360531c2024-03-05 07:53:55 -0800118 image: arm64v8/ruby:3.0.2-buster
Mike Kruskal91040752023-02-03 14:28:43 -0800119 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
120 command: >-
Mike Kruskalf6c7fdf2023-04-27 16:39:42 -0700121 /bin/bash -cex '
Protobuf Team Bot13cf3972024-09-11 07:55:04 -0700122 gem install bundler -v 2.5.13;
Mike Kruskal91040752023-02-03 14:28:43 -0800123 cd /workspace/ruby;
124 bundle;
125 PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} rake;
126 rake clobber_package gem;
127 PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} rake test'
128
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800129 macos:
130 strategy:
131 fail-fast: false # Don't cancel all jobs if one fails.
132 matrix:
Jason Lunnc52d80c2023-07-24 23:13:47 -0700133 include:
134 # Test both FFI and Native implementations on the highest and lowest
135 # Ruby versions for CRuby, but only on Bazel 5.x.
136 # Quote versions numbers otherwise 3.0 will render as 3
Sandy Zhang360531c2024-03-05 07:53:55 -0800137 - { version: "3.0", ffi: NATIVE }
Deanna Garcia2f9cdd12024-08-14 09:07:29 -0700138 - { version: "3.0", ffi: FFI, continuous-only: true }
139 - { version: "3.1", continuous-only: true }
140 - { version: "3.2", continuous-only: true }
Sandy Zhang03178752023-12-27 18:18:08 -0800141 - { version: "3.3", ffi: NATIVE }
Protobuf Team Bote5957492024-06-04 09:57:43 -0700142 - { version: "3.3", ffi: FFI }
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800143
Deanna Garcia2f9cdd12024-08-14 09:07:29 -0700144 name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} MacOS Ruby ${{ matrix.version }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }}
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800145 runs-on: macos-12
146 steps:
147 - name: Checkout pending changes
Deanna Garcia2f9cdd12024-08-14 09:07:29 -0700148 if: ${{ !matrix.continuous-only || inputs.continuous-run }}
Mike Kruskalb28d9d42024-04-19 09:38:13 -0700149 uses: protocolbuffers/protobuf-ci/checkout@v3
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800150 with:
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800151 ref: ${{ inputs.safe-checkout }}
152
153 - name: Pin Ruby version
Deanna Garcia2f9cdd12024-08-14 09:07:29 -0700154 if: ${{ !matrix.continuous-only || inputs.continuous-run }}
Sandy Zhang03178752023-12-27 18:18:08 -0800155 uses: ruby/setup-ruby@961f85197f92e4842e3cb92a4f97bd8e010cdbaf # v1.165.0
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800156 with:
157 ruby-version: ${{ matrix.version }}
158
159 - name: Validate version
Deanna Garcia2f9cdd12024-08-14 09:07:29 -0700160 if: ${{ !matrix.continuous-only || inputs.continuous-run }}
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800161 run: ruby --version | grep ${{ matrix.version }} || (echo "Invalid Ruby version - $(ruby --version)" && exit 1)
162
163 - name: Run tests
Deanna Garcia2f9cdd12024-08-14 09:07:29 -0700164 if: ${{ !matrix.continuous-only || inputs.continuous-run }}
Mike Kruskalb28d9d42024-04-19 09:38:13 -0700165 uses: protocolbuffers/protobuf-ci/bazel@v3
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800166 with:
167 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
168 bazel-cache: ruby_macos/${{ matrix.version }}
Jason Lunnc52d80c2023-07-24 23:13:47 -0700169 bazel: test //ruby/... --test_env=KOKORO_RUBY_VERSION=${{ matrix.version }} --test_env=BAZEL=true ${{ matrix.ffi == 'FFI' && '--//ruby:ffi=enabled --test_env=PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION=FFI' || '' }}
Mike Kruskalf0ef44d2023-02-02 15:53:04 -0800170
Deanna Garciaf6a6b062024-08-23 14:10:11 -0700171 # This test should always be skipped on presubmit
Mike Kruskala138e542023-02-01 16:10:43 -0800172 test_ruby_gems:
173 strategy:
174 fail-fast: false
175 matrix:
176 include:
Jason Lunnc52d80c2023-07-24 23:13:47 -0700177 # Test both FFI and Native implementations on the highest and lowest
178 # Ruby versions for CRuby and JRuby, but only on Bazel 5.x.
Sandy Zhang360531c2024-03-05 07:53:55 -0800179 - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE}
180 - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI}
Mike Kruskala80daa22023-07-28 17:07:02 -0700181 - { name: Ruby 3.1, ruby: ruby-3.1.0}
Sandy Zhang03178752023-12-27 18:18:08 -0800182 - { name: Ruby 3.2, ruby: ruby-3.2.0}
183 - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE }
184 - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI }
Jason Lunn801049a2024-04-02 19:23:10 -0700185 - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE }
186 - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI }
Deanna Garciaf6a6b062024-08-23 14:10:11 -0700187 name: ${{ inputs.continuous-prefix }} Install ${{ matrix.name }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }}
Mike Kruskala138e542023-02-01 16:10:43 -0800188 runs-on: ubuntu-latest
189 steps:
190 - name: Checkout pending changes
Deanna Garciaf6a6b062024-08-23 14:10:11 -0700191 if: ${{ inputs.continuous-run }}
Mike Kruskalb28d9d42024-04-19 09:38:13 -0700192 uses: protocolbuffers/protobuf-ci/checkout@v3
Mike Kruskala138e542023-02-01 16:10:43 -0800193 with:
194 ref: ${{ inputs.safe-checkout }}
195 - name: Run tests
Deanna Garciaf6a6b062024-08-23 14:10:11 -0700196 if: ${{ inputs.continuous-run }}
Mike Kruskalb28d9d42024-04-19 09:38:13 -0700197 uses: protocolbuffers/protobuf-ci/bazel-docker@v3
Mike Kruskala138e542023-02-01 16:10:43 -0800198 with:
Protobuf Team Bot13cf3972024-09-11 07:55:04 -0700199 image: us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:6.4.0-${{ matrix.ruby }}-27cf7b86212020d7e552bc13b1e084abb971da75
Mike Kruskala138e542023-02-01 16:10:43 -0800200 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
201 bazel-cache: ruby_install/${{ matrix.ruby }}_${{ matrix.bazel }}
202 bash: >
203 bazel --version;
204 ruby --version;
Mike Kruskal395bfe12023-08-30 12:50:43 -0700205 ./regenerate_stale_files.sh $BAZEL_FLAGS;
Jason Lunnc52d80c2023-07-24 23:13:47 -0700206 bazel build //ruby:release //:protoc ${{ matrix.ffi == 'FFI' && '--//ruby:ffi=enabled' || '' }} $BAZEL_FLAGS;
Mike Kruskala138e542023-02-01 16:10:43 -0800207 gem install bazel-bin/ruby/google-protobuf-*;
208 bazel-bin/protoc --proto_path=src --proto_path=ruby/tests --proto_path=ruby --ruby_out=ruby tests/test_import_proto2.proto;
209 bazel-bin/protoc --proto_path=src --proto_path=ruby/tests --proto_path=ruby --ruby_out=ruby tests/basic_test.proto;
Jason Lunnc52d80c2023-07-24 23:13:47 -0700210 ${{ matrix.ffi == 'FFI' && 'PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION=FFI' || '' }} ruby ruby/tests/basic.rb;
211 ${{ matrix.ffi == 'FFI' && 'PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION=FFI' || '' }} ruby ruby/tests/implementation.rb