chore: fix linux x86 build (#427) #207
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: Build Gems | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - "releases/*" | |
| permissions: | |
| contents: read | |
| actions: write | |
| jobs: | |
| build-platform-gems: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see | |
| # https://github.com/temporalio/sdk-ruby/issues/172 | |
| include: | |
| - rubyPlatform: aarch64-linux | |
| - rubyPlatform: aarch64-linux-musl | |
| # aws-lc-rs refuses to use GCC version included in image due to compiler bug | |
| - rubyPlatform: x86_64-linux | |
| gccVersion: "10" | |
| - rubyPlatform: x86_64-linux-musl | |
| - rubyPlatform: arm64-darwin | |
| - rubyPlatform: x86_64-darwin | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: recursive | |
| - name: Read protoc version | |
| shell: bash | |
| run: echo "PROTOC_VERSION=$(tr -d '\n' < .protoc-version)" >> "$GITHUB_ENV" | |
| - name: Setup Ruby and Rust | |
| uses: oxidize-rb/actions/setup-ruby-and-rust@e5f9a49a7812a078584072f6e3f657ad247c8771 # v1 | |
| with: | |
| ruby-version: "4.0" | |
| bundler-cache: false # Needed so 'bundler install' doesn't run | |
| cargo-cache: true | |
| cargo-vendor: true | |
| working-directory: ./temporalio | |
| cache-version: v1-${{ matrix.rubyPlatform }} | |
| # rb-sys-dock runs the native gem build inside a Docker container and does | |
| # not inherit arbitrary host tools, so we derive a pinned image with the | |
| # exact protoc version baked in for release builds. | |
| - name: Build rb-sys-dock image | |
| id: build-rb-sys-dock-image | |
| working-directory: ./temporalio | |
| run: | | |
| gem install rb_sys --no-document | |
| rb_sys_version="$(ruby -e 'require "rb_sys/version"; puts RbSys::VERSION')" | |
| custom_image="temporalio-rbsys/${{ matrix.rubyPlatform }}:${rb_sys_version}-protoc-${PROTOC_VERSION}" | |
| docker build \ | |
| --platform linux/amd64 \ | |
| --build-arg BASE_IMAGE="rbsys/${{ matrix.rubyPlatform }}:${rb_sys_version}" \ | |
| --build-arg GCC_VERSION="${{ matrix.gccVersion || '' }}" \ | |
| --build-arg PROTOC_VERSION="${PROTOC_VERSION}" \ | |
| -t "$custom_image" \ | |
| -f ../.github/docker/rb-sys-protoc.Dockerfile \ | |
| .. | |
| echo "image=$custom_image" >> "$GITHUB_OUTPUT" | |
| # Cannot use oxidize-rb/actions/cross-gem because it has older Rust and we | |
| # need --mount-toolchains to get latest Rust, see | |
| # https://github.com/oxidize-rb/actions/issues/61 | |
| - name: Cross compile gem | |
| id: cross-gem | |
| working-directory: ./temporalio | |
| run: | | |
| RCD_IMAGE="${{ steps.build-rb-sys-dock-image.outputs.image }}" rb-sys-dock --platform "${{ matrix.rubyPlatform }}" --ruby-versions "3.3,3.4,4.0" --mount-toolchains --build | |
| echo "gem-path=$(find pkg -name '*-${{ matrix.rubyPlatform }}.gem')" >> "$GITHUB_OUTPUT" | |
| - name: Upload gem | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 | |
| with: | |
| if-no-files-found: error | |
| name: ${{ matrix.rubyPlatform }}-gem | |
| path: ./temporalio/${{ steps.cross-gem.outputs.gem-path }} | |
| build-source-gem: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: recursive | |
| - name: Read protoc version | |
| shell: bash | |
| run: echo "PROTOC_VERSION=$(tr -d '\n' < .protoc-version)" >> "$GITHUB_ENV" | |
| - name: Setup Ruby and Rust | |
| uses: oxidize-rb/actions/setup-ruby-and-rust@e5f9a49a7812a078584072f6e3f657ad247c8771 # v1 | |
| with: | |
| ruby-version: "4.0" | |
| bundler-cache: true | |
| cargo-cache: true | |
| cache-version: v1-source | |
| - name: Install protoc | |
| uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3 | |
| with: | |
| version: ${{ env.PROTOC_VERSION }} | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Fix gem directory permissions | |
| run: chmod -R o-w "$RUNNER_TOOL_CACHE/Ruby" || true | |
| - name: Install bundle | |
| working-directory: ./temporalio | |
| run: bundle install | |
| - name: Build | |
| working-directory: ./temporalio | |
| run: bundle exec rake build | |
| - name: Upload gem | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 | |
| with: | |
| name: source-gem | |
| path: temporalio/pkg/*.gem | |
| smoke-test-gems: | |
| needs: | |
| - build-platform-gems | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # TODO(cretz): Enable Linux ARM. See ci.yaml comment for why we can't right now. | |
| # | |
| # TODO(cretz): Enable windows-latest if we can figure out Windows issue, see | |
| # https://github.com/temporalio/sdk-ruby/issues/172 | |
| # | |
| # TODO(cretz): macos-intel (macos-13) is not tested against because the GH runner for it | |
| # does not have updated certificates and it is not easy to update them, see | |
| # https://github.com/temporalio/sdk-ruby/issues/306 | |
| os: [ubuntu-latest, macos-latest] | |
| rubyVersion: ["3.3", "3.4", "4.0"] | |
| # Container defaults to empty/none, but additional container for Alpine | |
| # added later | |
| container: [""] | |
| include: | |
| - os: ubuntu-latest | |
| rubyPlatform: x86_64-linux | |
| - os: macos-latest | |
| rubyPlatform: arm64-darwin | |
| - os: ubuntu-latest | |
| rubyVersion: "3.3" | |
| container: alpine/git:latest | |
| rubyPlatform: x86_64-linux-musl | |
| runs-on: ${{ matrix.os }} | |
| container: ${{ matrix.container }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: recursive | |
| - name: Download gem | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| with: | |
| name: ${{ matrix.rubyPlatform }}-gem | |
| path: local-gem | |
| # This only works on official runners | |
| - name: Setup Ruby | |
| if: ${{ matrix.container == '' }} | |
| uses: oxidize-rb/actions/setup-ruby-and-rust@e5f9a49a7812a078584072f6e3f657ad247c8771 # v1 | |
| with: | |
| ruby-version: "${{ matrix.rubyVersion }}" | |
| bundler-cache: true | |
| cargo-cache: false | |
| # Works for Alpine | |
| - name: Setup Ruby (Alpine) | |
| if: ${{ matrix.container == 'alpine/git:latest' }} | |
| run: apk add --no-cache ruby ruby-dev ruby-bundler build-base | |
| - name: Run smoke test | |
| run: ruby ./temporalio/smoke_test/smoke_test_gem.rb 'local-gem/*-${{ matrix.rubyPlatform }}.gem' |