-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Using a dynamically generated matrix for testing job setup (#3232)
* test: matrix building dynamically * test: calling building matrix * test: fix file permissions * feat: adding checkout * chore: adding changelog file 3232.changed.md * test: checks if github context is accessible from shell script * fix: wrong github user login * feat: checking in a script which test should be generated. * fix: final implementation * ci: replacing action * feat: adding hardlimit * fix: comments in shell file. * feat: adding matrix builder to local and minimal. renaming jobs. * fix: wrong context * feat: moving extended testing calculation to inside shell script. * fix: wrong matrix name * fix: coverage issues --------- Co-authored-by: pyansys-ci-bot <pyansys.github.bot@ansys.com>
- Loading branch information
1 parent
587a0cb
commit e80e4ef
Showing
3 changed files
with
223 additions
and
107 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 |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#!/bin/bash | ||
|
||
# List of versions | ||
versions=( | ||
# if added more "latest", change "$LATEST" | ||
'latest-ubuntu' | ||
'latest-ubuntu-student' | ||
'v24.2.0' | ||
'v24.2-ubuntu' | ||
'v24.2-ubuntu-student' | ||
'v24.1.0' | ||
'v24.1-ubuntu' | ||
'v24.1-ubuntu-student' | ||
'v23.2.0' | ||
'v23.2-ubuntu' | ||
'v23.1.0' | ||
'v23.1-ubuntu' | ||
'v22.2.1' | ||
'v22.2-ubuntu' | ||
) | ||
|
||
LATEST=2 # for 'latest-ubuntu' and 'latest-ubuntu-student' | ||
|
||
# Run only ubuntu jobs | ||
ONLY_UBUNTU="${ONLY_UBUNTU:-false}" | ||
|
||
# Do not process more than the $AUTH_USER_LIMIT_VERSIONS versions in above list | ||
AUTH_USER_LIMIT_VERSIONS="${AUTH_USER_LIMIT_VERSIONS:-3}" | ||
AUTH_USER_LIMIT=$((LATEST+AUTH_USER_LIMIT_VERSIONS*3)) | ||
|
||
# Students licenses only last a year, hence $NON_AUTH_USER_LIMIT_VERSIONS cannot be more than 2. | ||
NON_AUTH_USER_LIMIT_VERSIONS="${NON_AUTH_USER_LIMIT_VERSIONS:-2}" | ||
NON_AUTH_USER_LIMIT=$((LATEST+NON_AUTH_USER_LIMIT_VERSIONS*3)) | ||
|
||
# Hard limit version. Generally do not process more than $HARD_LIMIT_VERSION | ||
LIMIT_VERSIONS="${LIMIT_VERSIONS:-0}" | ||
HARD_LIMIT_VERSION=$((LATEST+LIMIT_VERSIONS*3)) | ||
|
||
# Checking if extended testing must be done | ||
# | ||
|
||
if [[ $ON_SCHEDULE || ( $ON_WORKFLOW_DISPATCH && $RUN_ALL_TEST ) || ( $ON_PUSH && $HAS_TAG ) ]]; then | ||
extended_testing=true | ||
else | ||
extended_testing=false | ||
fi | ||
|
||
## Start | ||
JSON="{\"include\":[" | ||
counter=0 | ||
|
||
# Loop through each version | ||
for version in "${versions[@]}"; do | ||
|
||
# 1 based counter | ||
((counter++)) | ||
|
||
# Checking hardlimit | ||
if [[ $LIMIT_VERSIONS -ne 0 && $counter -gt $HARD_LIMIT_VERSION ]]; then | ||
echo "Reached limit." | ||
break | ||
fi | ||
|
||
# checking version config | ||
if [[ "$version" == *"ubuntu"* ]]; then | ||
ON_UBUNTU=true; | ||
else | ||
ON_UBUNTU=false; | ||
fi | ||
|
||
if [[ "$version" == *"student"* ]]; then | ||
ON_STUDENT=true; | ||
else | ||
ON_STUDENT=false; | ||
fi | ||
|
||
# Printing | ||
echo "Processing $counter" | ||
echo " - Version: $version" | ||
echo " - extended_testing: $extended_testing" | ||
echo " - auth_user: $auth_user" | ||
echo " - Student: $ON_STUDENT" | ||
echo " - Ubuntu: $ON_UBUNTU" | ||
|
||
# Early exiting if on Ubuntu only | ||
if [[ "$ON_UBUNTU" != "true" && "$ONLY_UBUNTU" == "true" ]]; then | ||
echo "Skipping non-ubuntu versions" | ||
continue | ||
fi | ||
|
||
# main logic | ||
if [[ "$auth_user" == "true" ]]; then | ||
if [[ "$extended_testing" == "true" ]]; then | ||
# runs everything | ||
add_line="true"; | ||
else | ||
# Runs only "latest" and last two versions. | ||
# Last 6 entries in the list above. | ||
if [[ $counter -le $AUTH_USER_LIMIT ]]; then | ||
add_line="true"; | ||
else | ||
add_line="false"; | ||
fi | ||
fi | ||
else | ||
if [[ $ON_STUDENT == "true" && $counter -le $NON_AUTH_USER_LIMIT ]]; then | ||
add_line="true"; | ||
else | ||
add_line="false"; | ||
fi | ||
fi | ||
|
||
# Add line to json | ||
if [[ "$add_line" == "true" ]]; then | ||
JSONline="{\"mapdl-version\": \"$version\"}," | ||
|
||
echo "ADDED line: $JSONline" | ||
|
||
# checks that the line is not repeated before adding it. | ||
if [[ "$JSON" != *"$JSONline"* ]]; then | ||
JSON="$JSON$JSONline" | ||
fi | ||
else | ||
echo "NOT added line" | ||
fi | ||
echo "" | ||
|
||
done | ||
|
||
# Remove last "," and add closing brackets | ||
if [[ $JSON == *, ]]; then | ||
JSON="${JSON%?}" | ||
fi | ||
JSON="$JSON]}" | ||
echo "$JSON" | ||
|
||
# Set output | ||
echo "matrix=$( echo "$JSON" )" >> $GITHUB_OUTPUT |
Oops, something went wrong.