Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Using a dynamically generated matrix for testing job setup #3232

Merged
merged 29 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d821eee
test: matrix building dynamically
germa89 Jun 28, 2024
3d85859
test: calling building matrix
germa89 Jun 28, 2024
2bf8ac9
test: fix file permissions
germa89 Jun 28, 2024
4f8e12a
feat: adding checkout
germa89 Jun 28, 2024
f005da7
chore: adding changelog file 3232.changed.md
pyansys-ci-bot Jun 28, 2024
0658a9a
test: checks if github context is accessible from shell script
germa89 Jun 28, 2024
f1186f5
Merge branch 'ci/using-array-job-for-setting-testing-matrix' of https…
germa89 Jun 28, 2024
c6192ab
fix: wrong github user login
germa89 Jun 28, 2024
8d0177c
feat: checking in a script which test should be generated.
germa89 Jun 28, 2024
c43e513
fix: final implementation
germa89 Jun 28, 2024
380402f
ci: replacing action
germa89 Jun 28, 2024
e0d1b29
feat: adding hardlimit
germa89 Jun 28, 2024
dfc5065
fix: comments in shell file.
germa89 Jun 28, 2024
a2a1c22
feat: adding matrix builder to local and minimal.
germa89 Jun 28, 2024
26d79bb
Merge branch 'main' into ci/using-array-job-for-setting-testing-matrix
germa89 Jun 28, 2024
f0b9645
fix: wrong context
germa89 Jun 28, 2024
23a0ef7
feat: moving extended testing calculation to inside shell script.
germa89 Jun 28, 2024
1af049e
fix: wrong matrix name
germa89 Jun 28, 2024
ff4432c
fix: coverage issues
germa89 Jun 28, 2024
09aa868
ci: renaming the jobs so they fit in the summary map
germa89 Jul 1, 2024
044bda0
Merge branch 'main' into ci/using-array-job-for-setting-testing-matrix
germa89 Jul 1, 2024
8b4bc08
Merge branch 'ci/using-array-job-for-setting-testing-matrix' of https…
germa89 Jul 1, 2024
e4f067b
Merge branch 'main' into ci/using-array-job-for-setting-testing-matrix
clatapie Jul 2, 2024
d669e43
Merge branch 'main' into ci/using-array-job-for-setting-testing-matrix
germa89 Jul 8, 2024
8caed04
fix: adding permission to read user
germa89 Jul 8, 2024
b3fc36b
Merge branch 'ci/using-array-job-for-setting-testing-matrix' of https…
germa89 Jul 8, 2024
568fadf
fix: using github token
germa89 Jul 8, 2024
4a67534
fix: using a token for auth
germa89 Jul 8, 2024
283916f
fix: using token for both jobs
germa89 Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .ci/build_matrix.sh
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
Loading
Loading