-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter the JVM matrix and include modules into it
Fixes #46367
- Loading branch information
Showing
3 changed files
with
76 additions
and
34 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,64 @@ | ||
#!/bin/bash | ||
|
||
BASEDIR=$(dirname "$0") | ||
# Purpose: Prints a filtered version of matrix-jvm-tests.json | ||
# Note: This script is only for CI and does therefore not aim to be compatible with BSD/macOS. | ||
|
||
# Filter out mac os from a matrix of build configurations. | ||
# The reason we do this is that running mac on a fork won't work; the fork won't have a self-hosted runner | ||
set -e -u -o pipefail | ||
shopt -s failglob | ||
|
||
# See https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional | ||
export IFS=$'\n' | ||
|
||
repoName=${GITHUB_REPOSITORY} | ||
# path of this shell script | ||
PRG_PATH=$( cd "$(dirname "$0")" ; pwd -P ) | ||
|
||
if [[ $repoName == "quarkusio/quarkus" ]] | ||
JSON=$(cat ${PRG_PATH}/matrix-jvm-tests.json) | ||
if [[ "${GITHUB_REPOSITORY:-DEFINED_ON_CI}" != "quarkusio/quarkus" ]]; then | ||
# Filter out mac os from a matrix of build configurations. | ||
# The reason we do this is that running mac on a fork won't work; the fork won't have a self-hosted runner | ||
# See https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional | ||
JSON=$(echo -n "$JSON" | jq 'map(. | select(.["os-name"]!="macos-arm64-latest"))') | ||
fi | ||
|
||
# Step 0: print unfiltered json and exit in case the parameter is '_all_' (full build) or print nothing if empty (no changes) | ||
if [ "$1" == '_all_' ] | ||
then | ||
echo \{java: ${JSON}\} | ||
exit 0 | ||
elif [ -z "$1" ] | ||
then | ||
matrix=$(cat $BASEDIR/matrix-jvm-tests.json) | ||
echo -n '' | ||
exit 0 | ||
fi | ||
|
||
RUNTIME_MODULES=$(echo -n "$1" | grep -Pv '^(integration-tests|tcks)/.*' || echo '') | ||
INTEGRATION_TESTS=$(echo -n "$1" | grep -Po '^integration-tests/.+' | grep -Pv '^integration-tests/(devtools|gradle|maven|devmode|kubernetes)/.*' || echo '') | ||
|
||
if [ -z "$RUNTIME_MODULES" ] && [ -z "$INTEGRATION_TESTS" ]; then | ||
echo -n '' | ||
exit 0 | ||
fi | ||
|
||
if [ -z "$RUNTIME_MODULES" ]; then | ||
JSON=$(echo -n $JSON | jq --arg category Runtime 'del( .[] | select(.category == $category) )') | ||
else | ||
RUNTIME_MODULES_COMMAND="-pl '" | ||
for RUNTIME_MODULE in $RUNTIME_MODULES; do | ||
RUNTIME_MODULES_COMMAND+="${RUNTIME_MODULE}," | ||
done | ||
RUNTIME_MODULES_COMMAND+="'" | ||
JSON=$(echo -n $JSON | jq --arg category Runtime --arg modules "${RUNTIME_MODULES_COMMAND}" '( .[] | select(.category == $category) ).modules = $modules') | ||
fi | ||
|
||
if [ -z "$INTEGRATION_TESTS" ]; then | ||
JSON=$(echo -n $JSON | jq --arg category Integration 'del( .[] | select(.category == $category) )') | ||
else | ||
# Use jq to read in a json file that represents the matrix configuration. | ||
matrix=$(jq 'map(. | select(.["os-name"]!="macos-arm64-latest"))' $BASEDIR/matrix-jvm-tests.json) | ||
INTEGRATION_TESTS_COMMAND="-pl '" | ||
for INTEGRATION_TEST in $INTEGRATION_TESTS; do | ||
INTEGRATION_TESTS_COMMAND+="${INTEGRATION_TEST}," | ||
done | ||
INTEGRATION_TESTS_COMMAND+="'" | ||
JSON=$(echo -n $JSON | jq --arg category Integration --arg modules "${INTEGRATION_TESTS_COMMAND}" '( .[] | select(.category == $category) ).modules = $modules') | ||
fi | ||
|
||
echo \{java: ${matrix}\} | ||
|
||
echo \{java: ${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
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