From 4407a0de11c0327a9dc2072be789efa11b28cacb Mon Sep 17 00:00:00 2001 From: "Keto D. Zhang" Date: Wed, 20 Nov 2024 00:22:03 -0800 Subject: [PATCH] ci: configure pr's matrix from hatch env json file --- .github/workflows/hatch-matrix.json | 36 +++++++++++++++++++++++++++++ .github/workflows/pr.yml | 17 ++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/hatch-matrix.json diff --git a/.github/workflows/hatch-matrix.json b/.github/workflows/hatch-matrix.json new file mode 100644 index 0000000..141d1bb --- /dev/null +++ b/.github/workflows/hatch-matrix.json @@ -0,0 +1,36 @@ +{ + "include": [ + { + "hatch-env-name": "test.py3.10-numpy-version=1", + "python-version": "3.10" + }, + { + "hatch-env-name": "test.py3.10-numpy-version=2", + "python-version": "3.10" + }, + { + "hatch-env-name": "test.py3.11-numpy-version=1", + "python-version": "3.11" + }, + { + "hatch-env-name": "test.py3.11-numpy-version=2", + "python-version": "3.11" + }, + { + "hatch-env-name": "test.py3.12-numpy-version=1", + "python-version": "3.12" + }, + { + "hatch-env-name": "test.py3.12-numpy-version=2", + "python-version": "3.12" + }, + { + "hatch-env-name": "test.py3.13-numpy-version=1", + "python-version": "3.13" + }, + { + "hatch-env-name": "test.py3.13-numpy-version=2", + "python-version": "3.13" + } + ] +} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a5d6950..3f3b617 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,12 +6,21 @@ on: branches: ["main", "v1"] jobs: + prepare-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - name: Set matrix + id: set-matrix + run: echo "matrix=$(cat .github/workflows/hatch-matrix.json | jq -c )" >> $GITHUB_OUTPUT test: runs-on: ubuntu-latest + needs: prepare-matrix strategy: fail-fast: false - matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} steps: - uses: actions/checkout@v4 @@ -24,6 +33,6 @@ jobs: python -m pip install --upgrade pip python -m pip install hatch - name: Pytest - run: hatch run +py=${{ matrix.python-version }} test:test-cov + run: hatch -e ${{ matrix.hatch-env-name }} run test-cov - name: Coverage report - run: hatch run +py=${{ matrix.python-version }} test:cov-report + run: hatch run cov-report