|
| 1 | +name: Matrix Test |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main, devel] |
| 5 | + pull_request: |
| 6 | + branches: [main, devel] |
| 7 | + |
| 8 | +jobs: |
| 9 | + get-python-versions: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + python-versions: ${{ steps.set-versions.outputs.python-versions }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + - uses: actions/setup-python@v4 |
| 16 | + with: |
| 17 | + python-version: "3.11" |
| 18 | + |
| 19 | + - name: Install dependencies |
| 20 | + run: pip install tomli |
| 21 | + |
| 22 | + - id: set-versions |
| 23 | + run: | |
| 24 | + # Create a Python script to read and parse versions |
| 25 | + cat > get_versions.py << 'EOF' |
| 26 | + import tomli |
| 27 | + import re |
| 28 | + import json |
| 29 | +
|
| 30 | + # Read pyproject.toml |
| 31 | + with open("pyproject.toml", "rb") as f: |
| 32 | + data = tomli.load(f) |
| 33 | +
|
| 34 | + # Get Python version requirement |
| 35 | + python_req = data["project"]["requires-python"] |
| 36 | +
|
| 37 | + # Parse min and max versions |
| 38 | + min_version = re.search(r">=(\d+\.\d+)", python_req) |
| 39 | + max_version = re.search(r"<(\d+\.\d+)", python_req) |
| 40 | +
|
| 41 | + versions = [] |
| 42 | + if min_version and max_version: |
| 43 | + # Convert version strings to tuples |
| 44 | + min_v = tuple(map(int, min_version.group(1).split("."))) |
| 45 | + max_v = tuple(map(int, max_version.group(1).split("."))) |
| 46 | +
|
| 47 | + # Generate version list |
| 48 | + current = min_v |
| 49 | + while current < max_v: |
| 50 | + versions.append(".".join(map(str, current))) |
| 51 | + current = (current[0], current[1] + 1) |
| 52 | +
|
| 53 | + # Print as JSON array |
| 54 | + print(json.dumps(versions)) |
| 55 | + EOF |
| 56 | +
|
| 57 | + # Run the script and capture output |
| 58 | + VERSIONS=$(python3 get_versions.py) |
| 59 | + echo "Detected versions: ${VERSIONS}" # Debug output |
| 60 | + echo "python-versions=${VERSIONS}" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + build: |
| 63 | + needs: get-python-versions |
| 64 | + strategy: |
| 65 | + matrix: |
| 66 | + python-version: ${{ fromJson(needs.get-python-versions.outputs.python-versions) }} |
| 67 | + locale: ["en_US.UTF-8", "C.UTF-8"] |
| 68 | + fail-fast: false |
| 69 | + uses: ./.github/workflows/build-ultraplot.yml |
| 70 | + with: |
| 71 | + python-version: ${{ matrix.python-version }} |
0 commit comments