Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add round-trip tests for precompiled gems #76

Merged
merged 12 commits into from
Jul 25, 2023
351 changes: 351 additions & 0 deletions .github/workflows/precompiled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,351 @@
name: precompiled
concurrency:
group: "${{github.workflow}}-${{github.ref}}"
cancel-in-progress: true
on:
workflow_dispatch:
schedule:
- cron: "0 8 * * 3" # At 08:00 on Wednesday # https://crontab.guru/#0_8_*_*_3
push:
branches:
- main
- v*.*.x
tags:
- v*.*.*
pull_request:
types: [opened, synchronize]
branches:
- '*'

jobs:
precompiled:
strategy:
fail-fast: false
matrix:
runs-on: ["ubuntu-latest", "macos-latest"]
ruby: ["2.7", "3.0", "3.1", "3.2"]
include:
- ruby: "2.7"
runs-on: "windows-2019"
- ruby: "3.0"
runs-on: "windows-2019"
- ruby: "3.1"
runs-on: "windows-2022"
- ruby: "3.2"
runs-on: "windows-2022"
runs-on: ${{matrix.runs-on}}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
bundler-cache: true
- uses: actions/cache@v2
with:
path: ports
key: ports-${{matrix.runs-on}}-${{hashFiles('ext/re2/extconf.rb')}}
- run: bundle exec rake compile spec

cruby-package:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ports/archives
key: archives-ubuntu-${{hashFiles('ext/re2/extconf.rb')}}
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- run: ./scripts/test-gem-build gems ruby
- uses: actions/upload-artifact@v2
with:
name: cruby-gem
path: gems
retention-days: 1

