Skip to content

Commit

Permalink
pybop-team#123 add custom script to dynamically generate matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Feb 11, 2024
1 parent 695170f commit bff90d6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build_matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# This helper script generates a matrix for further use in the
# scheduled/nightly builds for PyBOP, i.e., in scheduled_tests.yaml
# It generates a matrix of all combinations of the following variables:
# - python_version: 3.8, 3.9, 3.10, 3.11
# - os: ubuntu-latest, windows-latest, macos-latest
# - pybamm_version: the last four versions of PyBaMM from PyPI

python_version=("3.8" "3.9" "3.10" "3.11")
os=("ubuntu-latest" "windows-latest" "macos-latest")
# This command fetches the last four PyBaMM versions excluding release candidates from PyPI
pybamm_version=$(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 4 | tr '\n' ' ')

json='{
"include": [
'

# loop through each combination of variables to generate matrix components
for py_ver in "${python_version[@]}"; do
for os_type in "${os[@]}"; do
for pybamm_ver in "${pybamm_version[@]}"; do
json+='{
"os": "'$os_type'",
"python_version": "'$py_ver'",
"pybamm_version": "'$pybamm_ver'"
},'
done
done
done

# fix structure, removing trailing comma
json=${json%,}

# close dict
json+='
]
}'


echo "$json" | jq .

0 comments on commit bff90d6

Please sign in to comment.