Skip to content

Commit 829af60

Browse files
committed
Tests: implement a generic subset filter
The reusable workflow now reads standard exclude rules passed by the user (e.g., `{"os": "windows-latest"}`). It subtracts any matching items from the include array using robust `jq` logic before handing the final matrix to GitHub Actions.
1 parent 037b26c commit 829af60

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/reusable-testing.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,17 @@ jobs:
323323
}
324324
EOF
325325
)
326-
MERGED_MATRIX=$(echo "$MATRIX" "$ADDITIONAL_MATRIX" | jq -s '{include: (.[0].include + .[1].include | map(if .os == null then .os = "" else . end) | unique), exclude: (.[0].exclude + .[1].exclude | unique)}')
326+
MERGED_MATRIX=$(echo "$MATRIX" "$ADDITIONAL_MATRIX" | jq -s '
327+
. as $root |
328+
(($root[0].exclude // []) + ($root[1].exclude // [])) as $excludes |
329+
{
330+
include: (
331+
(.[0].include + .[1].include | map(if .os == null then .os = "" else . end)) |
332+
map(. as $item | select($excludes | any(. as $rule | all($rule|keys[]; $item[.] == $rule[.])) | not)) |
333+
unique
334+
)
335+
}
336+
')
327337
echo matrix=$MERGED_MATRIX >> $GITHUB_OUTPUT
328338
329339
prepare-unit:

0 commit comments

Comments
 (0)