-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pipelines/ruby: add new pipelines to ruby packages
Signed-off-by: Dentrax <[email protected]>
- Loading branch information
Showing
4 changed files
with
128 additions
and
1 deletion.
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,28 @@ | ||
package: | ||
name: ruby3.2-json | ||
version: 2.7.2 | ||
epoch: 1 | ||
description: Tests for ruby3.2-json using Ruby test pipelines | ||
|
||
pipeline: | ||
|
||
# Test ruby/require, and ruby/test pipelines | ||
test: | ||
environment: | ||
contents: | ||
packages: | ||
- ruby-3.2 | ||
pipeline: | ||
# Test require with command | ||
- uses: ruby/test | ||
with: | ||
command: ruby -e "require 'json'" | ||
# Test require directly | ||
- uses: ruby/require | ||
with: | ||
require: json | ||
# Test require with multiple requires | ||
- uses: ruby/require | ||
with: | ||
requires: | | ||
require 'json' |
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,85 @@ | ||
name: Test a Ruby package require, with optional load clause | ||
|
||
needs: | ||
packages: | ||
- ${{inputs.ruby}} | ||
|
||
inputs: | ||
ruby: | ||
description: Which Ruby to use | ||
default: ruby | ||
require: | ||
description: | | ||
The package to require. | ||
required: false | ||
requires: | ||
description: | | ||
Commands to require packages, each line is a separate command. Example: | ||
require 'foo' | ||
# test that otherthing can be required from asdf | ||
require 'asdf' | ||
require 'bark' # this is like woof | ||
full-line and inline comments are supported via '#' | ||
required: false | ||
|
||
pipeline: | ||
- runs: | | ||
set +x | ||
RUBY="${{inputs.ruby}}" | ||
SINGLE_REQUIRE="${{inputs.require}}" | ||
MULTIPLE_REQUIRES="${{inputs.requires}}" | ||
perform_require() { | ||
command="$1" | ||
if $RUBY -e "$command"; then | ||
echo "$RUBY -e \"$command\": PASS" | ||
else | ||
echo "$RUBY -e \"$command\": FAIL" | ||
return 1 | ||
fi | ||
} | ||
if [ "$RUBY" = "ruby" ]; then | ||
glob="/usr/bin/ruby-3.[0-9][0-9] /usr/bin/ruby-3.[789] /usr/bin/ruby" | ||
n=0 | ||
for p in $glob; do | ||
[ -x "$p" ] && n=$((n+1)) && rb=$p | ||
done | ||
if [ "$n" -ne 1 ]; then | ||
echo "FAIL: must set inputs.ruby: " \ | ||
"found $n executables matching $glob" | ||
[ "$n" -eq 0 ] || echo "found:" $glob | ||
exit 1 | ||
fi | ||
echo "using ruby $rb" | ||
RUBY=$rb | ||
fi | ||
if [ -n "$SINGLE_REQUIRE" ] && [ -n "$MULTIPLE_REQUIRES" ]; then | ||
echo "Error: Cannot mix 'require' with 'requires'." | ||
exit 1 | ||
fi | ||
fail_flag=0 | ||
if [ -n "$MULTIPLE_REQUIRES" ]; then | ||
requiref=$(mktemp) || { echo "failed mktemp"; exit 1; } | ||
printf "%s\n" "$MULTIPLE_REQUIRES" > "$requiref" || | ||
{ echo "failed to write to temp file"; exit 1; } | ||
while read line; do | ||
# Drop anything after # | ||
line=${line%%#*} | ||
cmd=$(set -f; echo $line) # normalize/trim whitespace | ||
[ -z "$cmd" ] && continue | ||
perform_require "$cmd" || fail_flag=1 | ||
done < "$requiref" | ||
rm -f "$requiref" | ||
elif [ -n "$SINGLE_REQUIRE" ]; then | ||
perform_require "require '$SINGLE_REQUIRE'" || fail_flag=1 | ||
else | ||
echo "No package specified for require." | ||
fail_flag=1 | ||
fi | ||
exit $fail_flag |
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,14 @@ | ||
name: Test a Ruby package | ||
|
||
needs: | ||
packages: | ||
- busybox | ||
|
||
inputs: | ||
command: | ||
description: | | ||
The command to run. | ||
required: true | ||
|
||
pipeline: | ||
- runs: ${{inputs.command}} |