Skip to content

Commit

Permalink
Pare down cross-building configuration
Browse files Browse the repository at this point in the history
In an attempt to make the precompilation of gems easier to maintain, try
to make it as concise as possible.

Specifically:

* Switch the downloading of Abseil and RE2's archives to Rake file tasks
  as they will automatically be required by the default gem task as long
  as they are added to the gem specification.
* Switch from invoking Docker directly in CI to using the
  gem:$platform tasks we define in the Rakefile. These will
  automatically use the correct version of rake-compiler-docker's Docker
  images for us and use rake-compiler's native:$platform tasks and the
  gem package task to build the correct gem.
* Remove the test-gem-build and build-gems tasks in favour of explicitly
  using the appropriate Rake tasks (rake gem:$platform for precompiled
  gems and rake gem for the C Ruby gem).
* We keep the test-gem-install script as it is easier to pass to Docker
  and the FreeBSD VM as a single entrypoint though it now only installs
  the gem and its required dependencies (reusing the Bundler cache
  created by setup-ruby where possible) before running the test suite in
  the gem install directory.
  • Loading branch information
mudge committed Apr 27, 2024
1 parent f6dbb1d commit 81c4a74
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 235 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/precompile-gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- uses: actions/cache@v4
with:
path: ports/archives
key: archives-ubuntu-${{hashFiles('ext/re2/extconf.rb')}}
- run: |
docker run --rm -v "$(pwd):/re2" -w /re2 \
"ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-${{ inputs.platform }}" \
./scripts/test-gem-build gems ${{inputs.platform}}
key: archives-ubuntu-${{ hashFiles('ext/re2/extconf.rb') }}
- run: bundle exec rake gem:${{ inputs.platform }}
- uses: actions/upload-artifact@v4
with:
name: "cruby-${{inputs.platform}}-gem"
path: gems
name: "cruby-${{ inputs.platform }}-gem"
path: pkg/*.gem
123 changes: 76 additions & 47 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: re2 Tests

concurrency:
group: "${{github.workflow}}-${{github.sha}}"
group: "${{ github.workflow }}-${{ github.sha }}"
cancel-in-progress: true

on:
Expand All @@ -22,16 +22,16 @@ jobs:
- uses: actions/cache@v4
with:
path: ports/archives
key: archives-ubuntu-${{hashFiles('ext/re2/extconf.rb')}}
key: archives-ubuntu-${{ hashFiles('ext/re2/extconf.rb') }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- run: ./scripts/test-gem-build gems ruby
- run: bundle exec rake gem
- uses: actions/upload-artifact@v4
with:
name: cruby-gem
path: gems
path: pkg/*.gem

precompile-aarch64-linux:
uses: ./.github/workflows/precompile-gem.yml
Expand Down Expand Up @@ -124,8 +124,10 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: cruby-gem
path: gems
- run: ./scripts/test-gem-install gems --enable-system-libraries
path: pkg
- run: ./scripts/test-gem-install --enable-system-libraries
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-ubuntu:
needs: "build-cruby-gem"
Expand All @@ -141,12 +143,14 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
apt-get: libre2-dev
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-gem
path: gems
- run: ./scripts/test-gem-install gems --${{ matrix.sys }}-system-libraries
shell: bash
path: pkg
- run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-macos:
needs: "build-cruby-gem"
Expand All @@ -162,12 +166,14 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
brew: re2
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-gem
path: gems
- run: ./scripts/test-gem-install gems --${{ matrix.sys }}-system-libraries
shell: bash
path: pkg
- run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-windows-2019:
needs: "build-cruby-gem"
Expand All @@ -183,12 +189,15 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
mingw: re2
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-gem
path: gems
- run: ./scripts/test-gem-install gems --${{ matrix.sys }}-system-libraries
path: pkg
- run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries
shell: bash
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-windows-2022:
needs: "build-cruby-gem"
Expand All @@ -204,12 +213,15 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
mingw: re2
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-gem
path: gems
- run: ./scripts/test-gem-install gems --${{ matrix.sys }}-system-libraries
path: pkg
- run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries
shell: bash
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-freebsd:
needs: "build-cruby-gem"
Expand All @@ -223,13 +235,13 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: cruby-gem
path: gems
path: pkg
- uses: vmactions/freebsd-vm@v1
with:
usesh: true
copyback: false
prepare: pkg install -y ruby devel/ruby-gems sysutils/rubygem-bundler devel/pkgconf devel/cmake shells/bash devel/re2
run: ./scripts/test-gem-install gems --${{ matrix.sys }}-system-libraries
run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries

test-vendored-and-system:
needs: "build-cruby-gem"
Expand All @@ -246,10 +258,12 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: cruby-gem
path: gems
path: pkg
- name: "Link libre2 into Ruby's lib directory"
run: ln -s /usr/lib/x86_64-linux-gnu/libre2.so ${{ steps.setup-ruby.outputs.ruby-prefix }}/lib/libre2.so
- run: ./scripts/test-gem-install gems
- run: ./scripts/test-gem-install
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-precompiled-aarch64-linux:
needs: "precompile-aarch64-linux"
Expand All @@ -263,14 +277,14 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: cruby-aarch64-linux-gem
path: gems
path: pkg
- name: Enable execution of multi-architecture containers by QEMU
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- run: |
docker run --rm -v "$(pwd):/re2" -w /re2 \
--platform=linux/arm64/v8 \
ruby:${{matrix.ruby}} \
./scripts/test-gem-install ./gems
ruby:${{ matrix.ruby }} \
./scripts/test-gem-install
test-precompiled-arm-linux:
needs: "precompile-arm-linux"
Expand All @@ -284,14 +298,14 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: cruby-arm-linux-gem
path: gems
path: pkg
- name: enable execution of multi-architecture containers by qemu
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- run: |
docker run --rm -v "$(pwd):/re2" -w /re2 \
--platform=linux/arm/v7 \
ruby:${{matrix.ruby}} \
./scripts/test-gem-install ./gems
ruby:${{ matrix.ruby }} \
./scripts/test-gem-install
test-precompiled-x86-linux:
needs: "precompile-x86-linux"
Expand All @@ -305,14 +319,14 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: cruby-x86-linux-gem
path: gems
path: pkg
- name: Enable execution of multi-architecture containers by QEMU
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- run: |
docker run --rm -v "$(pwd):/re2" -w /re2 \
--platform=linux/386 \
ruby:${{matrix.ruby}} \
./scripts/test-gem-install ./gems
ruby:${{ matrix.ruby }} \
./scripts/test-gem-install
test-precompiled-x86_64-linux:
needs: "precompile-x86_64-linux"
Expand All @@ -325,12 +339,15 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
ruby-version: "${{ matrix.ruby }}"
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-x86_64-linux-gem
path: gems
- run: ./scripts/test-gem-install gems
path: pkg
- run: ./scripts/test-gem-install
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-precompiled-arm64-darwin:
needs: "precompile-arm64-darwin"
Expand All @@ -343,12 +360,15 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
ruby-version: "${{ matrix.ruby }}"
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-arm64-darwin-gem
path: gems
- run: ./scripts/test-gem-install gems
path: pkg
- run: ./scripts/test-gem-install
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-precompiled-x86_64-darwin:
needs: "precompile-x86_64-darwin"
Expand All @@ -361,12 +381,15 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
ruby-version: "${{ matrix.ruby }}"
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-x86_64-darwin-gem
path: gems
- run: ./scripts/test-gem-install gems
path: pkg
- run: ./scripts/test-gem-install
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-precompiled-x64-mingw-ucrt:
needs: "precompile-x64-mingw-ucrt"
Expand All @@ -379,13 +402,16 @@ jobs:
- uses: actions/checkout@v4
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: "${{matrix.ruby}}"
ruby-version: "${{ matrix.ruby }}"
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-x64-mingw-ucrt-gem
path: gems
- run: ./scripts/test-gem-install gems
path: pkg
- run: ./scripts/test-gem-install
shell: bash
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-precompiled-x64-mingw32:
needs: "precompile-x64-mingw32"
Expand All @@ -398,13 +424,16 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
ruby-version: "${{ matrix.ruby }}"
bundler-cache: true
- uses: actions/download-artifact@v4
with:
name: cruby-x64-mingw32-gem
path: gems
- run: ./scripts/test-gem-install gems
path: pkg
- run: ./scripts/test-gem-install
shell: bash
env:
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle

test-precompiled-x86_64-alpine:
needs: "precompile-x86_64-linux"
Expand All @@ -414,12 +443,12 @@ jobs:
ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
runs-on: ubuntu-latest
container:
image: "ruby:${{matrix.ruby}}-alpine"
image: "ruby:${{ matrix.ruby }}-alpine"
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: cruby-x86_64-linux-gem
path: gems
path: pkg
- run: apk add bash libstdc++ gcompat
- run: ./scripts/test-gem-install gems
- run: ./scripts/test-gem-install
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tmp
doc
Gemfile.lock
ports/
pkg/
Loading

0 comments on commit 81c4a74

Please sign in to comment.