diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 627dbc24b..a4a569828 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -1,12 +1,13 @@ name: Build docs on: - push: - branches: [main] - pull_request: - branches: [main] + workflow_call: + inputs: + python-version: + required: true + type: string jobs: - build: + build-docs: runs-on: ubuntu-latest timeout-minutes: 15 steps: @@ -16,6 +17,7 @@ jobs: environment-file: ./environment-dev.yml init-shell: bash create-args: --verbose + python=${{ inputs.python-version }} cache-environment: true cache-downloads: false diff --git a/.github/workflows/build-ultraplot.yml b/.github/workflows/build-ultraplot.yml index 6df88c53d..4fcc0d43e 100644 --- a/.github/workflows/build-ultraplot.yml +++ b/.github/workflows/build-ultraplot.yml @@ -1,12 +1,14 @@ name: Build and Test on: - push: - branches: [main] - pull_request: - branches: [main] + workflow_call: + inputs: + python-version: + required: true + type: string jobs: - build: + build-ultraplot: + name: Test Python ${{ inputs.python-version }} runs-on: ubuntu-latest timeout-minutes: 15 steps: @@ -15,7 +17,9 @@ jobs: with: environment-file: ./environment-dev.yml init-shell: bash - create-args: --verbose + create-args: >- + --verbose + python=${{ inputs.python-version }} cache-environment: true cache-downloads: false diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 45fce116e..0ba6769e0 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -6,7 +6,7 @@ on: branches: [main] jobs: - build: + linter: runs-on: ubuntu-latest timeout-minutes: 15 steps: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..81c8075c0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,68 @@ +name: Matrix Test +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + get-python-versions: + runs-on: ubuntu-latest + outputs: + python-versions: ${{ steps.set-versions.outputs.python-versions }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: pip install tomli + + - id: set-versions + run: | + # Save the Python script to a file + cat > get_versions.py << 'EOF' + import tomli + import re + import json + + with open("pyproject.toml", "rb") as f: + data = tomli.load(f) + python_req = data["project"]["requires-python"] + min_version = re.search(r">=(\d+\.\d+)", python_req) + max_version = re.search(r"<(\d+\.\d+)", python_req) + + versions = [] + if min_version and max_version: + min_v = tuple(map(int, min_version.group(1).split("."))) + max_v = tuple(map(int, max_version.group(1).split("."))) + current = min_v + while current < max_v: + versions.append(".".join(map(str, current))) + current = (current[0], current[1] + 1) + + print(json.dumps(versions)) + EOF + + # Run the Python script and capture output + VERSIONS=$(python3 get_versions.py) + echo "python-versions=${VERSIONS}" >> $GITHUB_OUTPUT + + build-test: + needs: get-python-versions + strategy: + matrix: + python-version: ${{ fromJson(needs.get-python-versions.outputs.python-versions) }} + uses: ./.github/workflows/build-ultraplot.yml + with: + python-version: ${{ matrix.python-version }} + + build-docs: + needs: get-python-versions + strategy: + matrix: + python-version: ${{ fromJson(needs.get-python-versions.outputs.python-versions) }} + uses: ./.github/workflows/build-docs.yml + with: + python-version: ${{ matrix.python-version }}