Hi! It's been awhile since I wrote anything about SparrowCI. Not a lot changed since then, however as they say - "repetition is a mother of learning", so in this short post I am going to show how one could use SparrowCI to test their Raku modules against various Rakudo versions. Which could be quite important in case you care much about back compatibility or at least you are curious on how your code behaves against old (or new?) environments ...
Sparrow.yaml
Just drop a sparrow.yaml
file into your repo's root with a following content:
tasks:
-
name: main
default: true
language: Raku
code: |
use Text::Table::Simple;
my @columns = ("Rakudo Version", "Status", "Time", "Linux Dist");
my @rows;
my $fail = False;
for config()<tasks><multi-versions><state><list><> -> $i {
@rows.push: [ $i<version>, $i<status>, $i<time>, os() ];
$fail = True unless $i<status> eq "OK";
}
my @table = lol2table(@columns,@rows);
.say for @table;
die "some tests failed" if $fail == True;
depends:
-
name: multi-versions
-
name: multi-versions
language: Raku
config:
list:
- 2022.04
- 2022.06
- 2023.06
- 2022.12
code: |
my @state;
for config()<list><> -> $v {
my $s = %( version => $v );
if "{cache_root_dir()}/{$v}_ok".IO ~~ :e {
$s<status> = "OK";
} else {
$s<status> = "FAIL";
}
if "{cache_root_dir()}/{$v}_time".IO ~~ :e {
$s<time> = "{cache_root_dir()}/{$v}_time".IO.slurp();
} else {
$s<time> = "NA";
}
@state.push: $s;
}
update_state %( list => @state );
init: |
for config()<list><> -> $v {
run_task("test", %( version => $v ));
}
subtasks:
-
name: test
language: Bash
init: |
ignore_error
code: |
set -e
rakubrew download moar-$version
rakubrew switch moar-$version
cd source/
zef install --/test --deps-only --to=home .
/usr/bin/time -f "%E real,%U user,%S sys" -o "${cache_root_dir}/${version}_time" \
zef test . && touch "${cache_root_dir}/${version}_ok"
depends:
-
name: rakubrew-install
-
name: rakubrew-install
language: Bash
code: |
set -e
curl -sf https://rakubrew.org/perl/rakubrew -o rakubrew
sudo mv rakubrew /usr/local/bin
sudo chmod a+x /usr/local/bin/rakubrew
rakubrew mode shim
zef install --/test Text::Table::Simple
sudo apk add time --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
In this a bit lengthy YAML based pipeline important bit is config.list
input array for multi-versions
task, which sets a range of Rakudo distributions being tested against ...
Results
So once sparrow.yaml
is created - go ahead and login to https://ci.sparrowhub.io and add your repo to "your repositories" list, that is it. Give SparrowCI a few minutes (depending on current load) to do it's job and get nicely formatted results for your module's unit tests:
09:12:46 :: O----------------O--------O----------------------------------O------------O
09:12:46 :: | Rakudo Version | Status | Time | Linux Dist |
09:12:46 :: O================O========O==================================O============O
09:12:46 :: | 2022.04 | OK | 0:08.10 real,12.51 user,0.87 sys | alpine |
09:12:46 :: | 2022.06 | OK | 0:05.82 real,9.11 user,0.81 sys | alpine |
09:12:46 :: | 2023.06 | OK | 0:05.86 real,9.11 user,0.83 sys | alpine |
09:12:46 :: | 2022.12 | OK | 0:05.61 real,8.69 user,0.73 sys | alpine |
09:12:46 :: ---------------------------------------------------------------------------
Top comments (0)