Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 1 | name: Ruby Tests |
| 2 | |
| 3 | on: |
| 4 | workflow_call: |
| 5 | inputs: |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 6 | 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 Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 11 | safe-checkout: |
| 12 | required: true |
| 13 | description: "The SHA key for the commit we want to run over" |
| 14 | type: string |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 15 | 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 Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 21 | |
Joyce | 010fde9 | 2023-06-05 13:54:01 -0700 | [diff] [blame] | 22 | permissions: |
| 23 | contents: read |
| 24 | |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 25 | jobs: |
| 26 | linux: |
| 27 | strategy: |
| 28 | fail-fast: false |
| 29 | matrix: |
| 30 | include: |
Jason Lunn | c52d80c | 2023-07-24 23:13:47 -0700 | [diff] [blame] | 31 | # 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 Zhang | 360531c | 2024-03-05 07:53:55 -0800 | [diff] [blame] | 33 | - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE } |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 34 | - { 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 Zhang | 2f7b283 | 2023-12-26 19:44:33 -0800 | [diff] [blame] | 37 | - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE } |
Protobuf Team Bot | e595749 | 2024-06-04 09:57:43 -0700 | [diff] [blame] | 38 | - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI } |
Jason Lunn | 801049a | 2024-04-02 19:23:10 -0700 | [diff] [blame] | 39 | - { 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 Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 41 | |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 42 | name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.name }} ${{ matrix.ffi == 'FFI' && ' FFI' || '' }} |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 43 | runs-on: ubuntu-latest |
| 44 | steps: |
| 45 | - name: Checkout pending changes |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 46 | if: ${{ !matrix.continuous-only || inputs.continuous-run }} |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 47 | uses: protocolbuffers/protobuf-ci/checkout@v3 |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 48 | with: |
| 49 | ref: ${{ inputs.safe-checkout }} |
| 50 | - name: Run tests |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 51 | if: ${{ !matrix.continuous-only || inputs.continuous-run }} |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 52 | uses: protocolbuffers/protobuf-ci/bazel-docker@v3 |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 53 | with: |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 54 | image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:6.4.0-{0}-27cf7b86212020d7e552bc13b1e084abb971da75', matrix.ruby) }} |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 55 | credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} |
| 56 | bazel-cache: ruby_linux/${{ matrix.ruby }}_${{ matrix.bazel }} |
Jason Lunn | c52d80c | 2023-07-24 23:13:47 -0700 | [diff] [blame] | 57 | 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 Lunn | 2088bc6 | 2024-06-17 20:50:20 -0700 | [diff] [blame] | 58 | # 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 Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 61 | # if: ${{ matrix.presubmit || inputs.test-type == 'continuous' }} |
Jason Lunn | 2088bc6 | 2024-06-17 20:50:20 -0700 | [diff] [blame] | 62 | # uses: actions/upload-artifact@v4 |
| 63 | # with: |
| 64 | # name: test-logs-${{ matrix.ruby }}_${{ matrix.ffi || 'NATIVE' }} |
| 65 | # path: logs |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 66 | |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 67 | linux-32bit: |
| 68 | name: Linux 32-bit |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 69 | runs-on: ubuntu-20-4core |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 70 | steps: |
| 71 | - name: Checkout pending changes |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 72 | uses: protocolbuffers/protobuf-ci/checkout@v3 |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 73 | with: |
| 74 | ref: ${{ inputs.safe-checkout }} |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 75 | |
| 76 | - name: Cross compile protoc for i386 |
| 77 | id: cross-compile |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 78 | uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v3 |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 79 | with: |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 80 | image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.4.0-cf84e92285ca133b9c8104ad7b14d70e953cbb8e |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 81 | credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} |
| 82 | architecture: linux-i386 |
| 83 | |
| 84 | - name: Run tests |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 85 | uses: protocolbuffers/protobuf-ci/docker@v3 |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 86 | with: |
Sandy Zhang | 360531c | 2024-03-05 07:53:55 -0800 | [diff] [blame] | 87 | image: i386/ruby:3.0.2-buster |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 88 | credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} |
| 89 | command: >- |
| 90 | /bin/bash -cex ' |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 91 | gem install bundler -v 2.5.13; |
Stan Hu | 055c378 | 2023-08-15 12:25:13 -0700 | [diff] [blame] | 92 | 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 Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 98 | linux-aarch64: |
| 99 | name: Linux aarch64 |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 100 | runs-on: ubuntu-20-4core |
Mike Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 101 | steps: |
| 102 | - name: Checkout pending changes |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 103 | uses: protocolbuffers/protobuf-ci/checkout@v3 |
Mike Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 104 | with: |
| 105 | ref: ${{ inputs.safe-checkout }} |
| 106 | |
| 107 | - name: Cross compile protoc for aarch64 |
| 108 | id: cross-compile |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 109 | uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v3 |
Mike Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 110 | with: |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 111 | image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.4.0-cf84e92285ca133b9c8104ad7b14d70e953cbb8e |
Mike Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 112 | credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} |
| 113 | architecture: linux-aarch64 |
| 114 | |
| 115 | - name: Run tests |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 116 | uses: protocolbuffers/protobuf-ci/docker@v3 |
Mike Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 117 | with: |
Sandy Zhang | 360531c | 2024-03-05 07:53:55 -0800 | [diff] [blame] | 118 | image: arm64v8/ruby:3.0.2-buster |
Mike Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 119 | credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} |
| 120 | command: >- |
Mike Kruskal | f6c7fdf | 2023-04-27 16:39:42 -0700 | [diff] [blame] | 121 | /bin/bash -cex ' |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 122 | gem install bundler -v 2.5.13; |
Mike Kruskal | 9104075 | 2023-02-03 14:28:43 -0800 | [diff] [blame] | 123 | 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 Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 129 | macos: |
| 130 | strategy: |
| 131 | fail-fast: false # Don't cancel all jobs if one fails. |
| 132 | matrix: |
Jason Lunn | c52d80c | 2023-07-24 23:13:47 -0700 | [diff] [blame] | 133 | 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 Zhang | 360531c | 2024-03-05 07:53:55 -0800 | [diff] [blame] | 137 | - { version: "3.0", ffi: NATIVE } |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 138 | - { version: "3.0", ffi: FFI, continuous-only: true } |
| 139 | - { version: "3.1", continuous-only: true } |
| 140 | - { version: "3.2", continuous-only: true } |
Sandy Zhang | 0317875 | 2023-12-27 18:18:08 -0800 | [diff] [blame] | 141 | - { version: "3.3", ffi: NATIVE } |
Protobuf Team Bot | e595749 | 2024-06-04 09:57:43 -0700 | [diff] [blame] | 142 | - { version: "3.3", ffi: FFI } |
Mike Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 143 | |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 144 | name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} MacOS Ruby ${{ matrix.version }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} |
Mike Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 145 | runs-on: macos-12 |
| 146 | steps: |
| 147 | - name: Checkout pending changes |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 148 | if: ${{ !matrix.continuous-only || inputs.continuous-run }} |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 149 | uses: protocolbuffers/protobuf-ci/checkout@v3 |
Mike Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 150 | with: |
Mike Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 151 | ref: ${{ inputs.safe-checkout }} |
| 152 | |
| 153 | - name: Pin Ruby version |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 154 | if: ${{ !matrix.continuous-only || inputs.continuous-run }} |
Sandy Zhang | 0317875 | 2023-12-27 18:18:08 -0800 | [diff] [blame] | 155 | uses: ruby/setup-ruby@961f85197f92e4842e3cb92a4f97bd8e010cdbaf # v1.165.0 |
Mike Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 156 | with: |
| 157 | ruby-version: ${{ matrix.version }} |
| 158 | |
| 159 | - name: Validate version |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 160 | if: ${{ !matrix.continuous-only || inputs.continuous-run }} |
Mike Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 161 | run: ruby --version | grep ${{ matrix.version }} || (echo "Invalid Ruby version - $(ruby --version)" && exit 1) |
| 162 | |
| 163 | - name: Run tests |
Deanna Garcia | 2f9cdd1 | 2024-08-14 09:07:29 -0700 | [diff] [blame] | 164 | if: ${{ !matrix.continuous-only || inputs.continuous-run }} |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 165 | uses: protocolbuffers/protobuf-ci/bazel@v3 |
Mike Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 166 | with: |
| 167 | credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} |
| 168 | bazel-cache: ruby_macos/${{ matrix.version }} |
Jason Lunn | c52d80c | 2023-07-24 23:13:47 -0700 | [diff] [blame] | 169 | 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 Kruskal | f0ef44d | 2023-02-02 15:53:04 -0800 | [diff] [blame] | 170 | |
Deanna Garcia | f6a6b06 | 2024-08-23 14:10:11 -0700 | [diff] [blame] | 171 | # This test should always be skipped on presubmit |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 172 | test_ruby_gems: |
| 173 | strategy: |
| 174 | fail-fast: false |
| 175 | matrix: |
| 176 | include: |
Jason Lunn | c52d80c | 2023-07-24 23:13:47 -0700 | [diff] [blame] | 177 | # 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 Zhang | 360531c | 2024-03-05 07:53:55 -0800 | [diff] [blame] | 179 | - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE} |
| 180 | - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI} |
Mike Kruskal | a80daa2 | 2023-07-28 17:07:02 -0700 | [diff] [blame] | 181 | - { name: Ruby 3.1, ruby: ruby-3.1.0} |
Sandy Zhang | 0317875 | 2023-12-27 18:18:08 -0800 | [diff] [blame] | 182 | - { 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 Lunn | 801049a | 2024-04-02 19:23:10 -0700 | [diff] [blame] | 185 | - { 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 Garcia | f6a6b06 | 2024-08-23 14:10:11 -0700 | [diff] [blame] | 187 | name: ${{ inputs.continuous-prefix }} Install ${{ matrix.name }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 188 | runs-on: ubuntu-latest |
| 189 | steps: |
| 190 | - name: Checkout pending changes |
Deanna Garcia | f6a6b06 | 2024-08-23 14:10:11 -0700 | [diff] [blame] | 191 | if: ${{ inputs.continuous-run }} |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 192 | uses: protocolbuffers/protobuf-ci/checkout@v3 |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 193 | with: |
| 194 | ref: ${{ inputs.safe-checkout }} |
| 195 | - name: Run tests |
Deanna Garcia | f6a6b06 | 2024-08-23 14:10:11 -0700 | [diff] [blame] | 196 | if: ${{ inputs.continuous-run }} |
Mike Kruskal | b28d9d4 | 2024-04-19 09:38:13 -0700 | [diff] [blame] | 197 | uses: protocolbuffers/protobuf-ci/bazel-docker@v3 |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 198 | with: |
Protobuf Team Bot | 13cf397 | 2024-09-11 07:55:04 -0700 | [diff] [blame] | 199 | image: us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:6.4.0-${{ matrix.ruby }}-27cf7b86212020d7e552bc13b1e084abb971da75 |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 200 | credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} |
| 201 | bazel-cache: ruby_install/${{ matrix.ruby }}_${{ matrix.bazel }} |
| 202 | bash: > |
| 203 | bazel --version; |
| 204 | ruby --version; |
Mike Kruskal | 395bfe1 | 2023-08-30 12:50:43 -0700 | [diff] [blame] | 205 | ./regenerate_stale_files.sh $BAZEL_FLAGS; |
Jason Lunn | c52d80c | 2023-07-24 23:13:47 -0700 | [diff] [blame] | 206 | bazel build //ruby:release //:protoc ${{ matrix.ffi == 'FFI' && '--//ruby:ffi=enabled' || '' }} $BAZEL_FLAGS; |
Mike Kruskal | a138e54 | 2023-02-01 16:10:43 -0800 | [diff] [blame] | 207 | 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 Lunn | c52d80c | 2023-07-24 23:13:47 -0700 | [diff] [blame] | 210 | ${{ 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 |