Skip to content

Commit

Permalink
workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rsk0315 committed Feb 12, 2024
1 parent 6d8cfd0 commit f917881
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions scripts/ci-test.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,71 @@ pass_lib=$($mktemp --suffix=.md)
pass_doc=$($mktemp --suffix=.md)
fail_lib=$($mktemp --suffix=.md)
fail_doc=$($mktemp --suffix=.md)
notest_lib=$($mktemp --suffix=.md)
notest_doc=$($mktemp --suffix=.md)

cargo_test() {
temp=$($mktemp --suffix=.json)
pass="$1"
fail="$2"
opt="$3"
last_failed_dir=''
notest="$3"
opt="$4"
last_pass_dir=''
last_fail_dir=''
last_notest_dir=''
failed=''

for dir in nekolib-src/*/; do
dir="${${(s:/:)dir}[2]}"
echo "### \`$dir\`" >>$pass
for toml in nekolib-src/$dir/*/Cargo.toml; do
crate="${${(s:/:)toml}[3]}"
echo "- \`$crate\`" >>$pass

cargo test "${(s: :)opt}" --manifest-path=$toml --message-format=json \
-- -Z unstable-options --format=json \
| jq -rs 'map(select(.event != "started") | select(.type == "test"))' >$temp


tested=''
if cat $temp | jq -e '.[] | select(.event == "ok")' >/dev/null; then
# some test passed
tested=t
if [[ $last_pass_dir != $dir ]]; then
echo "### \`$dir\`" >>$pass
last_pass_dir=$dir
fi
echo "- \`$crate\`" >>$pass
cat $temp \
| jq -r '.[] | select(.event == "ok") | .name' \
| sort | sed 's/.*/ - `&`/' >>$pass
fi
if cat $temp | jq -e '.[] | select(.event == "failed")' >/dev/null; then
# some test failed
if [[ $last_failed_dir != $dir ]]; then
tested=t
failed=t
if [[ $last_fail_dir != $dir ]]; then
echo "### \`$dir\`" >>$fail
last_failed_dir=$dir
last_fail_dir=$dir
fi
echo "- \`$crate\`" >>$fail
cat $temp \
| jq -r '.[] | select(.event == "failed") | .name' \
| sort | sed 's/.*/ - `&`/' >>$fail
fi
if [[ -z "$tested" ]]; then
if [[ $last_notest_dir != $dir ]]; then
echo "### \`$dir\`" >>$notest
last_notest_dir=$dir
fi
echo "- \`$crate\`" >>$notest
fi
done
done

[[ "$failed" == t ]]
}

cargo_test "$pass_lib" "$fail_lib" '--lib --release'
cargo_test "$pass_lib" "$fail_lib" "$notest_lib" '--lib --release'
(( ? == 0 )) || fail=t
cargo_test "$pass_doc" "$fail_doc" '--doc --release'
cargo_test "$pass_doc" "$fail_doc" "$notest_doc" '--doc --release'
(( ? == 0 )) || fail=t

echo '## :x: failed (`--lib`)'
Expand All @@ -70,4 +92,14 @@ echo '---'
echo '## :sparkles: passed (`--doc`)'
cat $pass_doc

[[ $fail == t ]]
echo '---'

echo '## :smiling_face_with_tear: passed (`--lib`)'
cat $notest_lib

echo '---'

echo '## :smiling_face_with_tear:: passed (`--doc`)'
cat $notest_doc

[[ "$failed" != t ]]

0 comments on commit f917881

Please sign in to comment.