-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #432 from YOU54F/chore/ci_refactor_indiv_jobs
chore(ci): refactor indiv jobs
- Loading branch information
Showing
11 changed files
with
523 additions
and
254 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
module DetectOS | ||
def self.windows_arm? | ||
return unless !(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['arch']).nil? && !(/arm64/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
|
||
def self.windows? | ||
return if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
|
||
def self.mac_arm? | ||
return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/arm64/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
|
||
def self.mac? | ||
return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
|
||
def self.linux_arm_musl? | ||
return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil? && !(/musl/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
|
||
def self.linux_musl? | ||
return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?&& !(/musl/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
def self.linux_arm? | ||
return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
|
||
def self.linux? | ||
return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil? | ||
true | ||
end | ||
|
||
def self.debug? | ||
return if ENV['DEBUG_TARGET'].nil? | ||
true | ||
end | ||
|
||
def self.get_bin_path | ||
if debug? | ||
ENV['PACT_FFI_LIBRARY_PATH'].to_s | ||
elsif windows_arm? | ||
File.expand_path("#{__dir__}/../rust/target/aarch64-pc-windows-msvc/release/pact_ffi.dll") | ||
elsif windows? | ||
File.expand_path("#{__dir__}/../rust/target/x86_64-pc-windows-msvc/release/pact_ffi.dll") | ||
elsif mac_arm? | ||
File.expand_path("#{__dir__}/../rust/target/aarch64-apple-darwin/release/libpact_ffi.dylib") | ||
elsif mac? | ||
File.expand_path("#{__dir__}/../rust/target/x86_64-apple-darwin/release/libpact_ffi.dylib") | ||
elsif linux_arm_musl? | ||
File.expand_path("#{__dir__}/../rust/target/aarch64-unknown-linux-musl/release/libpact_ffi.so") | ||
elsif linux_musl? | ||
File.expand_path("#{__dir__}/../rust/target/x86_64-unknown-linux-musl/release/libpact_ffi.so") | ||
elsif linux_arm? | ||
File.expand_path("#{__dir__}/../rust/target/aarch64-unknown-linux-gnu/release/libpact_ffi.so") | ||
elsif linux? | ||
File.expand_path("#{__dir__}/../rust/target/x86_64-unknown-linux-gnu/release/libpact_ffi.so") | ||
else | ||
raise "Detected #{RbConfig::CONFIG['arch']}-- I have no idea what to do with that." | ||
end | ||
end | ||
|
||
def self.get_os | ||
if windows_arm? | ||
'win-arm64' | ||
elsif windows? | ||
'win' | ||
elsif mac_arm? | ||
'macos-arm64' | ||
elsif mac? | ||
'linux-x8664' | ||
elsif linux_arm? | ||
'linux-aarch64' | ||
elsif linux? | ||
'linux-x8664' | ||
else | ||
raise "Detected #{RbConfig::CONFIG['arch']}-- I have no idea what to do with that." | ||
end | ||
end | ||
end | ||
|
||
ENV['PACT_DEBUG'] ? (puts "Detected platform: #{RbConfig::CONFIG['arch']} \nLoad Path: #{DetectOS.get_bin_path}" ): nil |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
case $1 in | ||
x86_64-unknown-linux-musl) | ||
docker run --platform=linux/amd64 --rm -v $(pwd)/..:/home -w /home/ruby ruby:alpine ruby test_ffi.rb | ||
;; | ||
aarch64-unknown-linux-musl) | ||
docker run --platform=linux/arm64 --rm -v $(pwd)/..:/home -w /home/ruby ruby:alpine ruby test_ffi.rb | ||
;; | ||
x86_64-unknown-linux-gnu) | ||
docker run --platform=linux/amd64 --rm -v $(pwd)/..:/home -w /home/ruby ruby:slim ruby test_ffi.rb | ||
;; | ||
aarch64-unknown-linux-gnu) | ||
docker run --platform=linux/arm64 --rm -v $(pwd)/..:/home -w /home/ruby ruby:slim ruby test_ffi.rb | ||
;; | ||
aarch64-pc-windows-msvc) | ||
echo unable to test in github actions | ||
exit 0 | ||
;; | ||
*) ruby test_ffi.rb ;; | ||
esac |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'fiddle' | ||
require_relative 'detect_os' | ||
|
||
lib = Fiddle.dlopen(DetectOS.get_bin_path) | ||
|
||
pactffi_version = Fiddle::Function.new( | ||
lib['pactffi_version'], | ||
[], | ||
Fiddle::TYPE_VOIDP | ||
) | ||
pactffi_logger_init = Fiddle::Function.new( | ||
lib['pactffi_logger_init'], | ||
[], | ||
Fiddle::TYPE_VOIDP | ||
) | ||
pactffi_logger_apply = Fiddle::Function.new( | ||
lib['pactffi_logger_apply'], | ||
[], | ||
Fiddle::TYPE_VOIDP | ||
) | ||
pactffi_logger_attach_sink = Fiddle::Function.new( | ||
lib['pactffi_logger_attach_sink'], | ||
[Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT], | ||
Fiddle::TYPE_VOIDP | ||
) | ||
pactffi_log_message = Fiddle::Function.new( | ||
lib['pactffi_log_message'], | ||
[Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], | ||
Fiddle::TYPE_VOIDP | ||
) | ||
|
||
pactffi_logger_init.call | ||
pactffi_logger_attach_sink.call('stdout', 5) | ||
pactffi_logger_apply.call | ||
pactffi_log_message.call('pact-ruby-fiddle', 'INFO', "hello from ffi version: #{pactffi_version.call}, platform: #{RUBY_PLATFORM}") |
Oops, something went wrong.