-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·35 lines (31 loc) · 1.36 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·35 lines (31 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# Load the base test matrix
BASE_MATRIX=$(cat "$GITHUB_ACTION_PATH/test-matrix.json")
# Check if ADDITIONAL_MATRIX is provided and not empty
if [ -n "${ADDITIONAL_MATRIX}" ]; then
# Combine the matrices by merging the include arrays
# BASE_MATRIX has format: {"include": [...]}
# ADDITIONAL_MATRIX should be an array: [...]
FINAL_MATRIX=$(echo "$BASE_MATRIX" "$ADDITIONAL_MATRIX" | jq -s '{include: (.[0].include + .[1])}')
else
# Use the base matrix as-is
FINAL_MATRIX="$BASE_MATRIX"
fi
# Filter the matrix based on GitHub event type and repository
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] || [[ ! "$GITHUB_REPOSITORY" =~ ^mariadb-corporation/ ]]; then
# Filter out enterprise db-type entries for pull requests or non-mariadb-corporation repositories
FILTERED_MATRIX=$(echo "$FINAL_MATRIX" | jq '{
include: [.include[] | select(.["db-type"] != "enterprise")]
}')
else
# Use the full matrix for other events in mariadb-corporation repositories
FILTERED_MATRIX="$FINAL_MATRIX"
fi
echo "final-matrix=$(echo "$FILTERED_MATRIX" | jq -c '.include |= sort_by(
if (.name | test("^\\\\S+\\\\s+\\\\d+\\\\.\\\\d+")) then
(.name | capture("^(?<product>\\\\S+)\\\\s+(?<major>\\\\d+)\\\\.(?<minor>\\\\d+)") |
[(.major | tonumber), (.minor | tonumber), .name])
else
[999, 999, .name]
end
)')" >> "$GITHUB_OUTPUT"