cruby-linux-install:
needs: ["cruby-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v2
with:
name: cruby-gem
path: gems
- run: ./scripts/test-gem-install gems

cruby-osx-install:
needs: ["cruby-package"]
strategy:
fail-fast: false
matrix:
ruby: ["3.2"]
sys: ["enable", "disable"]
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v2
with:
name: cruby-gem
path: gems
- run: ./scripts/test-gem-install gems

cruby-windows-install:
needs: ["cruby-package"]
strategy:
fail-fast: false
matrix:
ruby: ["3.0"]
stanhu marked this conversation as resolved.
Show resolved Hide resolved
sys: ["enable", "disable"]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
stanhu marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/download-artifact@v2
with:
name: cruby-gem
path: gems
- run: |
stanhu marked this conversation as resolved.
Show resolved Hide resolved
gem install --verbose --no-document gems/*.gem
gem list -d re2
ruby -r re2 -e "puts RE2::Regexp.new('(\\d+)').match('bob 123')"

cruby-windows-install-ucrt:
needs: ["cruby-package"]
strategy:
fail-fast: false
matrix:
ruby: ["3.2"]
stanhu marked this conversation as resolved.
Show resolved Hide resolved
sys: ["enable", "disable"]
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
stanhu marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/download-artifact@v2
with:
name: cruby-gem
path: gems
- run: |
stanhu marked this conversation as resolved.
Show resolved Hide resolved
gem install --verbose --no-document gems/*.gem
gem list -d re2
ruby -r re2 -e "puts RE2::Regexp.new('(\\d+)').match('bob 123')"

cruby-native-package:
needs: ["rcd_image_version"]
strategy:
fail-fast: false
matrix:
plat:
- "aarch64-linux"
- "arm-linux"
- "arm64-darwin"
- "x64-mingw-ucrt"
- "x64-mingw32"
- "x86-linux"
- "x86_64-darwin"
- "x86_64-linux"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ports/archives
key: archives-ubuntu-${{hashFiles('ext/re2/extconf.rb')}}
- env:
DOCKER_IMAGE: "ghcr.io/rake-compiler/rake-compiler-dock-image:${{needs.rcd_image_version.outputs.rcd_image_version}}-mri-${{matrix.plat}}"
run: |
docker run --rm -v "$(pwd):/re2" -w /re2 \
${DOCKER_IMAGE} \
./scripts/test-gem-build gems ${{matrix.plat}}
- uses: actions/upload-artifact@v3
with:
name: "cruby-${{matrix.plat}}-gem"
path: gems
retention-days: 1

cruby-x86_64-linux-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v2
with:
name: cruby-x86_64-linux-gem
path: gems
- run: ./scripts/test-gem-install gems

cruby-x86-linux-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: cruby-x86-linux-gem
path: gems
- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --rm -v "$(pwd):/re2" -w /re2 \
--platform=linux/386 \
ruby:${{matrix.ruby}} \
./scripts/test-gem-install ./gems

cruby-aarch64-linux-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: cruby-aarch64-linux-gem
path: gems
- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --rm -v "$(pwd):/re2" -w /re2 \
--platform=linux/arm64/v8 \
ruby:${{matrix.ruby}} \
./scripts/test-gem-install ./gems

cruby-arm-linux-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: cruby-arm-linux-gem
path: gems
- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --rm -v "$(pwd):/re2" -w /re2 \
--platform=linux/arm/v7 \
ruby:${{matrix.ruby}} \
./scripts/test-gem-install ./gems

cruby-x86_64-musl-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: ubuntu-latest
container:
image: "ruby:${{matrix.ruby}}-alpine"
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: cruby-x86_64-linux-gem
path: gems
- run: apk add bash libstdc++ gcompat
stanhu marked this conversation as resolved.
Show resolved Hide resolved
- run: ./scripts/test-gem-install gems

cruby-x86_64-darwin-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v2
with:
name: cruby-x86_64-darwin-gem
path: gems
- run: ./scripts/test-gem-install gems

## arm64-darwin installation testing is omitted until github actions supports it
# cruby-arm64-darwin-install:
# ...

cruby-x64-mingw32-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v2
with:
name: cruby-x64-mingw32-gem
path: gems
- run: ./scripts/test-gem-install gems

cruby-x64-mingw-ucrt-install:
needs: ["cruby-native-package"]
strategy:
fail-fast: false
matrix:
ruby: ["3.2"]
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v2
with:
name: cruby-x64-mingw-ucrt-gem
path: gems
- run: ./scripts/test-gem-install gems

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious how this is running without specifying shell: bash? I expected this to fail. I wonder if there's been some shebang magic introduced on the windows images (or if github changed the default behavior?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure https://github.com/mudge/re2/actions/runs/5596591577/job/15159473313 actually ran. Maybe since ErrorActionPreference=Stop wasn't set, the job didn't actually fail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


#
# SECTION the end-to-end gem installation tests
#
rcd_image_version:
runs-on: ubuntu-latest
outputs:
rcd_image_version: ${{steps.rcd_image_version.outputs.rcd_image_version}}
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
bundler: latest
- id: rcd_image_version
run: bundle exec ruby -e 'require "rake_compiler_dock"; puts "rcd_image_version=#{RakeCompilerDock::IMAGE_VERSION}"' >> $GITHUB_OUTPUT
27 changes: 25 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CROSS_RUBY_PLATFORMS = %w[
arm-linux
arm64-darwin
x64-mingw-ucrt
x64-mingw32
x86-linux
x86-mingw32
x86_64-darwin
Expand Down Expand Up @@ -118,5 +119,27 @@ task gem_build_path do
add_vendored_libraries
end

task :spec => :compile
task :default => :spec
desc "Temporarily set VERSION to a unique timestamp"
task "set-version-to-timestamp" do
# this task is used by bin/test-gem-build
# to test building, packaging, and installing a precompiled gem
version_constant_re = /^\s*VERSION\s*=\s*["'](.*)["']$/

version_file_path = File.join(__dir__, "lib/re2/version.rb")
version_file_contents = File.read(version_file_path)

current_version_string = version_constant_re.match(version_file_contents)[1]
current_version = Gem::Version.new(current_version_string)

fake_version = Gem::Version.new(format("%s.test.%s", current_version.bump, Time.now.strftime("%Y.%m%d.%H%M")))

unless version_file_contents.gsub!(version_constant_re, " VERSION = \"#{fake_version}\"")
raise("Could not hack the VERSION constant")
end

File.open(version_file_path, "w") { |f| f.write(version_file_contents) }

puts "NOTE: wrote version as \"#{fake_version}\""
end

task default: [:compile, :spec]
Loading
Loading